fix(sys_mon): guard before calling `erlang:port_info`
Sometimes, the `emqx_sys_mon:procinfo/1` might be called with something that is not a port, like `[]`. Not sure on the conditions for this to happen. ``` 2022-02-18T20:05:02.671592+00:00 [error] Generic server emqx_sys_mon terminating. Reason: {badarg,[{erlang,port_info,[[]],[{error_info,#{module => erl_erts_errors}}]},{emqx_sys_mon,portinfo,1,[{file,"/emqx/apps/emqx/src/emqx_sys_mon.erl"},{line,205}]},{emqx_sys_mon,'-handle_info/2-fun-5-',2,[{file,"/emqx/apps/emqx/src/emqx_sys_mon.erl"},{line,150}]},{emqx_sys_mon,suppress,3,[{file,"/emqx/apps/emqx/src/emqx_sys_mon.erl"},{line,184}]},{gen_server,try_dispatch,4,[{file,"gen_server.erl"},{line,695}]},{gen_server,handle_msg,6,[{file,"gen_server.erl"},{line,771}]},{proc_lib,wake_up,3,[{file,"proc_lib.erl"},{line,236}]}]}. Last message: {monitor,<0.7796.0>,busy_dist_port,[]}. State: #{events => [{busy_dist_port,#Port<0.127>}],timer => #Ref<0.2758388682.1853620226.133920>}. ```
This commit is contained in:
parent
f173a2f61f
commit
d89925ce7b
|
@ -202,7 +202,12 @@ get_proc_lib_initial_call(Pid) ->
|
||||||
end.
|
end.
|
||||||
|
|
||||||
portinfo(Port) ->
|
portinfo(Port) ->
|
||||||
[{port, Port} | erlang:port_info(Port)].
|
PortInfo =
|
||||||
|
case is_port(Port) andalso erlang:port_info(Port) of
|
||||||
|
L when is_list(L) -> L;
|
||||||
|
_ -> []
|
||||||
|
end,
|
||||||
|
[{port, Port} | PortInfo].
|
||||||
|
|
||||||
safe_publish(Event, WarnMsg) ->
|
safe_publish(Event, WarnMsg) ->
|
||||||
Topic = emqx_topic:systop(lists:concat(['sysmon/', Event])),
|
Topic = emqx_topic:systop(lists:concat(['sysmon/', Event])),
|
||||||
|
|
|
@ -35,6 +35,11 @@
|
||||||
{self(), busy_port,
|
{self(), busy_port,
|
||||||
fmt("busy_port warning: suspid = ~p, port = ~p",
|
fmt("busy_port warning: suspid = ~p, port = ~p",
|
||||||
[self(), ?FAKE_PORT]), ?FAKE_PORT},
|
[self(), ?FAKE_PORT]), ?FAKE_PORT},
|
||||||
|
%% for the case when the port is missing, for some
|
||||||
|
%% reason.
|
||||||
|
{self(), busy_port,
|
||||||
|
fmt("busy_port warning: suspid = ~p, port = ~p",
|
||||||
|
[self(), []]), []},
|
||||||
{self(), busy_dist_port,
|
{self(), busy_dist_port,
|
||||||
fmt("busy_dist_port warning: suspid = ~p, port = ~p",
|
fmt("busy_dist_port warning: suspid = ~p, port = ~p",
|
||||||
[self(), ?FAKE_PORT]), ?FAKE_PORT},
|
[self(), ?FAKE_PORT]), ?FAKE_PORT},
|
||||||
|
|
Loading…
Reference in New Issue