obtain a new descriptor for the lock in kids, this should fix locking problems
[freeside.git] / fs_selfservice / FS-SelfService / freeside-selfservice-clientd
index 95e9b9b..ededfa6 100644 (file)
@@ -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";
@@ -42,6 +43,7 @@ $SIG{__WARN__} = \&_logmsg;
 
 warn "Creating $lock_file\n" if $Debug;
 open(LOCKFILE,">$lock_file") or die "can't open $lock_file: $!";
+close LOCKFILE;
 
 warn "Creating $socket\n" if $Debug;
 my $uaddr = sockaddr_un($socket);
@@ -255,6 +257,9 @@ sub lock_write {
   #broken on freebsd?
   #flock(STDOUT, LOCK_EX) or die "FATAL: can't lock write stream: $!";
 
+  #open a new one for each kid to get a unique lock
+  open(LOCKFILE,">$lock_file") or die "can't open $lock_file: $!";
+
   flock(LOCKFILE, LOCK_EX) or die "FATAL: can't lock $lock_file: $!";
 }