From: Mike Rylander Date: Wed, 20 Aug 2014 00:19:51 +0000 (-0400) Subject: Add support for login and institution keepalive values; Clean up kids in non-mux... X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=a0e304369e74b01b30dc1c08f15f167ceaca7602;p=working%2FSIPServer.git Add support for login and institution keepalive values; Clean up kids in non-mux mode Signed-off-by: Mike Rylander --- diff --git a/SIPServer.pm b/SIPServer.pm index fdd2152..d16eec3 100755 --- a/SIPServer.pm +++ b/SIPServer.pm @@ -273,20 +273,24 @@ sub check_pending_connections { } sub sig_chld { - for (keys(%kid_hash)) { - if ( my $reaped = waitpid($_, WNOHANG) > 0 ) { - syslog('LOG_DEBUG', "Reaping child $_"); - # Mourning... done. - $kid_count--; - # note: in some cases (when the primary connection is severed), - # the active connection is cleaned up in mux_close. - if ($active_connections{$kid_hash{$_}}) { - if ($active_connections{$kid_hash{$_}}{worker_pipe}) { - syslog('LOG_DEBUG', "Closing worker pipe after timeout for: $kid_hash{$_}"); - delete $active_connections{$kid_hash{$_}}{worker_pipe}; + if ( !scalar(keys(%kid_hash))) { # not using mux mode + 1 while waitpid(-1, WNOHANG) > 0; + } else { + for (keys(%kid_hash)) { + if ( my $reaped = waitpid($_, WNOHANG) > 0 ) { + syslog('LOG_DEBUG', "Reaping child $_"); + # Mourning... done. + $kid_count--; + # note: in some cases (when the primary connection is severed), + # the active connection is cleaned up in mux_close. + if ($active_connections{$kid_hash{$_}}) { + if ($active_connections{$kid_hash{$_}}{worker_pipe}) { + syslog('LOG_DEBUG', "Closing worker pipe after timeout for: $kid_hash{$_}"); + delete $active_connections{$kid_hash{$_}}{worker_pipe}; + } } + delete $kid_hash{$_}; } - delete $kid_hash{$_}; } } } @@ -429,7 +433,12 @@ sub mux_input { $self->{login_complete}->(0) unless $self->{login_complete_called}; } - $self->sip_protocol_loop($active_connections{$conn_id}{worker_pipe}, $worker_keepalive); + $self->sip_protocol_loop( + $active_connections{$conn_id}{worker_pipe}, + $self->{account}->{'worker-keepalive'} + // $self->{institution}->{'worker-keepalive'} + // $worker_keepalive + ); exit(0); @@ -485,7 +494,13 @@ sub mux_input { exit(0); } - $self->sip_protocol_loop($active_connections{$conn_id}{worker_pipe}, $worker_keepalive); + $self->sip_protocol_loop( + $active_connections{$conn_id}{worker_pipe}, + $self->{account}->{'worker-keepalive'} + // $self->{institution}->{'worker-keepalive'} + // $worker_keepalive + ); + exit(0);