From 6d4351e8a936a43bb9da8970ca0986b25d7817d5 Mon Sep 17 00:00:00 2001 From: Feng Lee Date: Tue, 18 Aug 2015 18:59:14 +0800 Subject: [PATCH] priority --- src/emqttd_pubsub.erl | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/emqttd_pubsub.erl b/src/emqttd_pubsub.erl index 4c89cd63a..74da5026f 100644 --- a/src/emqttd_pubsub.erl +++ b/src/emqttd_pubsub.erl @@ -235,14 +235,23 @@ init([Id, _Opts]) -> gproc_pool:connect_worker(pubsub, {?MODULE, Id}), {ok, #state{id = Id, submap = maps:new()}}. -prioritise_call(_Msg, _From, _Len, _State) -> - 1. +prioritise_call(Msg, _From, _Len, _State) -> + case Msg of + {subscriber, _, _} -> 1; + _ -> 0 + end. -prioritise_cast(_Msg, _Len, _State) -> - 0. +prioritise_cast(Msg, _Len, _State) -> + case Msg of + {unsubscribe, _, _} -> 2; + _ -> 0 + end. -prioritise_info(_Msg, _Len, _State) -> - 1. +prioritise_info(Msg, _Len, _State) -> + case Msg of + {'DOWN', _, _, _, _} -> 3; + _ -> 0 + end. handle_call({subscribe, SubPid, Topics}, _From, State) -> TopicSubs = lists:map(fun({<<"$Q/", _/binary>> = Queue, Qos}) ->