Use TCP keepalive probes in mux mode as well user/miker/multi-relais-timeout-keepalive
authorMike Rylander <mrylander@gmail.com>
Fri, 15 Aug 2014 23:21:34 +0000 (19:21 -0400)
committerMike Rylander <mrylander@gmail.com>
Fri, 15 Aug 2014 23:21:34 +0000 (19:21 -0400)
Signed-off-by: Mike Rylander <mrylander@gmail.com>
SIPServer.pm

index 1f876ab..1756e99 100755 (executable)
@@ -351,6 +351,16 @@ sub mux_input {
             worker_pipe => IO::Pipe->new
         };
  
+        # This is kind of kinky, but allows us to avoid requiring Socket::Linux.
+        # A simple "Socket::Linux"->use won't suffice since we need access to
+        # all of it's bareword constants as well.
+        eval <<'        EVAL';
+        use Socket::Linux qw(TCP_KEEPINTVL TCP_KEEPIDLE TCP_KEEPCNT);
+        setsockopt($self->{server}->{client}, SOL_SOCKET,  SO_KEEPALIVE, 1);
+        setsockopt($self->{server}->{client}, IPPROTO_TCP, TCP_KEEPIDLE, 120);
+        setsockopt($self->{server}->{client}, IPPROTO_TCP, TCP_KEEPINTVL, 10);
+        EVAL
+
         my $pid = fork();
         if (!defined($pid) or $pid < 0) {
             syslog('LOG_ERR', "Unable to fork new child process $!");