Skip to content

Commit 4333451

Browse files
authored
Merge pull request #182 from clintlombard/fix/empty-polling
Fix Poller poll to handle empty case
2 parents 5806f25 + 7c72941 commit 4333451

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

draft/polling.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,10 @@ func (p *Poller) PollAll(timeout time.Duration) ([]Polled, error) {
153153
func (p *Poller) poll(timeout time.Duration, all bool) ([]Polled, error) {
154154
lst := make([]Polled, 0, len(p.items))
155155

156+
if len(p.items) == 0 {
157+
return lst, nil
158+
}
159+
156160
var ctx *Context
157161
for _, soc := range p.socks {
158162
if !soc.opened {

polling.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,10 @@ func (p *Poller) PollAll(timeout time.Duration) ([]Polled, error) {
153153
func (p *Poller) poll(timeout time.Duration, all bool) ([]Polled, error) {
154154
lst := make([]Polled, 0, len(p.items))
155155

156+
if len(p.items) == 0 {
157+
return lst, nil
158+
}
159+
156160
var ctx *Context
157161
for _, soc := range p.socks {
158162
if !soc.opened {

0 commit comments

Comments
 (0)