reordered write/read operations to respond more quickly to client disconnect