From 6c94d040faf968ada5312b3dead7d9a79f38e399 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Chmielowski?= Date: Wed, 2 May 2012 22:38:19 +0200 Subject: [PATCH] Repeated http-bind request should abort only requests with same rid Before this change, when request with repeat rid was received any waiting request was aborted (but only after next request was delivered). With this change, only request with identical rid are aborted and this is done immediately --- src/web/ejabberd_http_bind.erl | 37 +++++++++++++--------------------- 1 file changed, 14 insertions(+), 23 deletions(-) diff --git a/src/web/ejabberd_http_bind.erl b/src/web/ejabberd_http_bind.erl index 0024cb17d..02b8d27b0 100644 --- a/src/web/ejabberd_http_bind.erl +++ b/src/web/ejabberd_http_bind.erl @@ -447,7 +447,6 @@ handle_sync_event({http_get, Rid, Wait, Hold}, From, StateName, StateData) -> ((StateData#state.output == []) or (StateData#state.rid < Rid)) and ((TNow - StateData#state.ctime) < (Wait*1000*1000)) and (StateData#state.rid =< Rid) and - (StateData#state.input /= cancel) and (StateData#state.pause == 0) -> send_receiver_reply(StateData#state.http_receiver, {ok, empty}), cancel_timer(StateData#state.wait_timer), @@ -459,18 +458,6 @@ handle_sync_event({http_get, Rid, Wait, Hold}, From, StateName, StateData) -> out_of_order_receiver = StateData#state.rid < Rid, wait_timer = WaitTimer, timer = undefined}}; - (StateData#state.input == cancel) -> - send_receiver_reply(StateData#state.http_receiver, {ok, empty}), - cancel_timer(StateData#state.wait_timer), - cancel_timer(StateData#state.timer), - Timer = set_inactivity_timer(StateData#state.pause, - StateData#state.max_inactivity), - Reply = {ok, cancel}, - {reply, Reply, StateName, StateData#state{ - input = queue:new(), - http_receiver = undefined, - wait_timer = undefined, - timer = Timer}}; true -> cancel_timer(StateData#state.timer), Reply = {ok, StateData#state.output}, @@ -668,16 +655,20 @@ process_http_put(#http_put{rid = Rid, attrs = Attrs, payload = Payload, {reply, Reply, StateName, StateData}; repeat -> ?DEBUG("REPEATING ~p", [Rid]), - Reply = case [El#hbr.out || - El <- StateData#state.req_list, - El#hbr.rid == Rid] of - [] -> - {error, not_exists}; - [Out | _XS] -> - {repeat, lists:reverse(Out)} - end, - {reply, Reply, StateName, StateData#state{input = cancel, - last_poll = LastPoll}}; + case [El#hbr.out || + El <- StateData#state.req_list, + El#hbr.rid == Rid] of + [] -> + {error, not_exists}; + [Out | _XS] -> + if (Rid == StateData#state.rid) and + (StateData#state.http_receiver /= undefined) -> + {reply, ok, StateName, StateData}; + true -> + Reply = {repeat, lists:reverse(Out)}, + {reply, Reply, StateName, StateData#state{last_poll = LastPoll}} + end + end; {true, Pause} -> SaveKey = if NewKey == "" ->