25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-24 16:23:40 +01:00

improve ip fetching patch

SVN Revision: 1416
This commit is contained in:
Christophe Romain 2008-07-08 10:19:57 +00:00
parent 9626c41817
commit f74fb8ea2d
2 changed files with 11 additions and 9 deletions

View File

@ -1,3 +1,7 @@
2008-07-08 Christophe Romain <christophe.romain@process-one.net>
* src/web/ejabberd_http_poll.erl: improve ip fetching patch
2008-07-07 Badlop <badlop@process-one.net>
* src/Makefile.in: Spool, config and log dirs: writtable by owner,

View File

@ -101,11 +101,9 @@ sockname(_) ->
{ok, ?NULL_PEER}.
peername({http_poll, FsmRef}) ->
gen_fsm:send_all_state_event(FsmRef, {peername, self()}),
%% XXX should improve that, but sync call seems not possible
receive
{peername, PeerName} -> {ok, PeerName}
after 1000 -> {ok, ?NULL_PEER}
case catch gen_fsm:sync_send_all_state_event(FsmRef, peername, 1000) of
{ok, IP} -> {ok, IP};
_ -> {ok, ?NULL_PEER}
end;
peername(_) ->
{ok, ?NULL_PEER}.
@ -238,10 +236,6 @@ handle_event({activate, From}, StateName, StateData) ->
}}
end;
handle_event({peername, From}, StateName, StateData) ->
From ! {peername, StateData#state.ip},
{next_state, StateName, StateData};
handle_event(_Event, StateName, StateData) ->
{next_state, StateName, StateData}.
@ -309,6 +303,10 @@ handle_sync_event(http_get, _From, StateName, StateData) ->
Reply = {ok, StateData#state.output},
{reply, Reply, StateName, StateData#state{output = ""}};
handle_sync_event(peername, _From, StateName, StateData) ->
Reply = {ok, {peername, StateData#state.ip}},
{reply, Reply, StateName, StateData};
handle_sync_event(_Event, _From, StateName, StateData) ->
Reply = ok,
{reply, Reply, StateName, StateData}.