Просмотр исходного кода

Merge pull request #419 from emqtt/0.15

0.14.1 - bugfix, spec fix
Feng Lee 10 лет назад
Родитель
Сommit
d9846eefd9

+ 8 - 0
CHANGELOG.md

@@ -2,6 +2,14 @@
 emqttd ChangeLog
 ==================
 
+0.14.1-beta(2015-12-28)
+-------------------------
+
+Bugfix: emqttd_ws_client.erl: Unexpected Info: {'EXIT',<0.27792.18>,{shutdown,destroy}} (#413)
+
+Improve: fix spec errors found by dialyzer
+
+
 0.14.0-beta(2015-12-18)
 -------------------------
 

+ 2 - 2
include/emqttd.hrl

@@ -130,8 +130,8 @@
 -record(mqtt_alarm, {
     id          :: binary(),
     severity    :: warning | error | critical,
-    title       :: binary(),
-    summary     :: binary(),
+    title       :: iolist() | binary(),
+    summary     :: iolist() | binary(),
     timestamp   :: erlang:timestamp() %% Timestamp
 }).
 

+ 1 - 1
src/emqttd.app.src

@@ -1,7 +1,7 @@
 {application, emqttd,
  [
   {id, "emqttd"},
-  {vsn, "0.14.0"},
+  {vsn, "0.14.1"},
   {description, "Erlang MQTT Broker"},
   {modules, []},
   {registered, []},

+ 1 - 1
src/emqttd_access_control.erl

@@ -119,7 +119,7 @@ reload_acl() ->
 register_mod(Type, Mod, Opts) when Type =:= auth; Type =:= acl->
     register_mod(Type, Mod, Opts, 0).
 
--spec register_mod(auth | acl, atom(), list(), pos_integer()) -> ok | {error, any()}.
+-spec register_mod(auth | acl, atom(), list(), non_neg_integer()) -> ok | {error, any()}.
 register_mod(Type, Mod, Opts, Seq) when Type =:= auth; Type =:= acl->
     gen_server:call(?SERVER, {register_mod, Type, Mod, Opts, Seq}).
 

+ 7 - 4
src/emqttd_ctl.erl

@@ -58,17 +58,20 @@ start_link() ->
 %% @doc Register a command
 %% @end
 %%------------------------------------------------------------------------------
--spec register_cmd(atom(), {module(), atom()}, list()) -> true.
+-spec register_cmd(atom(), {module(), atom()}, list()) -> ok.
 register_cmd(Cmd, MF, Opts) ->
-    gen_server:cast(?SERVER, {register_cmd, Cmd, MF, Opts}).
+    cast({register_cmd, Cmd, MF, Opts}).
 
 %%------------------------------------------------------------------------------
 %% @doc Unregister a command
 %% @end
 %%------------------------------------------------------------------------------
--spec unregister_cmd(atom()) -> true.
+-spec unregister_cmd(atom()) -> ok.
 unregister_cmd(Cmd) ->
-    gen_server:cast(?SERVER, {unregister_cmd, Cmd}).
+    cast({unregister_cmd, Cmd}).
+
+cast(Msg) ->
+    gen_server:cast(?SERVER, Msg).
 
 %%------------------------------------------------------------------------------
 %% @doc Run a command

+ 6 - 6
src/emqttd_metrics.erl

@@ -226,12 +226,12 @@ inc(Metric) ->
 %% @doc Increase metric value
 %% @end
 %%------------------------------------------------------------------------------
--spec inc(counter | gauge, atom()) -> non_neg_integer().
-inc(gauge, Metric) ->
-    inc(gauge, Metric, 1);
-inc(counter, Metric) ->
-    inc(counter, Metric, 1);
-inc(Metric, Val) when is_atom(Metric) and is_integer(Val) ->
+-spec inc({counter | gauge, atom()} | atom(), pos_integer()) -> non_neg_integer().
+inc({gauge, Metric}, Val) ->
+    inc(gauge, Metric, Val);
+inc({counter, Metric}, Val) ->
+    inc(counter, Metric, Val);
+inc(Metric, Val) when is_atom(Metric) ->
     inc(counter, Metric, Val).
 
 %%------------------------------------------------------------------------------

+ 1 - 1
src/emqttd_pubsub.erl

@@ -142,7 +142,7 @@ name(Id) ->
 %% @doc Create Topic or Subscription.
 %% @end
 %%------------------------------------------------------------------------------
--spec create(topic | subscription, binary()) -> ok | {error, any()}.
+-spec create(topic | subscription, binary() | {binary(), binary(), mqtt_qos()}) -> ok | {error, any()}.
 create(topic, Topic) when is_binary(Topic) ->
     Record = #mqtt_topic{topic = Topic, node = node()},
     case mnesia:transaction(fun add_topic/1, [Record]) of

+ 1 - 1
src/emqttd_session.erl

@@ -191,7 +191,7 @@ subscribe(SessPid, PacketId, TopicTable) ->
 %% @doc Publish message
 %% @end
 %%------------------------------------------------------------------------------
--spec publish(pid(), mqtt_message()) -> ok.
+-spec publish(pid(), mqtt_message()) -> ok | {error, any()}.
 publish(_SessPid, Msg = #mqtt_message{qos = ?QOS_0}) ->
     %% publish qos0 directly
     emqttd_pubsub:publish(Msg);