diff options
author | Micael Karlberg <[email protected]> | 2012-01-03 11:42:58 +0100 |
---|---|---|
committer | Micael Karlberg <[email protected]> | 2012-01-03 11:42:58 +0100 |
commit | 10014b400da456869449c2affe683ddd2e252d0c (patch) | |
tree | 4fbeb0185735235e1df019bbba7b3f021f3b0257 /lib/inets/src/http_client/httpc_handler.erl | |
parent | 021d5c2e49e623d4f43c0cc88a097bc99f3564e6 (diff) | |
download | otp-10014b400da456869449c2affe683ddd2e252d0c.tar.gz otp-10014b400da456869449c2affe683ddd2e252d0c.tar.bz2 otp-10014b400da456869449c2affe683ddd2e252d0c.zip |
[inets/httpc] Fix the selection of session for keep-alive mode
When selecting a session, the "state" of the session (specifically if
the server has responded) was not taken into account. Attempting to
fix this, a "state" field (actually available) has been added to the
session record.
OTP-9847
Diffstat (limited to 'lib/inets/src/http_client/httpc_handler.erl')
-rw-r--r-- | lib/inets/src/http_client/httpc_handler.erl | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/lib/inets/src/http_client/httpc_handler.erl b/lib/inets/src/http_client/httpc_handler.erl index 587e24cc8d..8874304bd6 100644 --- a/lib/inets/src/http_client/httpc_handler.erl +++ b/lib/inets/src/http_client/httpc_handler.erl @@ -1403,7 +1403,9 @@ try_to_enable_pipeline_or_keep_alive( end. answer_request(#request{id = RequestId, from = From} = Request, Msg, - #state{timers = Timers, profile_name = ProfileName} = State) -> + #state{session = Session, + timers = Timers, + profile_name = ProfileName} = State) -> ?hcrt("answer request", [{request, Request}, {msg, Msg}]), httpc_response:send(From, Msg), RequestTimers = Timers#timers.request_timers, @@ -1412,12 +1414,22 @@ answer_request(#request{id = RequestId, from = From} = Request, Msg, Timer = {RequestId, TimerRef}, cancel_timer(TimerRef, {timeout, Request#request.id}), httpc_manager:request_done(RequestId, ProfileName), - + NewSession = maybe_make_session_available(ProfileName, Session), + Timers2 = Timers#timers{request_timers = lists:delete(Timer, + RequestTimers)}, State#state{request = Request#request{from = answer_sent}, - timers = - Timers#timers{request_timers = - lists:delete(Timer, RequestTimers)}}. - + session = NewSession, + timers = Timers2}. + +maybe_make_session_available(ProfileName, + #session{id = SessionId, + available = false} = Session) -> + httpc_manager:update_session(ProfileName, SessionId, + #session.available, true), + Session#session{available = true}; +maybe_make_session_available(_ProfileName, Session) -> + Session. + cancel_timers(#timers{request_timers = ReqTmrs, queue_timer = QTmr}) -> cancel_timer(QTmr, timeout_queue), CancelTimer = fun({_, Timer}) -> cancel_timer(Timer, timeout) end, |