From 647e95aed157edd58c86acdd774048593eb9d039 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Tue, 22 Jan 2013 02:34:18 +0100 Subject: Replace terminate/2 with terminate/3, adding a Reason This should have been done a *long* time ago, back when I initially added Websocket support. This is the first part of two in improving loop handler support with regards to socket closure. Reason may include: {normal, shutdown} for the most normal shutdown, {normal, timeout} for a loop handler timeout shutdown, or {error, _} if an error occured. --- src/cowboy_loop_handler.erl | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src/cowboy_loop_handler.erl') diff --git a/src/cowboy_loop_handler.erl b/src/cowboy_loop_handler.erl index 067d672..71323d2 100644 --- a/src/cowboy_loop_handler.erl +++ b/src/cowboy_loop_handler.erl @@ -23,8 +23,8 @@ %% receive. It receives the message and the state previously defined. %% It can decide to stop the receive loop or continue receiving. %% -%% terminate/2 allows you to clean up. It receives the state -%% previously defined. +%% terminate/3 allows you to clean up. It receives the +%% termination reason and the state previously defined. %% %% There is no required operation to perform in any of these callbacks %% other than returning the proper values. Make sure you always return @@ -39,6 +39,9 @@ -type opts() :: any(). -type state() :: any(). +-type terminate_reason() :: {normal, shutdown} + | {normal, timeout} + | {error, atom()}. -callback init({atom(), http}, Req, opts()) -> {ok, Req, state()} @@ -54,4 +57,4 @@ | {loop, Req, State} | {loop, Req, State, hibernate} when Req::cowboy_req:req(), State::state(). --callback terminate(cowboy_req:req(), state()) -> ok. +-callback terminate(terminate_reason(), cowboy_req:req(), state()) -> ok. -- cgit v1.2.3