2
0
mirror of https://github.com/soheilhy/cmux.git synced 2025-10-09 05:33:23 +08:00

Tweak shutdown behaviour

When the root listener is closed, child listeners will not be closed
until all parked connections are served. This prevents losing
connections that have been read from.

This also allows moving the main test to package cmux_test, but that
will happen in a separate change.
This commit is contained in:
Tamir Duberstein
2015-12-11 14:33:39 -05:00
parent 9a9119af9d
commit 235d98b021
3 changed files with 80 additions and 27 deletions

View File

@@ -4,6 +4,7 @@ import (
"bytes"
"io"
"net"
"sync"
"testing"
)
@@ -31,12 +32,15 @@ func BenchmarkCMuxConn(b *testing.B) {
}
}()
b.ResetTimer()
donec := make(chan struct{})
var wg sync.WaitGroup
wg.Add(b.N)
b.ResetTimer()
for i := 0; i < b.N; i++ {
c := &mockConn{
r: bytes.NewReader(benchHTTPPayload),
}
m.serve(c)
m.serve(c, donec, &wg)
}
}