mirror of
https://github.com/ninenines/cowboy.git
synced 2025-07-14 04:10:24 +00:00
Cancel timers async
Where it wasn't already async. To slightly improve performance.
This commit is contained in:
parent
2531b26acf
commit
fcab905eca
3 changed files with 3 additions and 3 deletions
|
@ -93,7 +93,7 @@ handle_cast(_Msg, State) ->
|
|||
-spec handle_info(any(), State) -> {noreply, State} when State::#state{}.
|
||||
handle_info(update, #state{universaltime=Prev, rfc1123=B1, tref=TRef0}) ->
|
||||
%% Cancel the timer in case an external process sent an update message.
|
||||
_ = erlang:cancel_timer(TRef0),
|
||||
_ = erlang:cancel_timer(TRef0, [{async, true}, {info, false}]),
|
||||
T = erlang:universaltime(),
|
||||
B2 = update_rfc1123(B1, Prev, T),
|
||||
ets:insert(?MODULE, {rfc1123, B2}),
|
||||
|
|
|
@ -328,7 +328,7 @@ cancel_timeout(State=#state{timer=TimerRef}) ->
|
|||
_ ->
|
||||
%% Do a synchronous cancel and remove the message if any
|
||||
%% to avoid receiving stray messages.
|
||||
_ = erlang:cancel_timer(TimerRef),
|
||||
_ = erlang:cancel_timer(TimerRef, [{async, false}, {info, false}]),
|
||||
receive
|
||||
{timeout, TimerRef, _} -> ok
|
||||
after 0 ->
|
||||
|
|
|
@ -391,7 +391,7 @@ set_idle_timeout(State=#state{opts=Opts, timeout_ref=PrevRef}, TimeoutNum) ->
|
|||
%% options are changed dynamically.
|
||||
_ = case PrevRef of
|
||||
undefined -> ignore;
|
||||
PrevRef -> erlang:cancel_timer(PrevRef)
|
||||
PrevRef -> erlang:cancel_timer(PrevRef, [{async, true}, {info, false}])
|
||||
end,
|
||||
case maps:get(idle_timeout, Opts, 60000) of
|
||||
infinity ->
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue