mirror of https://github.com/docker/docs.git
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
1
AUTHORS
1
AUTHORS
|
@ -28,6 +28,7 @@ Anthony Bishopric <git@anthonybishopric.com>
|
||||||
Anton Nikitin <anton.k.nikitin@gmail.com>
|
Anton Nikitin <anton.k.nikitin@gmail.com>
|
||||||
Antony Messerli <amesserl@rackspace.com>
|
Antony Messerli <amesserl@rackspace.com>
|
||||||
apocas <petermdias@gmail.com>
|
apocas <petermdias@gmail.com>
|
||||||
|
Arnaud Porterie <arnaud.porterie@gmail.com>
|
||||||
Asbjørn Enge <asbjorn@hanafjedle.net>
|
Asbjørn Enge <asbjorn@hanafjedle.net>
|
||||||
Barry Allard <barry.allard@gmail.com>
|
Barry Allard <barry.allard@gmail.com>
|
||||||
Bartłomiej Piotrowski <b@bpiotrowski.pl>
|
Bartłomiej Piotrowski <b@bpiotrowski.pl>
|
||||||
|
|
|
@ -259,7 +259,10 @@ func (srv *Server) Events(job *engine.Job) engine.Status {
|
||||||
}
|
}
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case event := <-listener:
|
case event, ok := <-listener:
|
||||||
|
if !ok { // Channel is closed: listener was evicted
|
||||||
|
return engine.StatusOK
|
||||||
|
}
|
||||||
err := sendEvent(&event)
|
err := sendEvent(&event)
|
||||||
if err != nil && err.Error() == "JSON error" {
|
if err != nil && err.Error() == "JSON error" {
|
||||||
continue
|
continue
|
||||||
|
|
Loading…
Reference in New Issue