remove a transaction
This commit is contained in:
parent
9584f2a990
commit
e08dbf82f6
|
@ -212,8 +212,7 @@ code_change(_OldVsn, State, _Extra) ->
|
||||||
add_subscriber_(Topic, SubPid) ->
|
add_subscriber_(Topic, SubPid) ->
|
||||||
case ets:member(subscriber, Topic) of
|
case ets:member(subscriber, Topic) of
|
||||||
false ->
|
false ->
|
||||||
mnesia:transaction(fun add_topic_/1, [Topic]),
|
mnesia:transaction(fun add_topic_route_/2, [Topic, node()]),
|
||||||
emqttd_router:add_route(Topic, node()),
|
|
||||||
setstats(topic);
|
setstats(topic);
|
||||||
true ->
|
true ->
|
||||||
ok
|
ok
|
||||||
|
@ -224,13 +223,15 @@ del_subscriber_(Topic, SubPid) ->
|
||||||
ets:delete_object(subscriber, {Topic, SubPid}),
|
ets:delete_object(subscriber, {Topic, SubPid}),
|
||||||
case ets:lookup(subscriber, Topic) of
|
case ets:lookup(subscriber, Topic) of
|
||||||
[] ->
|
[] ->
|
||||||
emqttd_router:del_route(Topic, node()),
|
mnesia:transaction(fun del_topic_route_/2, [Topic, node()]),
|
||||||
mnesia:transaction(fun del_topic_/1, [Topic]),
|
|
||||||
setstats(topic);
|
setstats(topic);
|
||||||
[_|_] ->
|
[_|_] ->
|
||||||
ok
|
ok
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
add_topic_route_(Topic, Node) ->
|
||||||
|
add_topic_(Topic), emqttd_router:add_route(Topic, Node).
|
||||||
|
|
||||||
add_topic_(Topic) ->
|
add_topic_(Topic) ->
|
||||||
add_topic_(Topic, []).
|
add_topic_(Topic, []).
|
||||||
|
|
||||||
|
@ -241,6 +242,9 @@ add_topic_(Topic, Flags) ->
|
||||||
[_] -> ok
|
[_] -> ok
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
del_topic_route_(Topic, Node) ->
|
||||||
|
emqttd_router:del_route(Topic, Node), del_topic_(Topic).
|
||||||
|
|
||||||
del_topic_(Topic) ->
|
del_topic_(Topic) ->
|
||||||
case emqttd_router:has_route(Topic) of
|
case emqttd_router:has_route(Topic) of
|
||||||
true -> ok;
|
true -> ok;
|
||||||
|
|
Loading…
Reference in New Issue