From a4d3c2c3d10f7d7d513d141637353039b4c58741 Mon Sep 17 00:00:00 2001 From: Filipe David Borba Manana Date: Wed, 3 Nov 2010 17:03:05 +0000 Subject: Fix ibrowse 2.0.x inactivity timeouts not getting cleared. Patch submitted upstream: http://github.com/cmullaparthi/ibrowse/issues/#issue/17 git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@1030534 13f79535-47bb-0310-9956-ffa450edef68 --- src/ibrowse/ibrowse_http_client.erl | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/ibrowse/ibrowse_http_client.erl b/src/ibrowse/ibrowse_http_client.erl index 16d9b872..2dd209da 100644 --- a/src/ibrowse/ibrowse_http_client.erl +++ b/src/ibrowse/ibrowse_http_client.erl @@ -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. -- cgit v1.2.3