diff options
-rw-r--r-- | dispatch.go | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/dispatch.go b/dispatch.go index bbb696e6d..a6308709e 100644 --- a/dispatch.go +++ b/dispatch.go @@ -108,6 +108,7 @@ func DispatchLoop() { wg.Done() // Corresponds to the wg.Add(1) in Pub(). case <-doneChan: // All goroutines have completed. Now we can exit main(). + checkChanEmpty() return } @@ -120,3 +121,18 @@ func DispatchLoop() { first = false } } + +func checkChanEmpty() { + // We've received a done event. As a sanity check, make sure that resChan is + // empty. + select { + case _, ok := <-resChan: + if ok { + panic("Read a message from resChan after doneChan closed.") + } else { + panic("resChan closed. Unexpected.") + } + default: + // No value ready, moving on. + } +} |