Browse Source

Merge pull request #239 from emqtt/dev

emqttd_broker:unhook/2 cannot work #238
Feng Lee 10 years ago
parent
commit
6df8acde26
2 changed files with 6 additions and 4 deletions
  1. 5 4
      src/emqttd_broker.erl
  2. 1 0
      src/emqttd_protocol.erl

+ 5 - 4
src/emqttd_broker.erl

@@ -246,8 +246,8 @@ handle_call({hook, Hook, Name, MFArgs}, _From, State) ->
     end,
     {reply, Reply, State};
 
-handle_call({unhook, Name}, _From, State) ->
-    Key = {hook, Name}, Reply =
+handle_call({unhook, Hook, Name}, _From, State) ->
+    Key = {hook, Hook}, Reply =
     case ets:lookup(?BROKER_TAB, Key) of
         [{Key, Hooks}] -> 
             ets:insert(?BROKER_TAB, {Key, lists:keydelete(Name, 1, Hooks)}); 
@@ -256,8 +256,9 @@ handle_call({unhook, Name}, _From, State) ->
     end,
     {reply, Reply, State};
 
-handle_call(_Request, _From, State) ->
-    {reply, {error, unsupport_request}, State}.
+handle_call(Req, _From, State) ->
+    lager:critical("Unexpected request: ~p", [Req]),
+    {reply, {error, badreq}, State}.
 
 handle_cast(_Msg, State) ->
     {noreply, State}.

+ 1 - 0
src/emqttd_protocol.erl

@@ -308,6 +308,7 @@ shutdown(Error, #proto_state{client_id = undefined}) ->
     lager:info("Protocol shutdown ~p", [Error]),
     ignore;
 
+%% TODO: ClientId??
 shutdown(Error, #proto_state{peername = Peername, client_id = ClientId, will_msg = WillMsg}) ->
 	lager:info([{client, ClientId}], "Client ~s@~s: shutdown ~p",
                    [ClientId, emqttd_net:format(Peername), Error]),