|
|
@@ -813,3 +813,22 @@ func TestClusterConfigAfterClose(t *testing.T) {
|
|
|
t.Fatal("timed out before Cluster Config returned")
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+func TestDispatcherToCloseDeadlock(t *testing.T) {
|
|
|
+ // Verify that we don't deadlock when calling Close() from within one of
|
|
|
+ // the model callbacks (ClusterConfig).
|
|
|
+ m := newTestModel()
|
|
|
+ c := NewConnection(c0ID, &testutils.BlockingRW{}, &testutils.NoopRW{}, m, "name", CompressAlways).(wireFormatConnection).Connection.(*rawConnection)
|
|
|
+ m.ccFn = func(devID DeviceID, cc ClusterConfig) {
|
|
|
+ c.Close(errManual)
|
|
|
+ }
|
|
|
+ c.Start()
|
|
|
+
|
|
|
+ c.inbox <- &ClusterConfig{}
|
|
|
+
|
|
|
+ select {
|
|
|
+ case <-c.dispatcherLoopStopped:
|
|
|
+ case <-time.After(time.Second):
|
|
|
+ t.Fatal("timed out before dispatcher loop terminated")
|
|
|
+ }
|
|
|
+}
|