소스 검색

Introduce an option to not trap process exits in worker processes (#171)

When worker processes are part of an external connection pool it may make sense
to rely on automatic cleanup based on links. Since by default worker processes
trap exits, linked proceses would fail to terminate the ibrowse worker and
instead it would generate an '{'EXIT', Pid, Reason}' which is handled in
handle_info/2 with a warning to stdout.

Add a new option to allow users to control worker process link behavior via an
ibrowse config parameter. The default stays the same (=true).
pull/172/head
Nick Vatamaniuc 4 년 전
committed by GitHub
부모
커밋
232f83c7af
No known key found for this signature in database GPG 키 ID: 4AEE18F83AFDEB23
1개의 변경된 파일9개의 추가작업 그리고 3개의 파일을 삭제
  1. +9
    -3
      src/ibrowse_http_client.erl

+ 9
- 3
src/ibrowse_http_client.erl 파일 보기

@ -133,7 +133,7 @@ send_req(Conn_Pid, Url, Headers, Method, Body, Options, Timeout) ->
%% {stop, Reason}
%%--------------------------------------------------------------------
init({Lb_Tid, #url{host = Host, port = Port}, {SSLOptions, Is_ssl}}) ->
process_flag(trap_exit, true),
maybe_trap_exits(),
State = #state{host = Host,
port = Port,
ssl_options = SSLOptions,
@ -143,7 +143,7 @@ init({Lb_Tid, #url{host = Host, port = Port}, {SSLOptions, Is_ssl}}) ->
put(my_trace_flag, ibrowse_lib:get_trace_status(Host, Port)),
{ok, set_inac_timer(State)};
init(Url) when is_list(Url) ->
process_flag(trap_exit, true),
maybe_trap_exits(),
case catch ibrowse_lib:parse_url(Url) of
#url{protocol = Protocol} = Url_rec ->
init({undefined, Url_rec, {[], Protocol == https}});
@ -151,7 +151,7 @@ init(Url) when is_list(Url) ->
{error, invalid_url}
end;
init({Host, Port}) ->
process_flag(trap_exit, true),
maybe_trap_exits(),
State = #state{host = Host,
port = Port},
put(ibrowse_trace_token, [Host, $:, integer_to_list(Port)]),
@ -2187,3 +2187,9 @@ get_header_value(Name, Headers, Default_val) ->
delayed_stop_timer() ->
erlang:send_after(500, self(), delayed_stop).
maybe_trap_exits() ->
case ibrowse:get_config_value(worker_trap_exits, true) of
true -> process_flag(trap_exit, true);
false -> ok
end.

불러오는 중...
취소
저장