From 22dc47a755a3384a5faf6f182e916e483652abce Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Fri, 13 Sep 2013 10:11:04 -0400 Subject: [PATCH] SIP multi connection cleanup; debugging * Use the stringified file handle as the connection ID instead of the fileno. This allows us to find the connection during mux_close, where, since the file handle has already been close, fileno($fh) returns undef. Signed-off-by: Bill Erickson --- SIPServer.pm | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/SIPServer.pm b/SIPServer.pm index edc6a21..78c6e05 100644 --- a/SIPServer.pm +++ b/SIPServer.pm @@ -189,13 +189,12 @@ sub mux_input { # clear read data from the mux string ref $$str_ref = ''; - my $self; - my $conn_id = fileno($mux_fh); + my $conn_id = ''.$mux_fh; # check for kids that went away REAPER(); - + my $self; if (!$active_connections{$conn_id}) { # Brand new connection, log them in $self = $mself->{net_server}; @@ -239,6 +238,9 @@ sub mux_input { $active_connections{$conn_id}->{ils} = ref($self->{ils}); delete $$self{ils}; + my $c = scalar(keys %active_connections); + syslog("LOG_DEBUG", "multi: new active connection; $c total"); + return; } @@ -268,10 +270,18 @@ sub mux_input { } else { # in parent $kid_count++; $kid_hash{$pid} = 1; + syslog("LOG_DEBUG", "multi: $conn_id forked child $pid; $kid_count total"); } +} +# client disconnected, remove the active connection +sub mux_close { + my ($self, $mux, $fh) = @_; + delete $active_connections{''.$fh}; + syslog("LOG_DEBUG", "multi: cleaning up child: $fh"); } + # # Transports # -- 2.11.0