diff options
author | Christophe Romain <christophe.romain@process-one.net> | 2008-07-08 10:19:57 +0000 |
---|---|---|
committer | Christophe Romain <christophe.romain@process-one.net> | 2008-07-08 10:19:57 +0000 |
commit | f74fb8ea2d96dd460a8fd66dcdaf78a65ac8caac (patch) | |
tree | b09e7bf95cda78671ea37db83192b2aece343711 /src | |
parent | * src/Makefile.in: Spool, config and log dirs: writtable by owner, (diff) |
improve ip fetching patch
SVN Revision: 1416
Diffstat (limited to 'src')
-rw-r--r-- | src/web/ejabberd_http_poll.erl | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/src/web/ejabberd_http_poll.erl b/src/web/ejabberd_http_poll.erl index d93bec79..1929b146 100644 --- a/src/web/ejabberd_http_poll.erl +++ b/src/web/ejabberd_http_poll.erl @@ -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}. |