Selaa lähdekoodia

Merged upstream changes

pull/110/head v4.1.0
Chandrashekhar Mullaparthi 11 vuotta sitten
vanhempi
commit
7871e2ebe8
1 muutettua tiedostoa jossa 29 lisäystä ja 34 poistoa
  1. +29
    -34
      src/ibrowse_http_client.erl

+ 29
- 34
src/ibrowse_http_client.erl Näytä tiedosto

@ -194,7 +194,7 @@ handle_info({ssl, _Sock, Data}, State) ->
handle_info({stream_next, Req_id}, #state{socket = Socket, handle_info({stream_next, Req_id}, #state{socket = Socket,
cur_req = #request{req_id = Req_id}} = State) -> cur_req = #request{req_id = Req_id}} = State) ->
ok = do_setopts(Socket, [{active, once}], State),
_ = do_setopts(Socket, [{active, once}], State),
{noreply, set_inac_timer(State)}; {noreply, set_inac_timer(State)};
handle_info({stream_next, _Req_id}, State) -> handle_info({stream_next, _Req_id}, State) ->
@ -296,12 +296,12 @@ handle_sock_data(Data, #state{status = get_header}=State) ->
shutting_down(State), shutting_down(State),
{stop, normal, State}; {stop, normal, State};
#state{socket = Socket, status = Status, cur_req = CurReq} = State_1 -> #state{socket = Socket, status = Status, cur_req = CurReq} = State_1 ->
case {Status, CurReq} of
{get_header, #request{caller_controls_socket = true}} ->
ok = do_setopts(Socket, [{active, once}], State_1);
_ ->
active_once(State_1)
end,
_ = case {Status, CurReq} of
{get_header, #request{caller_controls_socket = true}} ->
do_setopts(Socket, [{active, once}], State_1);
_ ->
active_once(State_1)
end,
{noreply, set_inac_timer(State_1)} {noreply, set_inac_timer(State_1)}
end; end;
@ -320,7 +320,7 @@ handle_sock_data(Data, #state{status = get_body,
{error, {Reason, {stat_code, StatCode}, Headers}}), {error, {Reason, {stat_code, StatCode}, Headers}}),
{stop, normal, State}; {stop, normal, State};
State_1 -> State_1 ->
active_once(State_1),
_ = active_once(State_1),
State_2 = set_inac_timer(State_1), State_2 = set_inac_timer(State_1),
{noreply, State_2} {noreply, State_2}
end; end;
@ -333,14 +333,14 @@ handle_sock_data(Data, #state{status = get_body,
{stop, normal, State}; {stop, normal, State};
#state{cur_req = #request{caller_controls_socket = Ccs}, #state{cur_req = #request{caller_controls_socket = Ccs},
interim_reply_sent = Irs} = State_1 -> interim_reply_sent = Irs} = State_1 ->
case Irs of
true ->
active_once(State_1);
false when Ccs == true ->
ok = do_setopts(Socket, [{active, once}], State);
false ->
active_once(State_1)
end,
_ = case Irs of
true ->
active_once(State_1);
false when Ccs == true ->
do_setopts(Socket, [{active, once}], State);
false ->
active_once(State_1)
end,
State_2 = State_1#state{interim_reply_sent = false}, State_2 = State_1#state{interim_reply_sent = false},
case Ccs of case Ccs of
true -> true ->
@ -350,7 +350,7 @@ handle_sock_data(Data, #state{status = get_body,
{noreply, set_inac_timer(State_2)} {noreply, set_inac_timer(State_2)}
end; end;
State_1 -> State_1 ->
active_once(State_1),
_ = active_once(State_1),
State_2 = set_inac_timer(State_1), State_2 = set_inac_timer(State_1),
{noreply, State_2} {noreply, State_2}
end end
@ -646,7 +646,7 @@ do_close(#state{socket = Sock, is_ssl = false}) -> catch gen_tcp:close(Sock).
active_once(#state{cur_req = #request{caller_controls_socket = true}}) -> active_once(#state{cur_req = #request{caller_controls_socket = true}}) ->
ok; ok;
active_once(#state{socket = Socket} = State) -> active_once(#state{socket = Socket} = State) ->
ok = do_setopts(Socket, [{active, once}], State).
_ = do_setopts(Socket, [{active, once}], State).
do_setopts(_Sock, [], _) -> ok; do_setopts(_Sock, [], _) -> ok;
do_setopts(Sock, Opts, #state{is_ssl = true, do_setopts(Sock, Opts, #state{is_ssl = true,
@ -737,7 +737,7 @@ send_req_1(From,
case do_send_body(Body_1, State_1, TE) of case do_send_body(Body_1, State_1, TE) of
{ok, _Sent_body} -> {ok, _Sent_body} ->
trace_request_body(Body_1), trace_request_body(Body_1),
ok = active_once(State_1),
_ = active_once(State_1),
State_1_1 = inc_pipeline_counter(State_1), State_1_1 = inc_pipeline_counter(State_1),
State_2 = State_1_1#state{status = get_header, State_2 = State_1_1#state{status = get_header,
cur_req = NewReq, cur_req = NewReq,
@ -830,7 +830,7 @@ send_req_1(From,
NewReq_1 = NewReq#request{raw_req = Raw_req}, NewReq_1 = NewReq#request{raw_req = Raw_req},
State_1 = State#state{reqs=queue:in(NewReq_1, State#state.reqs)}, State_1 = State#state{reqs=queue:in(NewReq_1, State#state.reqs)},
State_2 = inc_pipeline_counter(State_1), State_2 = inc_pipeline_counter(State_1),
active_once(State_2),
_ = active_once(State_2),
State_3 = case Status of State_3 = case Status of
idle -> idle ->
State_2#state{ State_2#state{
@ -1486,12 +1486,8 @@ set_cur_request(#state{reqs = Reqs, socket = Socket} = State) ->
empty -> empty ->
State#state{cur_req = undefined}; State#state{cur_req = undefined};
{value, #request{caller_controls_socket = Ccs} = NextReq} -> {value, #request{caller_controls_socket = Ccs} = NextReq} ->
case Ccs of
true ->
ok = do_setopts(Socket, [{active, once}], State);
_ ->
ok
end,
_ = Ccs =:= true
andalso do_setopts(Socket, [{active, once}], State),
State#state{cur_req = NextReq} State#state{cur_req = NextReq}
end. end.
@ -1943,14 +1939,13 @@ dec_pipeline_counter(#state{lb_ets_tid = undefined} = State) ->
State; State;
dec_pipeline_counter(#state{cur_pipeline_size = Pipe_sz, dec_pipeline_counter(#state{cur_pipeline_size = Pipe_sz,
lb_ets_tid = Tid} = State) -> lb_ets_tid = Tid} = State) ->
try
update_counter(Tid, self(), {2,-1,0,0}),
update_counter(Tid, self(), {3,-1,0,0}),
ok
catch
_:_ ->
ok
end,
_ = try
update_counter(Tid, self(), {2,-1,0,0}),
update_counter(Tid, self(), {3,-1,0,0})
catch
_:_ ->
ok
end,
State#state{cur_pipeline_size = Pipe_sz - 1}. State#state{cur_pipeline_size = Pipe_sz - 1}.
flatten([H | _] = L) when is_integer(H) -> flatten([H | _] = L) when is_integer(H) ->

Ladataan…
Peruuta
Tallenna