fix(emqx_sn_gateway): Dialyzer warnings
This commit is contained in:
parent
eecd2b5f35
commit
baaa4e847d
|
@ -74,7 +74,7 @@
|
||||||
sockstate :: emqx_types:sockstate(),
|
sockstate :: emqx_types:sockstate(),
|
||||||
sockname :: {inet:ip_address(), inet:port()},
|
sockname :: {inet:ip_address(), inet:port()},
|
||||||
peername :: {inet:ip_address(), inet:port()},
|
peername :: {inet:ip_address(), inet:port()},
|
||||||
channel :: emqx_channel:channel(),
|
channel :: maybe(emqx_channel:channel()),
|
||||||
registry :: emqx_sn_registry:registry(),
|
registry :: emqx_sn_registry:registry(),
|
||||||
clientid :: maybe(binary()),
|
clientid :: maybe(binary()),
|
||||||
username :: maybe(binary()),
|
username :: maybe(binary()),
|
||||||
|
@ -105,6 +105,8 @@
|
||||||
|
|
||||||
-define(NO_PEERCERT, undefined).
|
-define(NO_PEERCERT, undefined).
|
||||||
|
|
||||||
|
%% TODO: fix when https://github.com/emqx/emqx-sn/pull/170 is merged
|
||||||
|
-dialyzer([{nowarn_function, [idle/3]}]).
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% Exported APIs
|
%% Exported APIs
|
||||||
|
@ -136,7 +138,8 @@ init([{_, SockPid, Sock}, Peername, Options]) ->
|
||||||
EnableStats = proplists:get_value(enable_stats, Options, false),
|
EnableStats = proplists:get_value(enable_stats, Options, false),
|
||||||
case inet:sockname(Sock) of
|
case inet:sockname(Sock) of
|
||||||
{ok, Sockname} ->
|
{ok, Sockname} ->
|
||||||
Channel = emqx_channel:init(#{sockname => Sockname,
|
Channel = emqx_channel:init(#{socktype => udp,
|
||||||
|
sockname => Sockname,
|
||||||
peername => Peername,
|
peername => Peername,
|
||||||
protocol => 'mqtt-sn',
|
protocol => 'mqtt-sn',
|
||||||
peercert => ?NO_PEERCERT,
|
peercert => ?NO_PEERCERT,
|
||||||
|
@ -197,12 +200,16 @@ idle(cast, {incoming, ?SN_PUBLISH_MSG(#mqtt_sn_flags{qos = ?QOS_NEG1,
|
||||||
}, TopicId, _MsgId, Data)},
|
}, TopicId, _MsgId, Data)},
|
||||||
State = #state{clientid = ClientId, registry = Registry}) ->
|
State = #state{clientid = ClientId, registry = Registry}) ->
|
||||||
TopicName = case (TopicIdType =:= ?SN_SHORT_TOPIC) of
|
TopicName = case (TopicIdType =:= ?SN_SHORT_TOPIC) of
|
||||||
false ->
|
false -> emqx_sn_registry:lookup_topic(Registry, ClientId, TopicId);
|
||||||
emqx_sn_registry:lookup_topic(Registry, ClientId, TopicId);
|
|
||||||
true -> <<TopicId:16>>
|
true -> <<TopicId:16>>
|
||||||
end,
|
end,
|
||||||
|
case TopicName =/= undefined of
|
||||||
|
true ->
|
||||||
Msg = emqx_message:make(?NEG_QOS_CLIENT_ID, ?QOS_0, TopicName, Data),
|
Msg = emqx_message:make(?NEG_QOS_CLIENT_ID, ?QOS_0, TopicName, Data),
|
||||||
(TopicName =/= undefined) andalso emqx_broker:publish(Msg),
|
emqx_broker:publish(Msg);
|
||||||
|
false ->
|
||||||
|
ok
|
||||||
|
end;
|
||||||
?LOG(debug, "Client id=~p receives a publish with QoS=-1 in idle mode!", [ClientId], State),
|
?LOG(debug, "Client id=~p receives a publish with QoS=-1 in idle mode!", [ClientId], State),
|
||||||
{keep_state_and_data, State#state.idle_timeout};
|
{keep_state_and_data, State#state.idle_timeout};
|
||||||
|
|
||||||
|
@ -562,10 +569,9 @@ terminate(Reason, _StateName, #state{clientid = ClientId,
|
||||||
channel = Channel,
|
channel = Channel,
|
||||||
registry = Registry}) ->
|
registry = Registry}) ->
|
||||||
emqx_sn_registry:unregister_topic(Registry, ClientId),
|
emqx_sn_registry:unregister_topic(Registry, ClientId),
|
||||||
case {Channel, Reason} of
|
case Channel =:= undefined of
|
||||||
{undefined, _} -> ok;
|
true -> ok;
|
||||||
{_, _} ->
|
false -> emqx_channel:terminate(Reason, Channel)
|
||||||
emqx_channel:terminate(Reason, Channel)
|
|
||||||
end.
|
end.
|
||||||
|
|
||||||
code_change(_Vsn, StateName, State, _Extra) ->
|
code_change(_Vsn, StateName, State, _Extra) ->
|
||||||
|
|
|
@ -148,7 +148,8 @@
|
||||||
-type(username() :: maybe(binary())).
|
-type(username() :: maybe(binary())).
|
||||||
-type(password() :: maybe(binary())).
|
-type(password() :: maybe(binary())).
|
||||||
-type(peerhost() :: inet:ip_address()).
|
-type(peerhost() :: inet:ip_address()).
|
||||||
-type(peername() :: {inet:ip_address(), inet:port_number()}).
|
-type(peername() :: {inet:ip_address(), inet:port_number()}
|
||||||
|
| inet:returned_non_ip_address()).
|
||||||
-type(protocol() :: mqtt | 'mqtt-sn' | coap | lwm2m | stomp | none | atom()).
|
-type(protocol() :: mqtt | 'mqtt-sn' | coap | lwm2m | stomp | none | atom()).
|
||||||
-type(auth_result() :: success
|
-type(auth_result() :: success
|
||||||
| client_identifier_not_valid
|
| client_identifier_not_valid
|
||||||
|
|
Loading…
Reference in New Issue