You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
contains a useful “connection reset by peer” error.
What did you see instead?
2009/11/10 23:00:00 127.0.0.1:47676: Accepted
2009/11/10 23:00:01 127.0.0.1:47676: Closed
panic: Patch "http://127.0.0.1:22356/": write tcp 127.0.0.1:47676->127.0.0.1:22356: use of closed network connection
contains net.ErrClosed, with no indication of the actual underlying root cause. And I think it's possibly controversial but plausible point that net.ErrClosed is considered an indication of a programming bug.
The reports in #4373 obliquely hint at net/http encountering this issue, but never quite spell it out, hence this report.
The underlying cause, at least for this specific reproducer, is that persistConn.readLoop and persistConn.writeLoop are quite independent; in this case, readLoop encounters a socket read error, terminates, and closes persistConn.conn. Meanwhile, writeLoop is deep in transferWriter.doBodyCopy, continuing to issue writes and flushes to persistConn.conn, and that triggers net.ErrClosed on the write side. Arguably that’s the primary bug, issuing a write on a closed connection.
And then, persistConn.roundTrip actually sees the read-side error first (re := <-resc:); but it proceeds to mapRoundTripError, and sees req.err set, and returns that value. Alternatively, if issuing a write on a closed connection is considered fine (or the performance cost to avoid that would be too great), the logic in mapRoundTripError could see that there is both a read-side and write-side error, and decide that net.ErrClosed is not the one that should be returned.
There also seems to be a dual of this issue, where persistConn.writeLoop can encounter an error and close the connection, causing readLoop to fail with net.ErrClosed instead, and in that case, again, an error with the “use of closed network connection” text is returned. I’m afraid I lost the reproducer I had for that one.
The text was updated successfully, but these errors were encountered: