Skip to content

Commit

Permalink
chore: set_lable for debugging and log pool/id for zombie ehttpc
Browse files Browse the repository at this point in the history
  • Loading branch information
zhongwencool committed Feb 7, 2025
1 parent eafe388 commit ffb0759
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/ehttpc.app.src
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{application, ehttpc, [
{description, "HTTP Client for Erlang/OTP"},
{vsn, "0.7.0"},
{vsn, "0.7.1"},
{registered, []},
{applications, [
kernel,
Expand Down
11 changes: 10 additions & 1 deletion src/ehttpc.erl
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,13 @@ init([Pool, Id, Opts0]) ->
max_inactive = MaxInactive
},
true = gproc_pool:connect_worker(ehttpc:name(Pool), {Pool, Id}),

case erlang:function_exported(proc_lib, set_label, 1) of
true ->
proc_lib:set_label({ehttpc, Pool, Id});
false ->
ignore
end,
{ok, start_check_inactive_timer(State)}.

handle_call({health_check, _}, _From, State = #state{gun_state = up}) ->
Expand Down Expand Up @@ -736,7 +743,9 @@ maybe_shoot(
]),
inactive_duration_threshold => MaxInactive,
inflight_requests => SentCount,
connection_pid => Client
connection_pid => Client,
pool => State#state.pool,
id => State#state.id
},
State
),
Expand Down
2 changes: 1 addition & 1 deletion src/ehttpc_worker_sup.erl
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ start_link(Pool, Opts) ->
init([Pool, Opts]) ->
WorkerSpec = fun(Id) ->
#{
id => {worker, Id},
id => {Pool, Id},
start => {ehttpc, start_link, [Pool, Id, Opts]},
restart => transient,
shutdown => 5000,
Expand Down

0 comments on commit ffb0759

Please sign in to comment.