projects
/
freeside.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
daeb70e
)
freebsd portability fix
author
ivan
<ivan>
Thu, 25 Sep 2003 10:28:13 +0000
(10:28 +0000)
committer
ivan
<ivan>
Thu, 25 Sep 2003 10:28:13 +0000
(10:28 +0000)
fs_selfservice/FS-SelfService/freeside-selfservice-clientd
patch
|
blob
|
history
diff --git
a/fs_selfservice/FS-SelfService/freeside-selfservice-clientd
b/fs_selfservice/FS-SelfService/freeside-selfservice-clientd
index
f13dd42
..
438d472
100644
(file)
--- a/
fs_selfservice/FS-SelfService/freeside-selfservice-clientd
+++ b/
fs_selfservice/FS-SelfService/freeside-selfservice-clientd
@@
-5,7
+5,7
@@
# This is run REMOTELY over ssh by freeside-selfservice-server
use strict;
# This is run REMOTELY over ssh by freeside-selfservice-server
use strict;
-use subs qw(spawn logmsg);
+use subs qw(spawn logmsg
lock_write unlock_write
);
use Fcntl qw(:flock);
use POSIX qw(:sys_wait_h);
use Socket;
use Fcntl qw(:flock);
use POSIX qw(:sys_wait_h);
use Socket;
@@
-25,6
+25,8
@@
my $pid_file = "$socket.pid";
my $log_file = "/usr/local/freeside/selfservice.log";
my $log_file = "/usr/local/freeside/selfservice.log";
+my $lock_file = "/usr/local/freeside/selfservice.writelock";
+
#my $me = '[client]';
$|=1;
#my $me = '[client]';
$|=1;
@@
-35,6
+37,9
@@
$SIG{__WARN__} = \&_logmsg;
#warn "$me Reading init data\n" if $Debug;
#my $signup_init =
#warn "$me Reading init data\n" if $Debug;
#my $signup_init =
+warn "Creating $lock_file\n" if $Debug;
+open(LOCKFILE,">$lock_file") or die "can't open $lock_file: $!";
+
warn "Creating $socket\n" if $Debug;
my $uaddr = sockaddr_un($socket);
my $proto = getprotobyname('tcp');
warn "Creating $socket\n" if $Debug;
my $uaddr = sockaddr_un($socket);
my $proto = getprotobyname('tcp');
@@
-138,11
+143,19
@@
while (1) {
#handle some commands weirdly?
$packet->{_token}=$$;
#handle some commands weirdly?
$packet->{_token}=$$;
+ warn "[child-$$] locking write stream" if $Debug > 1;
+ lock_write;
+
warn "[child-$$] sending packet to remote server" if $Debug > 1;
warn "[child-$$] sending packet to remote server" if $Debug > 1;
- flock(STDOUT, LOCK_EX) or die "FATAL: can't lock write stream: $!";
nstore_fd($packet, \*STDOUT) or die "FATAL: can't send response: $!";
nstore_fd($packet, \*STDOUT) or die "FATAL: can't send response: $!";
+
+ warn "[child-$$] flushing write stream" if $Debug > 1;
STDOUT->flush or die "FATAL: can't flush: $!";
STDOUT->flush or die "FATAL: can't flush: $!";
- flock(STDOUT, LOCK_UN) or die "FATAL: can't release write lock: $!";
+
+ warn "[child-$$] releasing write lock" if $Debug > 1;
+ unlock_write;
+
+ warn "[child-$$] closing write stream" if $Debug > 1;
close STDOUT or die "FATAL: can't close write stream: $!"; #??!
warn "[child-$$] waiting for response from parent" if $Debug > 1;
close STDOUT or die "FATAL: can't close write stream: $!"; #??!
warn "[child-$$] waiting for response from parent" if $Debug > 1;
@@
-224,3
+237,17
@@
sub _logmsg {
flock($log, LOCK_UN);
close $log;
}
flock($log, LOCK_UN);
close $log;
}
+
+sub lock_write {
+ #broken on freebsd?
+ #flock(STDOUT, LOCK_EX) or die "FATAL: can't lock write stream: $!";
+
+ flock(LOCKFILE, LOCK_EX) or die "FATAL: can't lock $lock_file: $!";
+}
+
+sub unlock_write {
+ #broken on freebsd?
+ #flock(STDOUT, LOCK_UN) or die "FATAL: can't release write lock: $!";
+
+ flock(LOCKFILE, LOCK_UN) or die "FATAL: can't unlock $lock_file: $!";
+}