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=ff279291b3305bc349739415e8f1a44bb9c76177;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 e60532e..edc6a21 100644 --- a/SIPServer.pm +++ b/SIPServer.pm @@ -243,7 +243,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 07a4cd7..0e184fc 100644 --- a/Sip.pm +++ b/Sip.pm @@ -226,8 +226,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}; @@ -236,11 +234,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 4648ef4..6fb4793 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)); }