|
|
@@ -3273,6 +3273,12 @@ func TestConnCloseOnRestart(t *testing.T) {
|
|
|
br := &testutils.BlockingRW{}
|
|
|
nw := &testutils.NoopRW{}
|
|
|
m.AddConnection(newFakeProtoConn(protocol.NewConnection(device1, br, nw, m, "testConn", protocol.CompressNever)), protocol.HelloResult{})
|
|
|
+ m.pmut.RLock()
|
|
|
+ if len(m.closed) != 1 {
|
|
|
+ t.Fatalf("Expected just one conn (len(m.conn) == %v)", len(m.conn))
|
|
|
+ }
|
|
|
+ closed := m.closed[device1]
|
|
|
+ m.pmut.RUnlock()
|
|
|
|
|
|
newFcfg := fcfg.Copy()
|
|
|
newFcfg.Paused = true
|
|
|
@@ -3286,9 +3292,9 @@ func TestConnCloseOnRestart(t *testing.T) {
|
|
|
case <-time.After(5 * time.Second):
|
|
|
t.Fatal("Timed out before folder restart returned")
|
|
|
}
|
|
|
- m.pmut.RLock()
|
|
|
- defer m.pmut.RUnlock()
|
|
|
- if len(m.conn) != 0 {
|
|
|
- t.Errorf("Conn wasn't removed on restart (len(m.conn) == %v)", len(m.conn))
|
|
|
+ select {
|
|
|
+ case <-closed:
|
|
|
+ case <-time.After(5 * time.Second):
|
|
|
+ t.Fatal("Timed out before connection was closed")
|
|
|
}
|
|
|
}
|