mod_component: Enable TCP keepalives on component streams
authorKim Alvefur <zash@zash.se>
Wed, 18 Dec 2013 17:35:35 +0000 (18:35 +0100)
committerKim Alvefur <zash@zash.se>
Wed, 18 Dec 2013 17:35:35 +0000 (18:35 +0100)
plugins/mod_component.lua

index b6e111d5a9f8126e066f28bcfaf403ff1f001aed..c5a1da81ce49e3f920eae0dab735d92977043c3e 100644 (file)
@@ -25,6 +25,8 @@ local hosts = prosody.hosts;
 
 local log = module._log;
 
+local opt_keepalives = module:get_option_boolean("component_tcp_keepalives", module:get_option_boolean("tcp_keepalives", true));
+
 local sessions = module:shared("sessions");
 
 function module.add_host(module)
@@ -269,6 +271,10 @@ function listener.onconnect(conn)
        local conn_name = "jcp"..tostring(session):match("[a-f0-9]+$");
        session.log = logger.init(conn_name);
        session.close = session_close;
+
+       if opt_keepalives then
+               conn:setoption("keepalive", opt_keepalives);
+       end
        
        session.log("info", "Incoming Jabber component connection");