Merge pull request #437 from emqtt/0.15

0.15 - fix priority queue
This commit is contained in:
Feng Lee 2016-01-25 14:47:40 +08:00
commit bf570364a9
2 changed files with 10 additions and 6 deletions

View File

@ -25,10 +25,8 @@
%%%----------------------------------------------------------------------------- %%%-----------------------------------------------------------------------------
-module(emqttd_util). -module(emqttd_util).
-export([apply_module_attributes/1, -export([apply_module_attributes/1, all_module_attributes/1, cancel_timer/1,
all_module_attributes/1, now_to_secs/0, now_to_secs/1, now_to_ms/0, now_to_ms/1]).
cancel_timer/1,
now_to_secs/0, now_to_secs/1]).
-export([integer_to_binary/1]). -export([integer_to_binary/1]).
@ -94,3 +92,9 @@ now_to_secs() ->
now_to_secs({MegaSecs, Secs, _MicroSecs}) -> now_to_secs({MegaSecs, Secs, _MicroSecs}) ->
MegaSecs * 1000000 + Secs. MegaSecs * 1000000 + Secs.
now_to_ms() ->
now_to_ms(os:timestamp()).
now_to_ms({MegaSecs, Secs, MicroSecs}) ->
(MegaSecs * 1000000 + Secs) * 1000 + round(MicroSecs/1000).

View File

@ -98,8 +98,8 @@ len({pqueue, Queues}) ->
plen(0, {queue, _R, _F, L}) -> plen(0, {queue, _R, _F, L}) ->
L; L;
plen(P, {queue, _R, _F, _}) -> plen(_, {queue, _R, _F, _}) ->
erlang:error(badarg, [P]); 0;
plen(P, {pqueue, Queues}) -> plen(P, {pqueue, Queues}) ->
case lists:keysearch(maybe_negate_priority(P), 1, Queues) of case lists:keysearch(maybe_negate_priority(P), 1, Queues) of
{value, {_, Q}} -> len(Q); {value, {_, Q}} -> len(Q);