]> granicus.if.org Git - ejabberd/commitdiff
Avoid using broad p1_queue:queue() type wherever possible
authorEvgeny Khramtsov <ekhramtsov@process-one.net>
Fri, 28 Jun 2019 19:16:29 +0000 (22:16 +0300)
committerEvgeny Khramtsov <ekhramtsov@process-one.net>
Fri, 28 Jun 2019 19:16:29 +0000 (22:16 +0300)
include/mod_muc_room.hrl
rebar.config
src/ejabberd_redis.erl
src/mod_mqtt_session.erl
src/mod_muc_room.erl
src/mod_stream_mgmt.erl

index 46eb149bb25cb027ac7b3a5669d1ecab27d0c61f..2f09e5a5c8baeabbf5bbaa381a4c99c7003be639 100644 (file)
@@ -24,7 +24,7 @@
 
 -record(lqueue,
 {
-    queue = p1_queue:new()  :: p1_queue:queue(),
+    queue = p1_queue:new()  :: p1_queue:queue(lqueue_elem()),
     max   = 0               :: integer()
 }).
 
     just_created            = erlang:system_time(microsecond) :: true | integer(),
     activity                = treap:empty() :: treap:treap(),
     room_shaper             = none :: ejabberd_shaper:shaper(),
-    room_queue              :: p1_queue:queue() | undefined
+    room_queue              :: p1_queue:queue({message | presence, jid()}) | undefined
 }).
 
 -type users() :: #{ljid() => #user{}}.
index f81e0821c40056e0933fc9e12b7d113cc01e352e..9809c28b64cd98bc22e0e732605afae8439ad526 100644 (file)
@@ -19,7 +19,7 @@
 %%%----------------------------------------------------------------------
 
 {deps, [{lager, ".*", {git, "https://github.com/erlang-lager/lager", "3.6.10"}},
-        {p1_utils, ".*", {git, "https://github.com/processone/p1_utils", {tag, "1.0.15"}}},
+        {p1_utils, ".*", {git, "https://github.com/processone/p1_utils", "2887223"}},
         {cache_tab, ".*", {git, "https://github.com/processone/cache_tab", {tag, "1.0.19"}}},
         {fast_tls, ".*", {git, "https://github.com/processone/fast_tls", {tag, "1.1.1"}}},
         {stringprep, ".*", {git, "https://github.com/processone/stringprep", {tag, "1.0.16"}}},
index 18a73414b82577c7d0cf083290605173cbbfaf3d..a9ceb18330ba2d2949564f4f50c61f7b822f4ea7 100644 (file)
@@ -55,8 +55,9 @@
 -record(state, {connection :: pid() | undefined,
                num :: pos_integer(),
                subscriptions = #{} :: subscriptions(),
-               pending_q :: p1_queue:queue()}).
+               pending_q :: queue()}).
 
+-type queue() :: p1_queue:queue({{pid(), term()}, integer()}).
 -type subscriptions() :: #{binary() => [pid()]}.
 -type error_reason() :: binary() | timeout | disconnected | overloaded.
 -type redis_error() :: {error, error_reason()}.
@@ -592,7 +593,7 @@ fsm_limit_opts() ->
 get_queue_type() ->
     ejabberd_option:redis_queue_type().
 
--spec flush_queue(p1_queue:queue()) -> p1_queue:queue().
+-spec flush_queue(queue()) -> queue().
 flush_queue(Q) ->
     CurrTime = erlang:monotonic_time(millisecond),
     p1_queue:dropwhile(
@@ -605,7 +606,7 @@ flush_queue(Q) ->
              true
       end, Q).
 
--spec clean_queue(p1_queue:queue(), integer()) -> p1_queue:queue().
+-spec clean_queue(queue(), integer()) -> queue().
 clean_queue(Q, CurrTime) ->
     Q1 = p1_queue:dropwhile(
           fun({_From, Time}) ->
index 9d90ab0a8ed74576d1aa75aeb358b5e2cbb16b03..dd7a7c47f3ddff9afaadb614e0a528aeb7f7ef8b 100644 (file)
@@ -46,7 +46,7 @@
                id = 0                :: non_neg_integer(),
                in_flight             :: undefined | publish() | pubrel(),
                codec                 :: mqtt_codec:state(),
-               queue                 :: undefined | p1_queue:queue(),
+               queue                 :: undefined | p1_queue:queue(publish()),
                tls                   :: boolean()}).
 
 -type acks() :: #{non_neg_integer() => pubrec()}.
index 415a7f5de74a50efecbeeee40ac769afaac230e8..bbbd3a2ec963a22df8e5bcff7abf0f446ae5fea1 100644 (file)
@@ -1540,7 +1540,7 @@ get_service_max_users(StateData) ->
 get_max_users_admin_threshold(StateData) ->
     mod_muc_opt:max_users_admin_threshold(StateData#state.server_host).
 
--spec room_queue_new(binary(), ejabberd_shaper:shaper(), _) -> p1_queue:queue().
+-spec room_queue_new(binary(), ejabberd_shaper:shaper(), _) -> p1_queue:queue({message | presence, jid()}) | undefined.
 room_queue_new(ServerHost, Shaper, QueueType) ->
     HaveRoomShaper = Shaper /= none,
     HaveMessageShaper = mod_muc_opt:user_message_shaper(ServerHost) /= none,
@@ -2121,7 +2121,7 @@ get_history(Nick, Packet, #state{history = History}) ->
            p1_queue:to_list(History#lqueue.queue)
     end.
 
--spec filter_history(p1_queue:queue(), erlang:timestamp(),
+-spec filter_history(p1_queue:queue(lqueue_elem()), erlang:timestamp(),
                     binary(), muc_history()) -> [lqueue_elem()].
 filter_history(Queue, Now, Nick,
               #muc_history{since = Since,
@@ -2516,7 +2516,7 @@ lqueue_in(Item, #lqueue{queue = Q1, max = Max}) ->
        true -> #lqueue{queue = Q2, max = Max}
     end.
 
--spec lqueue_cut(p1_queue:queue(), non_neg_integer()) -> p1_queue:queue().
+-spec lqueue_cut(p1_queue:queue(lqueue_elem()), non_neg_integer()) -> p1_queue:queue(lqueue_elem()).
 lqueue_cut(Q, 0) -> Q;
 lqueue_cut(Q, N) ->
     {_, Q1} = p1_queue:out(Q),
index 09af0c7cfa6dc727e3f8f56099ab219dd0f593aa..c151807ffcf8310695dc53ad215569d62500617d 100644 (file)
@@ -50,6 +50,7 @@
        is_record(Pkt, sm_r)).
 
 -type state() :: ejabberd_c2s:state().
+-type queue() :: p1_queue:queue({non_neg_integer(), erlang:timestamp(), xmpp_element() | xmlel()}).
 -type error_reason() :: session_not_found | session_timed_out |
                        session_is_dead | session_has_exited |
                        session_was_killed | session_copy_timed_out |
@@ -298,7 +299,7 @@ set_resume_timeout(State, Timeout) ->
     State1 = restart_pending_timer(State, Timeout),
     State1#{mgmt_timeout => Timeout}.
 
--spec queue_find(fun((stanza()) -> boolean()), p1_queue:queue())
+-spec queue_find(fun((stanza()) -> boolean()), queue())
       -> stanza() | none.
 queue_find(Pred, Queue) ->
     case p1_queue:out(Queue) of