-
Kenton Varda authored
The test "WebSocket pump disconnect on send" tests what happens if a send() throws DISCONNECTED while pumping. The test hung forever with socketpairs because the message fits entirely in the socket's send buffer, and thus send() actually completes before the disconnect occurs. This differs from userspace pipes, where there is no buffering, and so the send() doesn't complete until all data is received. This could be fixed by sending a very large message, so that the send() actually blocks on the receiver. But, the problem reveals that WebSocket pumps won't notice when the destination disconnects unless the source sends some message through. Now that we have whenWriteDisconnected(), we can fix this and proactively end the pump, which also fixes the test. In fact, we can and should propagate such disconnects backwards: if the destination disconnects, we should close the source. We can do this by adding an abort() method to WebSocket, which incidentally allows us to remove the internal AbortableWebSocket interface which was used specifically by WebSocketPipeImpl.
a90c65f4