25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-22 16:20:52 +01:00

Improve ip fetching patch (thanks to Christohpe Romain)

SVN Revision: 2304
This commit is contained in:
Badlop 2009-06-16 18:26:36 +00:00
parent 3e0827deea
commit d25bd8c1c6

View File

@ -4,7 +4,7 @@
%%% Purpose : Implements XMPP over BOSH (XEP-0205) (formerly known as %%% Purpose : Implements XMPP over BOSH (XEP-0205) (formerly known as
%%% HTTP Binding) %%% HTTP Binding)
%%% Created : 21 Sep 2005 by Stefan Strigler <steve@zeank.in-berlin.de> %%% Created : 21 Sep 2005 by Stefan Strigler <steve@zeank.in-berlin.de>
%%% Id : $Id: ejabberd_http_bind.erl 674 2008-07-03 15:58:15Z cromain $ %%% Id : $Id: ejabberd_http_bind.erl 683 2008-07-08 10:30:45Z cromain $
%%%---------------------------------------------------------------------- %%%----------------------------------------------------------------------
-module(ejabberd_http_bind). -module(ejabberd_http_bind).
@ -119,11 +119,9 @@ sockname(_Socket) ->
{ok, ?NULL_PEER}. {ok, ?NULL_PEER}.
peername({http_bind, FsmRef}) -> peername({http_bind, FsmRef}) ->
gen_fsm:send_all_state_event(FsmRef, {peername, self()}), case catch gen_fsm:sync_send_all_state_event(FsmRef, peername, 1000) of
%% XXX should improve that, but sync call seems not possible {ok, IP} -> {ok, IP};
receive _ -> {ok, ?NULL_PEER}
{peername, PeerName} -> {ok, PeerName}
after 1000 -> {ok, ?NULL_PEER}
end; end;
peername(_) -> peername(_) ->
{ok, ?NULL_PEER}. {ok, ?NULL_PEER}.
@ -281,10 +279,6 @@ handle_event({activate, From}, StateName, StateData) ->
last_receiver = Receiver}} last_receiver = Receiver}}
end; end;
handle_event({peername, From}, StateName, StateData) ->
From ! {peername, StateData#state.ip},
{next_state, StateName, StateData};
handle_event(_Event, StateName, StateData) -> handle_event(_Event, StateName, StateData) ->
{next_state, StateName, StateData}. {next_state, StateName, StateData}.
@ -622,6 +616,10 @@ handle_sync_event({http_get, Rid, Wait, Hold}, From, StateName, StateData) ->
req_list = ReqList}} req_list = ReqList}}
end; end;
handle_sync_event(peername, _From, StateName, StateData) ->
Reply = {ok, StateData#state.ip},
{reply, Reply, StateName, StateData};
handle_sync_event(_Event, _From, StateName, StateData) -> handle_sync_event(_Event, _From, StateName, StateData) ->
Reply = ok, Reply = ok,
{reply, Reply, StateName, StateData}. {reply, Reply, StateName, StateData}.