refactor(emqx_gateway_cm): no need to keep locker pid in state
For two reasons 1. Every other places computes the process register name from gwname 2. The ekka_locker api spec only accepts atom but not pid
This commit is contained in:
parent
c44d4e7bd4
commit
6affda8194
|
@ -96,8 +96,6 @@
|
|||
-record(state, {
|
||||
%% Gateway Name
|
||||
gwname :: gateway_name(),
|
||||
%% ClientId Locker for CM
|
||||
locker :: pid(),
|
||||
%% ClientId Registry server
|
||||
registry :: pid(),
|
||||
chan_pmon :: emqx_pmon:pmon()
|
||||
|
@ -776,7 +774,8 @@ init(Options) ->
|
|||
{ok, Registry} = emqx_gateway_cm_registry:start_link(GwName),
|
||||
|
||||
%% Start locker process
|
||||
{ok, Locker} = ekka_locker:start_link(lockername(GwName)),
|
||||
LockerName = lockername(GwName),
|
||||
{ok, _LockerPid} = ekka_locker:start_link(lockername(GwName)),
|
||||
|
||||
%% Interval update stats
|
||||
%% TODO: v0.2
|
||||
|
@ -784,7 +783,6 @@ init(Options) ->
|
|||
|
||||
{ok, #state{
|
||||
gwname = GwName,
|
||||
locker = Locker,
|
||||
registry = Registry,
|
||||
chan_pmon = emqx_pmon:new()
|
||||
}}.
|
||||
|
@ -812,9 +810,9 @@ handle_info(
|
|||
handle_info(_Info, State) ->
|
||||
{noreply, State}.
|
||||
|
||||
terminate(_Reason, #state{registry = Registry, locker = Locker}) ->
|
||||
terminate(_Reason, #state{registry = Registry, gwname = GwName}) ->
|
||||
_ = gen_server:stop(Registry),
|
||||
_ = ekka_locker:stop(Locker),
|
||||
_ = ekka_locker:stop(lockername(GwName)),
|
||||
ok.
|
||||
|
||||
code_change(_OldVsn, State, _Extra) ->
|
||||
|
|
Loading…
Reference in New Issue