diff options
author | Loïc Hoguin <[email protected]> | 2019-10-02 16:57:22 +0200 |
---|---|---|
committer | Loïc Hoguin <[email protected]> | 2019-10-02 16:59:41 +0200 |
commit | 8f6ee9c1868ebc7bf31fb4846114919e164e0cf3 (patch) | |
tree | 83c74764f9546d0c5420c48cd969002813d551c3 /src | |
parent | f673e191b30ab440440c924476bb03000fff52c6 (diff) | |
download | cowboy-8f6ee9c1868ebc7bf31fb4846114919e164e0cf3.tar.gz cowboy-8f6ee9c1868ebc7bf31fb4846114919e164e0cf3.tar.bz2 cowboy-8f6ee9c1868ebc7bf31fb4846114919e164e0cf3.zip |
Make sure cowboy_http doesn't receive stray timeout messages
Diffstat (limited to 'src')
-rw-r--r-- | src/cowboy_http.erl | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/cowboy_http.erl b/src/cowboy_http.erl index a6c640a..6670781 100644 --- a/src/cowboy_http.erl +++ b/src/cowboy_http.erl @@ -267,8 +267,17 @@ set_timeout(State0=#state{opts=Opts, overriden_opts=Override, streams=Streams}) cancel_timeout(State=#state{timer=TimerRef}) -> ok = case TimerRef of - undefined -> ok; - _ -> erlang:cancel_timer(TimerRef, [{async, true}, {info, false}]) + undefined -> + ok; + _ -> + %% Do a synchronous cancel and remove the message if any + %% to avoid receiving stray messages. + erlang:cancel_timer(TimerRef), + receive + {timeout, TimerRef, _} -> ok + after 0 -> + ok + end end, State#state{timer=undefined}. |