From: Paweł Chmielowski Date: Fri, 1 Jun 2018 12:48:14 +0000 (+0200) Subject: Don't crash in bosh when we receive request with RID < prev_rid X-Git-Tag: 18.06~61 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=548ef7b835fbf2ad965bb4bb3a6f4e4905717002;p=ejabberd Don't crash in bosh when we receive request with RID < prev_rid --- diff --git a/src/ejabberd_bosh.erl b/src/ejabberd_bosh.erl index 1ec45a3e2..6d2971bd9 100644 --- a/src/ejabberd_bosh.erl +++ b/src/ejabberd_bosh.erl @@ -452,7 +452,7 @@ active1(#body{attrs = Attrs} = Req, From, State) -> {next_state, active, do_reply(State, From, PrevBody, RID)}; none -> - State1 = drop_holding_receiver(State), + State1 = drop_holding_receiver(State, RID), State2 = stop_inactivity_timer(State1), State3 = restart_wait_timer(State2), Receivers = gb_trees:insert(RID, {From, Req}, @@ -688,15 +688,16 @@ reply_stop(State, Body, From, RID) -> {stop, normal, do_reply(State, From, Body, RID)}. drop_holding_receiver(State) -> - RID = State#state.prev_rid, + drop_holding_receiver(State#state.prev_rid). +drop_holding_receiver(State, RID) -> case gb_trees:lookup(RID, State#state.receivers) of - {value, {From, Body}} -> - State1 = restart_inactivity_timer(State), - Receivers = gb_trees:delete_any(RID, - State1#state.receivers), - State2 = State1#state{receivers = Receivers}, - do_reply(State2, From, Body, RID); - none -> State + {value, {From, Body}} -> + State1 = restart_inactivity_timer(State), + Receivers = gb_trees:delete_any(RID, + State1#state.receivers), + State2 = State1#state{receivers = Receivers}, + do_reply(State2, From, Body, RID); + none -> State end. do_reply(State, From, Body, RID) ->