mirror of
https://github.com/ninenines/cowboy.git
synced 2025-07-14 20:30:23 +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}) ->
|
cancel_timeout(State=#state{timer=TimerRef}) ->
|
||||||
ok = case TimerRef of
|
ok = case TimerRef of
|
||||||
undefined -> ok;
|
undefined ->
|
||||||
_ -> erlang:cancel_timer(TimerRef, [{async, true}, {info, false}])
|
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,
|
end,
|
||||||
State#state{timer=undefined}.
|
State#state{timer=undefined}.
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue