Check channel closed state in /events loop
When listener channel is closed, it becomes always available for reading: select becomes an active loop which writes default-constructed events (i.e: empty strings). Fixes #5766. Docker-DCO-1.1-Signed-off-by: Arnaud Porterie <arnaud.porterie@gmail.com> (github: icecrime)
This commit is contained in:
parent
4af465fccf
commit
8699f53e6a
2 changed files with 5 additions and 1 deletions
1
AUTHORS
1
AUTHORS
|
@ -28,6 +28,7 @@ Anthony Bishopric <git@anthonybishopric.com>
|
|||
Anton Nikitin <anton.k.nikitin@gmail.com>
|
||||
Antony Messerli <amesserl@rackspace.com>
|
||||
apocas <petermdias@gmail.com>
|
||||
Arnaud Porterie <arnaud.porterie@gmail.com>
|
||||
Asbjørn Enge <asbjorn@hanafjedle.net>
|
||||
Barry Allard <barry.allard@gmail.com>
|
||||
Bartłomiej Piotrowski <b@bpiotrowski.pl>
|
||||
|
|
|
@ -259,7 +259,10 @@ func (srv *Server) Events(job *engine.Job) engine.Status {
|
|||
}
|
||||
for {
|
||||
select {
|
||||
case event := <-listener:
|
||||
case event, ok := <-listener:
|
||||
if !ok { // Channel is closed: listener was evicted
|
||||
return engine.StatusOK
|
||||
}
|
||||
err := sendEvent(&event)
|
||||
if err != nil && err.Error() == "JSON error" {
|
||||
continue
|
||||
|
|
Loading…
Reference in a new issue