]> granicus.if.org Git - ejabberd/commitdiff
* src/ejabberd_receiver.erl: Workaround for inet_drv bug
authorAlexey Shchepin <alexey@process-one.net>
Mon, 7 May 2007 17:52:35 +0000 (17:52 +0000)
committerAlexey Shchepin <alexey@process-one.net>
Mon, 7 May 2007 17:52:35 +0000 (17:52 +0000)
* src/web/ejabberd_http_poll.erl: Added sockname/1 and peername/1
stubs

SVN Revision: 763

ChangeLog
src/ejabberd_receiver.erl
src/web/ejabberd_http_poll.erl

index 50abf56e50485ff3f33866baa7c24f4fe50c7c07..5e5557b4d05c6d093736a8d8543e822bc9001a72 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,7 +1,12 @@
 2007-05-07  Alexey Shchepin  <alexey@sevcom.net>
 
+       * 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  <alexey@sevcom.net>
index 71a67723e0a2171a730490ce5ddf2d051e72bd47..3b019a08c959ad10d1f00aa2bb723115a1fa2ca2 100644 (file)
@@ -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,
index 01268b817ed53e3d880475bd0f6c87262b46483c..912865116da380e62ceb254c658a9021f6bee248 100644 (file)
@@ -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.