diff options
| author | Loïc Hoguin <[email protected]> | 2025-09-30 11:27:47 +0200 |
|---|---|---|
| committer | Loïc Hoguin <[email protected]> | 2025-09-30 11:28:07 +0200 |
| commit | e3fd6b2aa677b768a1450fe3dece466d398f61db (patch) | |
| tree | 2d6735280f051d47a3ffe9a6f26e44c71c0c50af /src | |
| parent | e713a630f384f861fa396048f9c881ca183aeda9 (diff) | |
| download | cowboy-e3fd6b2aa677b768a1450fe3dece466d398f61db.tar.gz cowboy-e3fd6b2aa677b768a1450fe3dece466d398f61db.tar.bz2 cowboy-e3fd6b2aa677b768a1450fe3dece466d398f61db.zip | |
Make HTTP/2 Websocket call terminate/3 on socket close
The close reason will differ from HTTP/1.1 because we don't
have access to the socket. Also trapping exits is required
to process the 'EXIT' signal and call terminate/3.
Diffstat (limited to 'src')
| -rw-r--r-- | src/cowboy_websocket.erl | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/cowboy_websocket.erl b/src/cowboy_websocket.erl index b66a414..152823c 100644 --- a/src/cowboy_websocket.erl +++ b/src/cowboy_websocket.erl @@ -492,8 +492,12 @@ loop(State=#state{parent=Parent, socket=Socket, messages=Messages, before_loop(State, HandlerState, ParseState); %% System messages. {'EXIT', Parent, Reason} -> - %% @todo We should exit gracefully. - exit(Reason); + %% The terminate reason will differ with HTTP/1.1 + %% since we don't have direct access to the socket. + %% @todo Perhaps we can make cowboy_children:terminate + %% receive the shutdown Reason and send {shutdown, Reason} + %% instead of just 'shutdown' in this scenario. + terminate(State, HandlerState, Reason); {system, From, Request} -> sys:handle_system_msg(Request, From, Parent, ?MODULE, [], {State, HandlerState, ParseState}); |
