Following the discussion in #4373, I propose that
the currently unexported error errClosed
in package crypto/tls be exported. That should
simplify error checking for services which use e.g. TCP,
TLS, or both types of connection depending
on configuration.
@ianlancetaylor also proposed that we replace that custom error
with internal/poll.ErrNetClosing, like it is done
in that CL, but I am not sure about that,
since that could break current code that only wishes to check
the error from crypto/tls
and not net. On the other hand, checking
against one error is obviously easier than checking
against two.
CC @FiloSottile @katiehockman
My suggestion is that we consider simply replacing crypto/tls.errClosed with net.ErrClosed. The error message will be very slightly different, but it will permit consistent use of errors.Is(err, net.ErrClosed) to see whether people are trying to do some operation on a connection has been closed. Or so it seems to me without knowing very much about how this code works.
Now that we've established net.ErrClosed as the "connection is closing/was closed" error, it does seem like TLS should use it.
ping @FiloSottile @katiehockman
The proposal to use net.ErrClosed in lieu of the unexported errClosed in crypto/tls sounds appropriate. @FiloSottile is also in agreement.
Based on the discussion above, this seems like a likely accept.
No change in consensus, so accepted.
@rsc Great, thanks! Should I send a CL or wait for someone else to do it? It seems like a small change, but it's still in a crypto package.
@ainar-g Feel free to send over a CL with this change if you would like!
Change https://golang.org/cl/256897 mentions this issue: crypto/tls: replace errClosed with net.ErrClosed
Most helpful comment
No change in consensus, so accepted.