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:
@@ -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)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user