gapi: Unblock from a waiting send on GAPI close
There was a race condition that would sometimes occur in that if we stopped reading from the gapiChan (on shutdown) but then a new message was available before we managed to close the GAPI, then we would wait forever to finish the close because the channel never sent, and the WaitGroup wouldn't let us exit. This fixes this horrible, horrible race.
This commit is contained in:
@@ -154,7 +154,11 @@ func (obj *MyGAPI) Next() chan error {
|
||||
select {
|
||||
case <-ticker.C:
|
||||
log.Printf("libmgmt: Generating new graph...")
|
||||
ch <- nil // trigger a run
|
||||
select {
|
||||
case ch <- nil: // trigger a run
|
||||
case <-obj.closeChan:
|
||||
return
|
||||
}
|
||||
case <-obj.closeChan:
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user