Fixes infinite loop (and consequentially spiked CPU usage) on ctx timeout

This commit is contained in:
Ben Davies 2017-06-22 13:27:36 +01:00 committed by Kenneth Shaw
parent 9282791225
commit 10a6f7bd20

8
sel.go
View File

@ -83,7 +83,13 @@ func (s *Selector) run(ctxt context.Context, h cdp.Handler) chan error {
for {
root, err := h.GetRoot(ctxt)
if err != nil {
continue
select {
case <-ctxt.Done():
ch <- ctxt.Err()
return
default:
continue
}
}
select {