diff options
author | Loïc Hoguin <[email protected]> | 2012-05-04 01:25:58 +0200 |
---|---|---|
committer | Loïc Hoguin <[email protected]> | 2012-05-04 01:25:58 +0200 |
commit | 1524ba4f39f03b51dda7d20ec69fb5fa7ba09bad (patch) | |
tree | f145156c8b3fe7cfeef741e4de5a682b86433d44 /src/cowboy_http_websocket.erl | |
parent | dab6648290679dd2a655eaaeea4b75beca9ae151 (diff) | |
parent | 4a8ba147fb70809e8b1e42460ca7489e933399e8 (diff) | |
download | cowboy-1524ba4f39f03b51dda7d20ec69fb5fa7ba09bad.tar.gz cowboy-1524ba4f39f03b51dda7d20ec69fb5fa7ba09bad.tar.bz2 cowboy-1524ba4f39f03b51dda7d20ec69fb5fa7ba09bad.zip |
Merge branch 'cancel-timer' of https://github.com/etrepum/cowboy
Diffstat (limited to 'src/cowboy_http_websocket.erl')
-rw-r--r-- | src/cowboy_http_websocket.erl | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/src/cowboy_http_websocket.erl b/src/cowboy_http_websocket.erl index ab96e93..f3f1cae 100644 --- a/src/cowboy_http_websocket.erl +++ b/src/cowboy_http_websocket.erl @@ -232,8 +232,7 @@ handler_loop_timeout(State=#state{timeout=infinity}) -> handler_loop_timeout(State=#state{timeout=Timeout, timeout_ref=PrevRef}) -> _ = case PrevRef of undefined -> ignore; PrevRef -> erlang:cancel_timer(PrevRef) end, - TRef = make_ref(), - erlang:send_after(Timeout, self(), {?MODULE, timeout, TRef}), + TRef = erlang:start_timer(Timeout, self(), ?MODULE), State#state{timeout_ref=TRef}. %% @private @@ -248,9 +247,9 @@ handler_loop(State=#state{messages={OK, Closed, Error}, timeout_ref=TRef}, handler_terminate(State, Req, HandlerState, {error, closed}); {Error, Socket, Reason} -> handler_terminate(State, Req, HandlerState, {error, Reason}); - {?MODULE, timeout, TRef} -> + {timeout, TRef, ?MODULE} -> websocket_close(State, Req, HandlerState, {normal, timeout}); - {?MODULE, timeout, OlderTRef} when is_reference(OlderTRef) -> + {timeout, OlderTRef, ?MODULE} when is_reference(OlderTRef) -> handler_loop(State, Req, HandlerState, SoFar); Message -> handler_call(State, Req, HandlerState, |