Skip to content

Commit

Permalink
Merge pull request #182 from clintlombard/fix/empty-polling
Browse files Browse the repository at this point in the history
Fix Poller poll to handle empty case
  • Loading branch information
pebbe authored Feb 18, 2022
2 parents 5806f25 + 7c72941 commit 4333451
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions draft/polling.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,10 @@ func (p *Poller) PollAll(timeout time.Duration) ([]Polled, error) {
func (p *Poller) poll(timeout time.Duration, all bool) ([]Polled, error) {
lst := make([]Polled, 0, len(p.items))

if len(p.items) == 0 {
return lst, nil
}

var ctx *Context
for _, soc := range p.socks {
if !soc.opened {
Expand Down
4 changes: 4 additions & 0 deletions polling.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,10 @@ func (p *Poller) PollAll(timeout time.Duration) ([]Polled, error) {
func (p *Poller) poll(timeout time.Duration, all bool) ([]Polled, error) {
lst := make([]Polled, 0, len(p.items))

if len(p.items) == 0 {
return lst, nil
}

var ctx *Context
for _, soc := range p.socks {
if !soc.opened {
Expand Down

0 comments on commit 4333451

Please sign in to comment.