Skip to content

Commit

Permalink
Fix Poller poll to handle empty case
Browse files Browse the repository at this point in the history
  • Loading branch information
clintlombard committed Feb 18, 2022
1 parent 5806f25 commit 7c72941
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 7c72941

Please sign in to comment.