-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve handling of closing WebSockets
Closing WebSockets can be initiated from two sides (server and client). This process involves a sort of handshake where both parties agree on closing the connection before actually closing it. When the server is reading from the socket and the client initiated closing the connection this would be handled fine. However, when the server initiated closing the connection, the process could be complicated by a potentially blocking read call on the socket in another Task. In this case there are two processes listening for control frames on the socket and it's not known in advance who will get to handle the client's reply. This is solved by adding a CLOSING state to the WebSocket which can be used to track who initiated closing the connection. Deferring handling of the client's reply to the appropriate process. This also prevents duplicate OPCODE_CLOSE messages from being sent by the server when it initiates a the close and also replies to the acknowledgement by the client when a `read` is watching the socket.
- Loading branch information
Showing
1 changed file
with
55 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters