davsync tests: the slow transfer's line is narrow both ways, so a download on macOS doesn't burst through the tuned-up buffers past the 300ms watchdog (TestSlowTransferIsNotCutShort red on macos-latest in main's run 37693090857: "took nothing for 300ms (GET)"; b1cba654 narrowed only the upload's way)
This commit is contained in:
1 parent
7b121eabc3
commit
e22d5eef81
1 file changed
+14
-2
@@ -115,7 +115,7 @@ func narrowLine(t *testing.T, h http.Handler) (*httptest.Server, *http.Client) {
|
|||||||
tr.DialContext = func(ctx context.Context, network, addr string) (net.Conn, error) {
|
tr.DialContext = func(ctx context.Context, network, addr string) (net.Conn, error) {
|
||||||
c, err := dial(ctx, network, addr)
|
c, err := dial(ctx, network, addr)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
err = c.(*net.TCPConn).SetWriteBuffer(buffer)
|
err = narrow(c, buffer)
|
||||||
}
|
}
|
||||||
return c, err
|
return c, err
|
||||||
}
|
}
|
||||||
@@ -131,11 +131,23 @@ type narrowListener struct {
|
|||||||
func (l narrowListener) Accept() (net.Conn, error) {
|
func (l narrowListener) Accept() (net.Conn, error) {
|
||||||
c, err := l.Listener.Accept()
|
c, err := l.Listener.Accept()
|
||||||
if err == nil {
|
if err == nil {
|
||||||
err = c.(*net.TCPConn).SetReadBuffer(l.buffer)
|
err = narrow(c, l.buffer)
|
||||||
}
|
}
|
||||||
return c, err
|
return c, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// narrow keeps both ways of a connection small: the PUT goes up through the
|
||||||
|
// client's send buffer and the server's receive buffer, the GET comes down
|
||||||
|
// through the other two, and on macOS a download through the tuned-up pair
|
||||||
|
// burst as the upload had (run 37693090857: "took nothing for 300ms (GET)").
|
||||||
|
func narrow(c net.Conn, buffer int) error {
|
||||||
|
tc := c.(*net.TCPConn)
|
||||||
|
if err := tc.SetReadBuffer(buffer); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return tc.SetWriteBuffer(buffer)
|
||||||
|
}
|
||||||
|
|
||||||
// A backup that takes far longer than the watchdog to go up and come back
|
// A backup that takes far longer than the watchdog to go up and come back
|
||||||
// down, but never stops moving, is written and read in full (#657: 43 MB
|
// down, but never stops moving, is written and read in full (#657: 43 MB
|
||||||
// at 305 KB/s took 2.4 minutes, and a sync was given 2).
|
// at 305 KB/s took 2.4 minutes, and a sync was given 2).
|
||||||
|
|||||||
Reference in new issue
Block a user