monitors
This commit is contained in:
parent
4fb018203e
commit
9effc2fad7
|
@ -48,9 +48,6 @@
|
||||||
|
|
||||||
-define(CM_POOL, ?MODULE).
|
-define(CM_POOL, ?MODULE).
|
||||||
|
|
||||||
-define(LOG(Level, Format, Args, Client),
|
|
||||||
lager:Level("CM(~s): " ++ Format, [Client#mqtt_client.client_id|Args])).
|
|
||||||
|
|
||||||
%%%=============================================================================
|
%%%=============================================================================
|
||||||
%%% API
|
%%% API
|
||||||
%%%=============================================================================
|
%%%=============================================================================
|
||||||
|
@ -127,7 +124,7 @@ prioritise_cast(Msg, _Len, _State) ->
|
||||||
end.
|
end.
|
||||||
|
|
||||||
prioritise_info(_Msg, _Len, _State) ->
|
prioritise_info(_Msg, _Len, _State) ->
|
||||||
1.
|
3.
|
||||||
|
|
||||||
handle_call(Req, _From, State) ->
|
handle_call(Req, _From, State) ->
|
||||||
lager:error("Unexpected request: ~p", [Req]),
|
lager:error("Unexpected request: ~p", [Req]),
|
||||||
|
@ -138,7 +135,7 @@ handle_cast({register, Client = #mqtt_client{client_id = ClientId,
|
||||||
case lookup_proc(ClientId) of
|
case lookup_proc(ClientId) of
|
||||||
Pid ->
|
Pid ->
|
||||||
{noreply, State};
|
{noreply, State};
|
||||||
_None ->
|
_ ->
|
||||||
ets:insert(mqtt_client, Client),
|
ets:insert(mqtt_client, Client),
|
||||||
{noreply, setstats(monitor_client(ClientId, Pid, State))}
|
{noreply, setstats(monitor_client(ClientId, Pid, State))}
|
||||||
end;
|
end;
|
||||||
|
@ -148,7 +145,7 @@ handle_cast({unregister, ClientId, Pid}, State) ->
|
||||||
Pid ->
|
Pid ->
|
||||||
ets:delete(mqtt_client, ClientId),
|
ets:delete(mqtt_client, ClientId),
|
||||||
{noreply, setstats(State)};
|
{noreply, setstats(State)};
|
||||||
undefined ->
|
_ ->
|
||||||
{noreply, State}
|
{noreply, State}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -156,8 +153,8 @@ handle_cast(Msg, State) ->
|
||||||
lager:error("Unexpected Msg: ~p", [Msg]),
|
lager:error("Unexpected Msg: ~p", [Msg]),
|
||||||
{noreply, State}.
|
{noreply, State}.
|
||||||
|
|
||||||
handle_info({'DOWN', MRef, process, DownPid, _Reason}, State = #state{monitors = MonDict}) ->
|
handle_info({'DOWN', MRef, process, DownPid, _Reason}, State) ->
|
||||||
case dict:find(MRef, MonDict) of
|
case dict:find(MRef, State#state.monitors) of
|
||||||
{ok, {ClientId, DownPid}} ->
|
{ok, {ClientId, DownPid}} ->
|
||||||
case lookup_proc(ClientId) of
|
case lookup_proc(ClientId) of
|
||||||
DownPid ->
|
DownPid ->
|
||||||
|
|
Loading…
Reference in New Issue