From 396b945d207c8f131e8ac6b4881337967b939f19 Mon Sep 17 00:00:00 2001 From: Alexey Shchepin Date: Mon, 7 May 2007 17:52:35 +0000 Subject: [PATCH] * src/ejabberd_receiver.erl: Workaround for inet_drv bug * src/web/ejabberd_http_poll.erl: Added sockname/1 and peername/1 stubs SVN Revision: 763 --- ChangeLog | 7 ++++++- src/ejabberd_receiver.erl | 19 ++++++++++++++----- src/web/ejabberd_http_poll.erl | 7 +++++++ 3 files changed, 27 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 50abf56e5..5e5557b4d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,7 +1,12 @@ 2007-05-07 Alexey Shchepin + * src/ejabberd_receiver.erl: Workaround for inet_drv bug + + * src/web/ejabberd_http_poll.erl: Added sockname/1 and peername/1 + stubs + * src/web/ejabberd_http.hrl: Added "ip" field in the "request" - record + record (thanks to Jerome Sautret and Mickael Remond) * src/web/ejabberd_http.erl: Likewise 2007-05-03 Alexey Shchepin diff --git a/src/ejabberd_receiver.erl b/src/ejabberd_receiver.erl index 71a67723e..3b019a08c 100644 --- a/src/ejabberd_receiver.erl +++ b/src/ejabberd_receiver.erl @@ -258,11 +258,20 @@ code_change(_OldVsn, State, _Extra) -> activate_socket(#state{socket = Socket, sock_mod = SockMod}) -> - case SockMod of - gen_tcp -> - inet:setopts(Socket, [{active, once}]); - _ -> - SockMod:setopts(Socket, [{active, once}]) + PeerName = + case SockMod of + gen_tcp -> + inet:setopts(Socket, [{active, once}]), + inet:peername(Socket); + _ -> + SockMod:setopts(Socket, [{active, once}]), + SockMod:peername(Socket) + end, + case PeerName of + {error, _Reason} -> + self() ! {tcp_closed, Socket}; + {ok, _} -> + ok end. process_data(Data, diff --git a/src/web/ejabberd_http_poll.erl b/src/web/ejabberd_http_poll.erl index 01268b817..912865116 100644 --- a/src/web/ejabberd_http_poll.erl +++ b/src/web/ejabberd_http_poll.erl @@ -22,6 +22,7 @@ terminate/3, send/2, setopts/2, + sockname/1, peername/1, controlling_process/2, close/1, process/2]). @@ -76,6 +77,12 @@ setopts({http_poll, FsmRef}, Opts) -> ok end. +sockname(_Socket) -> + {ok, {{0, 0, 0, 0}, 0}}. + +peername(_Socket) -> + {ok, {{0, 0, 0, 0}, 0}}. + controlling_process(_Socket, _Pid) -> ok.