mirror of
https://github.com/ninenines/cowboy.git
synced 2025-07-14 04:10:24 +00:00
Make sure cowboy_http doesn't receive stray timeout messages
This commit is contained in:
parent
f673e191b3
commit
8f6ee9c186
1 changed files with 11 additions and 2 deletions
|
@ -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}.
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue