Fix drain the session process mailbox handling err

This commit is contained in:
HeeeJianBo 2019-03-27 21:00:13 +08:00 committed by tigercl
parent 043f7d5473
commit 24f8c3a391
1 changed files with 8 additions and 2 deletions

View File

@ -839,8 +839,14 @@ drain_m(Cnt, Msgs) when Cnt =< 0 ->
lists:reverse(Msgs);
drain_m(Cnt, Msgs) ->
receive
{dispatch, Topic, Msg} ->
drain_m(Cnt-1, [{Topic, Msg}|Msgs])
{dispatch, Topic, Msg} when is_record(Msg, message)->
drain_m(Cnt-1, [{Topic, Msg} | Msgs]);
{dispatch, Topic, InMsgs} when is_list(InMsgs) ->
Msgs1 = lists:foldl(
fun(Msg, Acc) ->
[{Topic, Msg} | Acc]
end, Msgs, InMsgs),
drain_m(Cnt-length(InMsgs), Msgs1)
after 0 ->
lists:reverse(Msgs)
end.