Sfoglia il codice sorgente

fix issue #238 - emqttd_broker:unhook/2 cannot work

Feng Lee 10 anni fa
parent
commit
c4a09f97d5
1 ha cambiato i file con 5 aggiunte e 4 eliminazioni
  1. 5 4
      src/emqttd_broker.erl

+ 5 - 4
src/emqttd_broker.erl

@@ -246,8 +246,8 @@ handle_call({hook, Hook, Name, MFArgs}, _From, State) ->
     end,
     end,
     {reply, Reply, State};
     {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
     case ets:lookup(?BROKER_TAB, Key) of
         [{Key, Hooks}] -> 
         [{Key, Hooks}] -> 
             ets:insert(?BROKER_TAB, {Key, lists:keydelete(Name, 1, Hooks)}); 
             ets:insert(?BROKER_TAB, {Key, lists:keydelete(Name, 1, Hooks)}); 
@@ -256,8 +256,9 @@ handle_call({unhook, Name}, _From, State) ->
     end,
     end,
     {reply, Reply, State};
     {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) ->
 handle_cast(_Msg, State) ->
     {noreply, State}.
     {noreply, State}.