diff --git a/CHANGELOG.md b/CHANGELOG.md index 5de7d67ff..f2cc31ca6 100644 --- a/CHANGELOG.md +++ b/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) ------------------------- diff --git a/include/emqttd.hrl b/include/emqttd.hrl index c22cffa40..2f7b9b5c4 100644 --- a/include/emqttd.hrl +++ b/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 }). diff --git a/src/emqttd.app.src b/src/emqttd.app.src index 95b8148f1..1dd30ac7b 100644 --- a/src/emqttd.app.src +++ b/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, []}, diff --git a/src/emqttd_access_control.erl b/src/emqttd_access_control.erl index 43e0600a4..5dcc78e27 100644 --- a/src/emqttd_access_control.erl +++ b/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}). diff --git a/src/emqttd_ctl.erl b/src/emqttd_ctl.erl index 4aa29750e..41ef77eec 100644 --- a/src/emqttd_ctl.erl +++ b/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 diff --git a/src/emqttd_metrics.erl b/src/emqttd_metrics.erl index d75985ef3..37b034355 100644 --- a/src/emqttd_metrics.erl +++ b/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). %%------------------------------------------------------------------------------ diff --git a/src/emqttd_pubsub.erl b/src/emqttd_pubsub.erl index 0a5335fb0..1d528402f 100644 --- a/src/emqttd_pubsub.erl +++ b/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 diff --git a/src/emqttd_session.erl b/src/emqttd_session.erl index dde925ab0..af7fec0ca 100644 --- a/src/emqttd_session.erl +++ b/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);