From: Bill Erickson Date: Mon, 18 Aug 2014 19:51:02 +0000 (-0400) Subject: LP#1339190 odds and ends X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=83684d93f239761f71991cda9a9debf23ebc7814;p=working%2FSIPServer.git LP#1339190 odds and ends * autoflush worker pipe so child can see the message * avoid disconnect after login fork so subsequent msgs can succeed. ** todo: clean this up or change the expectations * avoid clobbering the ils handle in the child process since it may need to process additional requests. Signed-off-by: Bill Erickson --- diff --git a/SIPServer.pm b/SIPServer.pm index 1756e99..b5e5b34 100755 --- a/SIPServer.pm +++ b/SIPServer.pm @@ -305,7 +305,7 @@ sub mux_input { check_pending_connections(); my $c = scalar(keys %active_connections); - syslog("LOG_DEBUG", "multi: new active connection; $c total"); + syslog("LOG_DEBUG", "multi: inbound message on connection; $c total"); if ($kid_count >= $max_concurrent) { # XXX should we say something to the client? maybe wait and try again? @@ -384,15 +384,17 @@ sub mux_input { $self->{state} = $self->{ils}->state() if (UNIVERSAL::can($self->{ils},'state')); # Evergreen, at least, needs a chance to clean up before forking for other requests - $self->{ils}->disconnect() if (UNIVERSAL::can($self->{ils},'disconnect')); + # Note: This should not be necessary, w/ the child process exiting on completion + #$self->{ils}->disconnect() if (UNIVERSAL::can($self->{ils},'disconnect')); # Stash the ILS module somewhere handy for later - $self->{ils} = ref($self->{ils}); + my $ils_ref = ref($self->{ils}); $cache_data->{success} = 1; $cache_data->{net_server_parts} = { - map { ($_ => $$self{$_}) } qw/ils state institution account/ + map { ($_ => $$self{$_}) } qw/state institution account/ }; + $cache_data->{net_server_parts}{ils} = $ils_ref; } else { $cache_data->{success} = 0; } @@ -411,7 +413,7 @@ sub mux_input { $self->{login_complete_called} = 1; }; - syslog('LOG_DEBUG', "Child $$ / $conn_id kicking of login process"); + syslog('LOG_DEBUG', "Child $$ / $conn_id kicking off login process"); eval { &$transport($self, $active_connections{$conn_id}{worker_pipe}) }; @@ -426,6 +428,8 @@ sub mux_input { } else { my $fh = $active_connections{$conn_id}{worker_pipe}; + $fh->writer; + $fh->autoflush; print $fh $$str_ref; push(@pending_connections, $pid); $kid_hash{$pid} = $conn_id; @@ -437,6 +441,7 @@ sub mux_input { $self = $active_connections{$conn_id}->{net_server}; if ($active_connections{$conn_id}{worker_pipe}) { + syslog('LOG_DEBUG', "multi: parent writing msg to existing child process"); my $fh = $active_connections{$conn_id}{worker_pipe}; print $fh $$str_ref; @@ -476,6 +481,7 @@ sub mux_input { } else { # in parent $active_connections{$conn_id}{worker_pipe}->writer; my $fh = $active_connections{$conn_id}{worker_pipe}; + $fh->autoflush; print $fh $$str_ref; $kid_count++; $kid_hash{$pid} = $conn_id;