Closed joesis closed 4 years ago
How about half-closed net.Conn? peer can write only.
@xtaci Do you mean session or stream? If a session is half closed, are new streams supposed to be open over it?
the behavior is exactly the same as syscall read(2) write(2), if read/write returns error on file descriptor, it's the caller's responsibility to close the file descriptor, what do you think?
OpenStream will fail if it cannot write()
the behavior is exactly the same as syscall read(2) write(2), if read/write returns error on file descriptor, it's the caller's responsibility to close the file descriptor, what do you think?
Yeah surely the caller should close stream it it sees read/write error, but it won't know that new steams are doomed to have read/write errors.
Having OpenStream
returning error in such case sounds good to me.
sounds good, if OpenStream returns false
Thanks @xtaci !!!
See https://gist.github.com/joesis/340e21f44cc65e2119668d116f397e49 for a demo. Once the client TCP connection hits read deadline (just to demonstrate. Whichever temporary error could trigger the problem), the session signals socket read error which is persisted so later
Read
on all streams will fail, butOpenStream
andWrite
on the streams can still work, until the session being closed by the keep alive timer. From the server side, everything works as if there's no problem at all.I don't think the caller is expected to close the session when seeing a single read error on one stream, which can be specific to the stream and not affecting others, so such errors should be at least visible on the session level. I would even prefer close the session as it enters into an irrecoverable state.
Thoughts?