]> granicus.if.org Git - ejabberd/commitdiff
Assume tcp_init/2 and udp_init/2 now return new options
authorEvgeniy Khramtsov <ekhramtsov@process-one.net>
Sat, 3 May 2014 10:11:58 +0000 (14:11 +0400)
committerEvgeniy Khramtsov <ekhramtsov@process-one.net>
Sat, 3 May 2014 13:48:17 +0000 (17:48 +0400)
src/ejabberd_listener.erl

index 71f7440776a33f5bbd6eb114870b6976ad03d3e8..d3e5949710d52d9de7ba2f31d5e8120dc3de6d61 100644 (file)
@@ -152,19 +152,19 @@ init_udp(PortIP, Module, Opts, SockOpts, Port, IPS) ->
            %% Inform my parent that this port was opened succesfully
            proc_lib:init_ack({ok, self()}),
            case erlang:function_exported(Module, udp_init, 2) of
+               false ->
+                   udp_recv(Socket, Module, Opts);
                true ->
                    case catch Module:udp_init(Socket, Opts) of
                        {'EXIT', _} = Err ->
                            ?ERROR_MSG("failed to process callback function "
                                       "~p:~s(~p, ~p): ~p",
-                                      [Module, udp_init, Socket, Opts, Err]);
-                       _ ->
-                           ok
-                   end;
-               false ->
-                   ok
-           end,
-           udp_recv(Socket, Module, Opts);
+                                      [Module, udp_init, Socket, Opts, Err]),
+                           udp_recv(Socket, Module, Opts);
+                       NewOpts ->
+                           udp_recv(Socket, Module, NewOpts)
+                   end
+           end;
        {error, Reason} ->
            socket_error(Reason, PortIP, Module, SockOpts, Port, IPS)
     end.
@@ -174,20 +174,19 @@ init_tcp(PortIP, Module, Opts, SockOpts, Port, IPS) ->
     %% Inform my parent that this port was opened succesfully
     proc_lib:init_ack({ok, self()}),
     case erlang:function_exported(Module, tcp_init, 2) of
+       false ->
+           accept(ListenSocket, Module, Opts);
        true ->
            case catch Module:tcp_init(ListenSocket, Opts) of
                {'EXIT', _} = Err ->
                    ?ERROR_MSG("failed to process callback function "
                               "~p:~s(~p, ~p): ~p",
-                              [Module, tcp_init, ListenSocket, Opts, Err]);
-               _ ->
-                   ok
-           end;
-       false ->
-           ok
-    end,
-    %% And now start accepting connection attempts
-    accept(ListenSocket, Module, Opts).
+                              [Module, tcp_init, ListenSocket, Opts, Err]),
+                   accept(ListenSocket, Module, Opts);
+               NewOpts ->
+                   accept(ListenSocket, Module, NewOpts)
+           end
+    end.
 
 listen_tcp(PortIP, Module, SockOpts, Port, IPS) ->
     case ets:lookup(listen_sockets, PortIP) of