mirror of
https://github.com/mjl-/mox.git
synced 2025-07-14 05:34:38 +03:00
fix race in test setup/teardown
not easily triggered, but it happened just now on a build server.
This commit is contained in:
@ -71,8 +71,7 @@ func FuzzServer(f *testing.F) {
|
||||
if err != nil {
|
||||
f.Fatalf("set password: %v", err)
|
||||
}
|
||||
done := store.Switchboard()
|
||||
defer close(done)
|
||||
defer store.Switchboard()()
|
||||
|
||||
comm := store.RegisterComm(acc)
|
||||
defer comm.Unregister()
|
||||
|
@ -346,11 +346,9 @@ func startArgs(t *testing.T, first, isTLS, allowLoginWithoutTLS bool) *testconn
|
||||
err = acc.SetPassword("testtest")
|
||||
tcheck(t, err, "set password")
|
||||
}
|
||||
var switchDone chan struct{}
|
||||
switchStop := func() {}
|
||||
if first {
|
||||
switchDone = store.Switchboard()
|
||||
} else {
|
||||
switchDone = make(chan struct{}) // Dummy, that can be closed.
|
||||
switchStop = store.Switchboard()
|
||||
}
|
||||
|
||||
serverConn, clientConn := net.Pipe()
|
||||
@ -368,7 +366,7 @@ func startArgs(t *testing.T, first, isTLS, allowLoginWithoutTLS bool) *testconn
|
||||
cid := connCounter
|
||||
go func() {
|
||||
serve("test", cid, tlsConfig, serverConn, isTLS, allowLoginWithoutTLS)
|
||||
close(switchDone)
|
||||
switchStop()
|
||||
close(done)
|
||||
}()
|
||||
client, err := imapclient.New(clientConn, true)
|
||||
|
Reference in New Issue
Block a user