From 20b7f662f5f989bf4c5ac7d554c476e88f22e58b Mon Sep 17 00:00:00 2001 From: Filipe David Manana Date: Mon, 10 Jan 2011 15:14:42 +0000 Subject: [PATCH] Don't trigger new inactivity timer when socket data is received and caller controls the socket Like in synchronous programming, in makes sense to start an inactivity timer only when the caller does a "recv" call and cancel the timer as soon as data is received from the socket. --- src/ibrowse_http_client.erl | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/ibrowse_http_client.erl b/src/ibrowse_http_client.erl index 6548e2c..9447725 100644 --- a/src/ibrowse_http_client.erl +++ b/src/ibrowse_http_client.erl @@ -330,8 +330,13 @@ handle_sock_data(Data, #state{status = get_body, active_once(State_1) end, State_2 = State_1#state{interim_reply_sent = false}, - State_3 = set_inac_timer(State_2), - {noreply, State_3}; + case Ccs of + true -> + cancel_timer(State_2#state.inactivity_timer_ref, {eat_message, timeout}), + {noreply, State_2#state{inactivity_timer_ref = undefined}}; + _ -> + {no_reply, set_inac_timer(State_2)} + end; State_1 -> active_once(State_1), State_2 = set_inac_timer(State_1),