From 07fd88f7c0cd757eb2f8e635b71acebe6a944602 Mon Sep 17 00:00:00 2001 From: ivan Date: Tue, 14 Sep 2004 06:47:46 +0000 Subject: [PATCH] selfservice: - server: don't reconnect again if we've already been signalled to shutdown - server: add kid reaping to shutdown sequence - server: add another optional logging level to response sending - server: acquire write mutex for keepalives --- FS/bin/freeside-selfservice-server | 17 +++++++++++++---- .../FS-SelfService/freeside-selfservice-clientd | 7 ++++--- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/FS/bin/freeside-selfservice-server b/FS/bin/freeside-selfservice-server index a83664db2..ad100e83a 100644 --- a/FS/bin/freeside-selfservice-server +++ b/FS/bin/freeside-selfservice-server @@ -25,8 +25,8 @@ use FS::Conf; use FS::cust_bill; use FS::cust_pkg; -$Debug = 1; # >= 2 will log packet contents, including potentially compromising - # information +$Debug = 1; # 2 will turn on more logging + # 3 will log packet contents, including passwords $shutdown = 0; $max_kids = '10'; #? @@ -73,7 +73,9 @@ while (1) { &shutdown if $shutdown; if ( $keepalives && $keepalive_count++ > 10 ) { $keepalive_count = 0; + lock_write; nstore_fd( { _token => '_keepalive' }, $writer ); + unlock_write; } next; } @@ -96,7 +98,7 @@ while (1) { } warn "packet received\n". join('', map { " $_=>$packet->{$_}\n" } keys %$packet ) - if $Debug > 1; + if $Debug > 2; if ( $packet->{_packet} eq '_enable_keepalive' ) { warn "enabling keep alives\n" if $Debug; @@ -136,8 +138,8 @@ while (1) { } $rv->{_token} = $packet->{_token}; #identifier - warn "sending response\n" if $Debug; lock_write; + warn "sending response\n" if $Debug; nstore_fd($rv, $writer) or die "FATAL: can't send response: $!"; $writer->flush or die "FATAL: can't flush: $!"; unlock_write; @@ -148,6 +150,7 @@ while (1) { } + &shutdown if $shutdown; warn "connection lost, reconnecting\n" if $Debug; sleep 3; @@ -229,10 +232,12 @@ sub init { } sub shutdown { + &reap_kids; my $wait = 12; #wait up to 1 minute while ( $kids > 0 && $wait-- ) { warn "waiting for $kids children to terminate"; sleep 5; + &reap_kids; } warn "abandoning $kids children" if $kids; kill 'TERM', $ssh_pid if $ssh_pid; @@ -261,6 +266,8 @@ sub _do_logmsg { } sub lock_write { + warn "locking $lock_file mutex for write to write stream\n" if $Debug > 1; + #broken on freebsd? #flock($writer, LOCK_EX) or die "FATAL: can't lock write stream: $!"; @@ -269,6 +276,8 @@ sub lock_write { } sub unlock_write { + warn "unlocking $lock_file mutex\n" if $Debug > 1; + #broken on freebsd? #flock($writer, LOCK_UN) or die "WARNING: can't release write lock: $!"; diff --git a/fs_selfservice/FS-SelfService/freeside-selfservice-clientd b/fs_selfservice/FS-SelfService/freeside-selfservice-clientd index 95e9b9b4f..5a058381d 100644 --- a/fs_selfservice/FS-SelfService/freeside-selfservice-clientd +++ b/fs_selfservice/FS-SelfService/freeside-selfservice-clientd @@ -19,9 +19,10 @@ use IO::File; my $tag = scalar(@ARGV) ? '.'.shift : ''; use vars qw( $Debug ); -$Debug = 2; #2 will turn on child logging, 3 will log packet contents, - #including potentially compromising information, 4 will log - #receipts of all packets from server including keepalives (big!) +$Debug = 2; #2 will turn on child logging + #3 will log packet contents,#including passwords + #4 will log receipts of all packets from server including + # keepalives (big!) my $socket = "/usr/local/freeside/selfservice_socket$tag"; my $pid_file = "$socket.pid"; -- 2.11.0