From: Bill Erickson Date: Fri, 13 Sep 2013 13:32:44 +0000 (-0400) Subject: SIP multiplex X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=6ac9d702d47ff272de57e95da771131886915c46;p=working%2FSIPServer.git SIP multiplex * remove output_fh tracking. It's not needed. * write output Sip::write_msg via POSIX::write to bypass IO::Multiplex output buffer caching. This is needed since SIP child procs never return from mux_input (they exit) so the cached output is never sent to the client. Signed-off-by: Bill Erickson --- diff --git a/SIPServer.pm b/SIPServer.pm index 0118cf3..6e1dabd 100644 --- a/SIPServer.pm +++ b/SIPServer.pm @@ -246,7 +246,6 @@ sub mux_input { } $self = $active_connections{$conn_id}->{net_server}; - $self->{output_fh} = $mux_fh; my $pid = fork(); die "Cannot fork: $!" unless (defined($pid) && $pid > -1); diff --git a/Sip.pm b/Sip.pm index 8a59c10..35ba419 100644 --- a/Sip.pm +++ b/Sip.pm @@ -233,8 +233,6 @@ sub read_SIP_packet { sub write_msg { my ($self, $msg, $file) = @_; - $file ||= $self->{output_fh}; - if ($error_detection) { if (defined($self->{seqno})) { $msg .= 'AY' . $self->{seqno}; @@ -243,11 +241,13 @@ sub write_msg { $msg .= checksum($msg); } + my $outmsg = "$msg\r"; if ($file) { - print $file "$msg\r"; + print $file $outmsg; } else { - print "$msg\r"; + my $rv = POSIX::write(fileno(STDOUT), $outmsg, length($outmsg)); + syslog("LOG_ERR", "Error writing to STDOUT $!") unless $rv; } syslog("LOG_INFO", "OUTPUT MSG: '$msg'"); diff --git a/Sip/MsgType.pm b/Sip/MsgType.pm index b744ef6..543838e 100644 --- a/Sip/MsgType.pm +++ b/Sip/MsgType.pm @@ -423,7 +423,6 @@ sub handle { $req && (substr($msg, 0, 2) ne $req)) { return substr($msg, 0, 2); } - $self->{output_fh} = $server->{output_fh}; return($self->{handler}->($self, $server)); }