summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRyan Dahl <ry@tinyclouds.org>2018-05-29 02:51:55 -0400
committerRyan Dahl <ry@tinyclouds.org>2018-05-29 02:54:16 -0400
commit27c2529c1a237f1ee4bd9e7c40bf48fe198193cf (patch)
treeaf2b955ee4a7cbed75632b3cc6396a0544351d6f
parent62144e7fb164418f27fba41d394b7dedd14fb522 (diff)
Add sanity check to end of DispatchLoop
-rw-r--r--dispatch.go16
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.
+ }
+}