]> Cypherpunks repositories - gostls13.git/commitdiff
net/http: correctly close fake net.Conns
authorDamien Neil <dneil@google.com>
Wed, 19 Nov 2025 19:25:49 +0000 (11:25 -0800)
committerGopher Robot <gobot@golang.org>
Thu, 20 Nov 2025 18:14:05 +0000 (10:14 -0800)
Fix an inverted test in fakeNetConn.Close that caused closing
a connection to not break the other half of the connection.

Change-Id: I4e53f78402f8e503c749d57f294a4524abdccfb5
Reviewed-on: https://go-review.googlesource.com/c/go/+/722220
Reviewed-by: Nicholas Husin <nsh@golang.org>
Reviewed-by: Nicholas Husin <husin@google.com>
Auto-Submit: Damien Neil <dneil@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

src/net/http/netconn_test.go

index 52b8069f8b33e175f89d7d35493d0e3ae2b77bfd..c5fd61289f73089e2a25cfbaa76625f3de8d7668 100644 (file)
@@ -180,9 +180,10 @@ func (c *fakeNetConn) Close() error {
        c.loc.unlock()
        // Remote half of the connection reads EOF after reading any remaining data.
        c.rem.lock()
-       if c.rem.readErr != nil {
+       if c.rem.readErr == nil {
                c.rem.readErr = io.EOF
        }
+       c.rem.writeErr = net.ErrClosed
        c.rem.unlock()
        if c.autoWait {
                synctest.Wait()