Skip to content

Commit

Permalink
Fix inactivity timeout when using the same worker for several requests.
Browse files Browse the repository at this point in the history
If the {inactivity_timeout, X} option is given to a worker, and several requests are sent throught that worker, after X milliseconds the inactivity timeout set for the first request is triggered.
That is, it is never cleared.
  • Loading branch information
fdmanana committed Nov 2, 2010
1 parent 7958fc2 commit 072d4f8
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/ibrowse_http_client.erl
Expand Up @@ -1713,7 +1713,15 @@ set_inac_timer(State) ->
set_inac_timer(State, get_inac_timeout(State)).

set_inac_timer(_State, Timeout) when is_integer(Timeout) ->
erlang:send_after(Timeout, self(), timeout);
TimerRef = erlang:send_after(Timeout, self(), timeout),
case erlang:put(inac_timer, TimerRef) of
OldTimer when is_reference(OldTimer) ->
erlang:cancel_timer(OldTimer),
receive timeout -> ok after 0 -> ok end;
_ ->
ok
end,
TimerRef;
set_inac_timer(_, _) ->
undefined.

Expand Down

0 comments on commit 072d4f8

Please sign in to comment.