mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-28 16:34:13 +01:00
* src/web/ejabberd_http_poll.erl: Messages polled between the
the last client request and the polling timeout were lost. Those messages are now resent using ejabberd routing mechanisms (EJAB-87). SVN Revision: 575
This commit is contained in:
parent
ce5d10eb59
commit
ae537d2bfb
@ -1,3 +1,9 @@
|
|||||||
|
2006-06-31 Mickael Remond <mickael.remond@process-one.net>
|
||||||
|
|
||||||
|
* src/web/ejabberd_http_poll.erl: Messages polled between the
|
||||||
|
the last client request and the polling timeout were lost. Those
|
||||||
|
messages are now resent using ejabberd routing mechanisms.
|
||||||
|
|
||||||
2006-05-29 Mickael Remond <mickael.remond@process-one.net>
|
2006-05-29 Mickael Remond <mickael.remond@process-one.net>
|
||||||
|
|
||||||
* src/mod_roster.erl: According to RFC3921 section 9.2, outbound
|
* src/mod_roster.erl: According to RFC3921 section 9.2, outbound
|
||||||
|
@ -36,7 +36,7 @@
|
|||||||
key,
|
key,
|
||||||
output = "",
|
output = "",
|
||||||
input = "",
|
input = "",
|
||||||
waiting_input = false,
|
waiting_input = false, %% {ReceiverPid, Tag}
|
||||||
last_receiver,
|
last_receiver,
|
||||||
timer}).
|
timer}).
|
||||||
|
|
||||||
@ -195,7 +195,7 @@ handle_event(Event, StateName, StateData) ->
|
|||||||
%% {stop, Reason, Reply, NewStateData}
|
%% {stop, Reason, Reply, NewStateData}
|
||||||
%%----------------------------------------------------------------------
|
%%----------------------------------------------------------------------
|
||||||
handle_sync_event({send, Packet}, From, StateName, StateData) ->
|
handle_sync_event({send, Packet}, From, StateName, StateData) ->
|
||||||
Output = [StateData#state.output | Packet],
|
Output = StateData#state.output ++ [lists:flatten(Packet)],
|
||||||
Reply = ok,
|
Reply = ok,
|
||||||
{reply, Reply, StateName, StateData#state{output = Output}};
|
{reply, Reply, StateName, StateData#state{output = Output}};
|
||||||
|
|
||||||
@ -234,7 +234,7 @@ handle_sync_event({http_put, Key, NewKey, Packet},
|
|||||||
Allow ->
|
Allow ->
|
||||||
case StateData#state.waiting_input of
|
case StateData#state.waiting_input of
|
||||||
false ->
|
false ->
|
||||||
Input = [StateData#state.input | Packet],
|
Input = [StateData#state.input|Packet],
|
||||||
Reply = ok,
|
Reply = ok,
|
||||||
{reply, Reply, StateName, StateData#state{input = Input,
|
{reply, Reply, StateName, StateData#state{input = Input,
|
||||||
key = NewKey}};
|
key = NewKey}};
|
||||||
@ -291,13 +291,18 @@ terminate(Reason, StateName, StateData) ->
|
|||||||
end),
|
end),
|
||||||
case StateData#state.waiting_input of
|
case StateData#state.waiting_input of
|
||||||
false ->
|
false ->
|
||||||
|
%% We are testing this case due to "socket activation": If we pass
|
||||||
|
%% here and the "socket" is not ready to receive, the tcp_closed
|
||||||
|
%% will be lost.
|
||||||
case StateData#state.last_receiver of
|
case StateData#state.last_receiver of
|
||||||
undefined -> ok;
|
undefined -> ok;
|
||||||
Receiver -> Receiver ! {tcp_closed, {http_poll, self()}}
|
Receiver ->
|
||||||
|
Receiver ! {tcp_closed, {http_poll, self()}}
|
||||||
end;
|
end;
|
||||||
{Receiver, _Tag} ->
|
{Receiver, _Tag} ->
|
||||||
Receiver ! {tcp_closed, {http_poll, self()}}
|
Receiver ! {tcp_closed, {http_poll, self()}}
|
||||||
end,
|
end,
|
||||||
|
resend_messages(StateData#state.output),
|
||||||
ok.
|
ok.
|
||||||
|
|
||||||
%%%----------------------------------------------------------------------
|
%%%----------------------------------------------------------------------
|
||||||
@ -348,3 +353,27 @@ cancel_timer(Timer) ->
|
|||||||
ok
|
ok
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
%% Resend the polled messages
|
||||||
|
resend_messages(Messages) ->
|
||||||
|
lists:foreach(fun(Packet) ->
|
||||||
|
resend_message(Packet)
|
||||||
|
end, Messages).
|
||||||
|
|
||||||
|
%% This function is used to resend messages that have been polled but not
|
||||||
|
%% delivered.
|
||||||
|
resend_message(Packet) ->
|
||||||
|
ParsedPacket = xml_stream:parse_element(Packet),
|
||||||
|
From = get_jid("from", ParsedPacket),
|
||||||
|
To = get_jid("to", ParsedPacket),
|
||||||
|
io:format("MREMOND: Resend ~p ~p ~p~n",[From,To, ParsedPacket]),
|
||||||
|
ejabberd_router:route(From, To, ParsedPacket).
|
||||||
|
|
||||||
|
%% Type can be "from" or "to"
|
||||||
|
%% Parsed packet is a parsed Jabber packet.
|
||||||
|
get_jid(Type, ParsedPacket) ->
|
||||||
|
case xml:get_tag_attr(Type, ParsedPacket) of
|
||||||
|
{value, StringJid} ->
|
||||||
|
jlib:string_to_jid(StringJid);
|
||||||
|
false ->
|
||||||
|
jlib:make_jid("","","")
|
||||||
|
end.
|
||||||
|
Loading…
Reference in New Issue
Block a user