%% HTTP GET: send packets to the client
handle_sync_event({http_get, Rid, Wait, Hold}, From, StateName, StateData) ->
%% setup timer
- send_receiver_reply(StateData#state.http_receiver, {ok, empty}),
- cancel_timer(StateData#state.wait_timer),
TNow = tnow(),
if
(Hold > 0) and
((TNow - StateData#state.ctime) < (Wait*1000*1000)) and
(StateData#state.rid =< Rid) and
(StateData#state.input /= cancel) and
- (StateData#state.pause == 0) ->
+ (StateData#state.pause == 0) ->
+ send_receiver_reply(StateData#state.http_receiver, {ok, empty}),
+ cancel_timer(StateData#state.wait_timer),
WaitTimer = erlang:start_timer(Wait * 1000, self(), []),
%% MR: Not sure we should cancel the state timer here.
cancel_timer(StateData#state.timer),
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),
timer = Timer}};
true ->
cancel_timer(StateData#state.timer),
- Timer = set_inactivity_timer(StateData#state.pause,
- StateData#state.max_inactivity),
Reply = {ok, StateData#state.output},
%% save request
ReqList = [#hbr{rid = Rid,
[El || El <- StateData#state.req_list,
El#hbr.rid /= Rid ]
],
- {reply, Reply, StateName, StateData#state{
- output = [],
- http_receiver = undefined,
- wait_timer = undefined,
- timer = Timer,
- req_list = ReqList}}
+ if
+ (StateData#state.http_receiver /= undefined) and
+ StateData#state.out_of_order_receiver ->
+ {reply, Reply, StateName, StateData#state{
+ output = [],
+ timer = undefined,
+ req_list = ReqList,
+ out_of_order_receiver = false}};
+ true ->
+ send_receiver_reply(StateData#state.http_receiver, {ok, empty}),
+ cancel_timer(StateData#state.wait_timer),
+ Timer = set_inactivity_timer(StateData#state.pause,
+ StateData#state.max_inactivity),
+ {reply, Reply, StateName,
+ StateData#state{output = [],
+ http_receiver = undefined,
+ wait_timer = undefined,
+ timer = Timer,
+ req_list = ReqList}}
+ end
end;
handle_sync_event(peername, _From, StateName, StateData) ->