Skip to content

Commit

Permalink
feat(server): handle_QUIT callback
Browse files Browse the repository at this point in the history
In case the implentation needs to clean up.
  • Loading branch information
sntran authored Feb 18, 2024
1 parent c37d9d3 commit 895d8a4
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/gen_nntp.erl
Original file line number Diff line number Diff line change
Expand Up @@ -711,7 +711,16 @@ handle_command(<<"HELP">>, Client) ->
% MUST acknowledge the QUIT command and then close the connection to
% the client.
handle_command(<<"QUIT">>, Client) ->
{stop, normal, <<"205 Connection closing">>, Client};
#client{module = Module, state = State} = Client
Client1 = case erlang:function_exported(Module, handle_QUIT, 1) of
false ->
Client;
true ->
{ok, NewState} = Module:handle_QUIT(State),
Client#client{state = NewState}
end,

{stop, normal, <<"205 Connection closing">>, Client1};

% Any other commands.
handle_command(Command, Client) ->
Expand Down

0 comments on commit 895d8a4

Please sign in to comment.