]> granicus.if.org Git - ejabberd/commitdiff
Add 'supervisor' listening option
authorEvgeniy Khramtsov <ekhramtsov@process-one.net>
Wed, 11 Jan 2017 07:56:04 +0000 (10:56 +0300)
committerEvgeniy Khramtsov <ekhramtsov@process-one.net>
Wed, 11 Jan 2017 07:56:04 +0000 (10:56 +0300)
If set to 'true' (this is the default), new processes spawned by
ejabberd_listener will be attached to the corresponding supervisor.
No such processes will be attached to a supervisor otherwise.
Setting this to 'false' will improve performance of high loaded
systems where new C2S/S2S processes are spawned very rapidly.

src/ejabberd_c2s.erl
src/ejabberd_s2s_in.erl
src/ejabberd_s2s_out.erl

index 007a94dc944e13123ece41e7e089175dc5994ac8..582327d6c6dd78067473dd652744c7953a00cfc8 100644 (file)
 %%% ejabberd_socket API
 %%%===================================================================
 start(SockData, Opts) ->
-    xmpp_stream_in:start(?MODULE, [SockData, Opts],
-                        ejabberd_config:fsm_limit_opts(Opts)).
+    case proplists:get_value(supervisor, Opts, true) of
+       true ->
+           supervisor:start_child(ejabberd_c2s_sup, [SockData, Opts]);
+       _ ->
+           xmpp_stream_in:start(?MODULE, [SockData, Opts],
+                                ejabberd_config:fsm_limit_opts(Opts))
+    end.
 
 start_link(SockData, Opts) ->
     xmpp_stream_in:start_link(?MODULE, [SockData, Opts],
index cca8438c6b549879a847927bffcd5682f28e8e34..484d0a55a4cfb5e97fff7c4150dd23f1e0f448d5 100644 (file)
 %%% API
 %%%===================================================================
 start(SockData, Opts) ->
-    xmpp_stream_in:start(?MODULE, [SockData, Opts],
-                        ejabberd_config:fsm_limit_opts(Opts)).
+    case proplists:get_value(supervisor, Opts, true) of
+       true ->
+           supervisor:start_child(ejabberd_s2s_in_sup, [SockData, Opts]);
+       _ ->
+           xmpp_stream_in:start(?MODULE, [SockData, Opts],
+                                ejabberd_config:fsm_limit_opts(Opts))
+    end.
 
 start_link(SockData, Opts) ->
     xmpp_stream_in:start_link(?MODULE, [SockData, Opts],
index 5188d269b198d30cb2c8822006293153d2545084..6217a9f52f92a502cb50c4f0110d136d02e5f06f 100644 (file)
 %%% API
 %%%===================================================================
 start(From, To, Opts) ->
-    xmpp_stream_out:start(?MODULE, [ejabberd_socket, From, To, Opts],
-                         ejabberd_config:fsm_limit_opts([])).
+    case proplists:get_value(supervisor, Opts, true) of
+       true ->
+           supervisor:start_child(ejabberd_s2s_out_sup,
+                                  [ejabberd_socket, From, To, Opts]);
+       _ ->
+           xmpp_stream_out:start(?MODULE, [ejabberd_socket, From, To, Opts],
+                                 ejabberd_config:fsm_limit_opts([]))
+    end.
 
 start_link(From, To, Opts) ->
     xmpp_stream_out:start_link(?MODULE, [ejabberd_socket, From, To, Opts],