Skip to content

Commit aac7106

Browse files
FiloSottilegopherbot
authored andcommitted
crypto/tls: fix testHandshake close flakes
The flakes were introduced by me in CL 586655. It's unclear why only FreeBSD seems affected, maybe other TCP stacks handle sending on a half-closed connection differently, or aren't as quick to propagate the RST over localhost. Fixes #68155 Change-Id: I32a1b474a7d6531dbab93910c23568b867629e8c Reviewed-on: https://go-review.googlesource.com/c/go/+/602615 Reviewed-by: Cherry Mui <[email protected]> Run-TryBot: Filippo Valsorda <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Reviewed-by: Roland Shoemaker <[email protected]> Auto-Submit: Filippo Valsorda <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]>
1 parent 2ca1ae8 commit aac7106

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/crypto/tls/handshake_test.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -491,9 +491,10 @@ func testHandshake(t *testing.T, clientConfig, serverConfig *Config) (serverStat
491491
if got := string(buf); got != sentinel {
492492
t.Errorf("read %q from TLS connection, but expected %q", got, sentinel)
493493
}
494-
if err := cli.Close(); err != nil {
495-
t.Errorf("failed to call cli.Close: %v", err)
496-
}
494+
// We discard the error because after ReadAll returns the server must
495+
// have already closed the connection. Sending data (the closeNotify
496+
// alert) can cause a reset, that will make Close return an error.
497+
cli.Close()
497498
}()
498499
server := Server(s, serverConfig)
499500
err = server.Handshake()

0 commit comments

Comments
 (0)