Comparison

plugins/mod_component.lua @ 5953:1c08d6cca552

mod_component: Enable TCP keepalives on component streams
author Kim Alvefur <zash@zash.se>
date Wed, 18 Dec 2013 18:35:35 +0100
parent 5952:31b800964dfb
child 5954:6dc73be95213
child 6380:4220ffb87b22
comparison
equal deleted inserted replaced
5952:31b800964dfb 5953:1c08d6cca552
22 22
23 local core_process_stanza = prosody.core_process_stanza; 23 local core_process_stanza = prosody.core_process_stanza;
24 local hosts = prosody.hosts; 24 local hosts = prosody.hosts;
25 25
26 local log = module._log; 26 local log = module._log;
27
28 local opt_keepalives = module:get_option_boolean("component_tcp_keepalives", module:get_option_boolean("tcp_keepalives", true));
27 29
28 local sessions = module:shared("sessions"); 30 local sessions = module:shared("sessions");
29 31
30 function module.add_host(module) 32 function module.add_host(module)
31 if module:get_host_type() ~= "component" then 33 if module:get_host_type() ~= "component" then
267 269
268 -- Logging functions -- 270 -- Logging functions --
269 local conn_name = "jcp"..tostring(session):match("[a-f0-9]+$"); 271 local conn_name = "jcp"..tostring(session):match("[a-f0-9]+$");
270 session.log = logger.init(conn_name); 272 session.log = logger.init(conn_name);
271 session.close = session_close; 273 session.close = session_close;
274
275 if opt_keepalives then
276 conn:setoption("keepalive", opt_keepalives);
277 end
272 278
273 session.log("info", "Incoming Jabber component connection"); 279 session.log("info", "Incoming Jabber component connection");
274 280
275 local stream = new_xmpp_stream(session, stream_callbacks); 281 local stream = new_xmpp_stream(session, stream_callbacks);
276 session.stream = stream; 282 session.stream = stream;