From: Bill Erickson Date: Fri, 13 Sep 2013 14:51:48 +0000 (-0400) Subject: SIP Multi : avoid die in parent X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=047df7bc913b6ad47ee1888adbdad16502535005;p=working%2FSIPServer.git SIP Multi : avoid die in parent Don't allow a connection-level die() to affect the parent process. The parent process must be highly resilient. More logging. Signed-off-by: Bill Erickson --- diff --git a/SIPServer.pm b/SIPServer.pm index 78c6e05..5e577c1 100644 --- a/SIPServer.pm +++ b/SIPServer.pm @@ -213,7 +213,8 @@ sub mux_input { if (! defined($self->{service})) { syslog( "LOG_ERR", "process_request: Unrecognized server connection: %s:%s/%s", $sockaddr, $port, $proto ); - die "process_request: Bad server connection"; + syslog('LOG_ERR', "process_request: Bad server connection"); + return; } my $transport = $transports{ $self->{service}->{transport} }; @@ -223,7 +224,11 @@ sub mux_input { return; } - &$transport($self, $str_fh); + eval { &$transport($self, $str_fh) }; + if ($@) { + syslog('LOG_ERR', "ILS login error: $@"); + return; + } $active_connections{$conn_id} = { id => $conn_id, @@ -247,7 +252,10 @@ sub mux_input { $self = $active_connections{$conn_id}->{net_server}; my $pid = fork(); - die "Cannot fork: $!" unless (defined($pid) && $pid > -1); + if (!defined($pid) or $pid < 0) { + syslog('LOG_ERR', "Unable to fork new child process $!"); + return; + } if ($pid == 0) { # in kid @@ -278,7 +286,8 @@ sub mux_input { sub mux_close { my ($self, $mux, $fh) = @_; delete $active_connections{''.$fh}; - syslog("LOG_DEBUG", "multi: cleaning up child: $fh"); + syslog("LOG_DEBUG", "multi: cleaning up child: $fh; ". + scalar(keys %active_connections)." remain"); }