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_http_handler.erl | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src/cowboy_http_handler.erl') diff --git a/src/cowboy_http_handler.erl b/src/cowboy_http_handler.erl index fa52f78..9c7aaa6 100644 --- a/src/cowboy_http_handler.erl +++ b/src/cowboy_http_handler.erl @@ -22,8 +22,8 @@ %% handle/2 allows you to handle the request. It receives the %% state previously defined. %% -%% 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 @@ -33,6 +33,9 @@ -type opts() :: any(). -type state() :: any(). +-type terminate_reason() :: {normal, shutdown} + | {normal, timeout} %% Only occurs in loop handlers. + | {error, atom()}. -callback init({atom(), http}, Req, opts()) -> {ok, Req, state()} @@ -45,4 +48,4 @@ when Req::cowboy_req:req(). -callback handle(Req, State) -> {ok, Req, State} 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