aboutsummaryrefslogtreecommitdiff
path: root/tests/ftpserver.pl
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ftpserver.pl')
-rw-r--r--tests/ftpserver.pl15
1 files changed, 14 insertions, 1 deletions
diff --git a/tests/ftpserver.pl b/tests/ftpserver.pl
index 02a048f13..ce82d642b 100644
--- a/tests/ftpserver.pl
+++ b/tests/ftpserver.pl
@@ -6,7 +6,7 @@
# | (__| |_| | _ <| |___
# \___|\___/|_| \_\_____|
#
-# Copyright (C) 1998 - 2007, Daniel Stenberg, <daniel@haxx.se>, et al.
+# Copyright (C) 1998 - 2008, Daniel Stenberg, <daniel@haxx.se>, et al.
#
# This software is licensed as described in the file COPYING, which
# you should have received as part of this distribution. The terms
@@ -85,6 +85,8 @@ my $port = 8921; # just a default
my $listenaddr = "127.0.0.1"; # just a default
my $pidfile = ".ftpd.pid"; # a default, use --pidfile
+my $SERVERLOGS_LOCK="log/serverlogs.lock"; # server logs advisor read lock
+
do {
if($ARGV[0] eq "-v") {
$verbose=1;
@@ -121,6 +123,7 @@ sub catch_zap {
my $signame = shift;
print STDERR "ftpserver.pl received SIG$signame, exiting\n";
ftpkillslaves(1);
+ clear_advisor_read_lock($SERVERLOGS_LOCK);
die "Somebody sent me a SIG$signame";
}
$SIG{INT} = \&catch_zap;
@@ -146,6 +149,7 @@ sub sysread_or_die {
logmsg "Error: ftp$ftpdnum$ext sysread error: $!\n";
kill(9, $sfpid);
waitpid($sfpid, 0);
+ clear_advisor_read_lock($SERVERLOGS_LOCK);
die "Died in sysread_or_die() at $fcaller " .
"line $lcaller. ftp$ftpdnum$ext sysread error: $!\n";
}
@@ -155,6 +159,7 @@ sub sysread_or_die {
logmsg "Error: ftp$ftpdnum$ext read zero\n";
kill(9, $sfpid);
waitpid($sfpid, 0);
+ clear_advisor_read_lock($SERVERLOGS_LOCK);
die "Died in sysread_or_die() at $fcaller " .
"line $lcaller. ftp$ftpdnum$ext read zero\n";
}
@@ -176,6 +181,7 @@ sub startsf {
logmsg "Failed sockfilt command: $cmd\n";
kill(9, $sfpid);
waitpid($sfpid, 0);
+ clear_advisor_read_lock($SERVERLOGS_LOCK);
die "Failed to start sockfilt!";
}
}
@@ -784,6 +790,8 @@ while(1) {
}
logmsg "====> Client connect\n";
+ set_advisor_read_lock($SERVERLOGS_LOCK);
+
# flush data:
$| = 1;
@@ -888,8 +896,13 @@ while(1) {
} # while(1)
logmsg "====> Client disconnected\n";
+
+ clear_advisor_read_lock($SERVERLOGS_LOCK);
}
print SFWRITE "QUIT\n";
waitpid $sfpid, 0;
+
+clear_advisor_read_lock($SERVERLOGS_LOCK);
+
exit;