Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rpc: Fix crash during connection teardown
_buf_write.close() races with _fd.shutdown_output(). If the former happens first, it will close the socket. It is illegal to use a closed socket, so shutdown_output() was causing a crash. The code was protecting against this by checking if _send_loop_stopped is ready, but there is a deferring point between finally() callback containing _buf_write.close() is executed and the future associated with it is resolved, so this check is not enough. This patch fixes the problem by replacing the check to _send_loop_stopped.available() with a fully reliable check of a flag, which is set immediately before the stream is closed. The complication could be avoided by changing implementation of posix connected_socket to not close the whole socket but only shutdown their read/write side. In which case shutdown_output() could be called concurrently with _buf_write.close(). But this is a bigger change so was postponed. Fixes scylladb#210. Message-Id: <[email protected]>
- Loading branch information