Host: the.old.moo.%TESTNUMBER:%HTTPPORT\r
Proxy-Connection: Keep-Alive\r
\r
+[DISCONNECT]
</proxy>
<protocol>
GET /%TESTNUMBER HTTP/1.1\r
Proxy-Authorization: Basic dGVzdDppbmc=\r
Proxy-Connection: Keep-Alive\r
\r
+[DISCONNECT]
</proxy>
<protocol>
GET /%TESTNUMBER HTTP/1.1\r
exe_ext
);
+use globalconfig qw(
+ $LOCKDIR
+ );
+
#**********************************************************************
# global vars...
#
#**********************************************************************
# global vars used for server logs advisor read lock handling
#
-my $SERVERLOGS_LOCK = "serverlogs.lock";
my $serverlogs_lockfile;
my $serverlogslocked = 0;
$mainsockf_pidfile = mainsockf_pidfilename($piddir, $proto, $ipvnum, $idnum);
$mainsockf_logfile =
mainsockf_logfilename($logdir, $proto, $ipvnum, $idnum);
-$serverlogs_lockfile = "$logdir/$SERVERLOGS_LOCK";
if($proto eq 'ftp') {
$datasockf_pidfile = datasockf_pidfilename($piddir, $proto, $ipvnum, $idnum);
}
$srvrname = servername_str($proto, $ipvnum, $idnum);
+$serverlogs_lockfile = "$logdir/$LOCKDIR/${srvrname}.lock";
$idstr = "$idnum" if($idnum > 1);
$has_shared
$LIBDIR
$listonly
+ $LOCKDIR
$LOGDIR
$memanalyze
$MEMDUMP
our $valgrind; # path to valgrind, or empty if disabled
# paths in $LOGDIR
+our $LOCKDIR = "lock"; # root of the server directory with lock files
our $PIDDIR = "server"; # root of the server directory with PID files
our $SERVERIN="server.input"; # what curl sent the server
our $PROXYIN="proxy.input"; # what curl sent the proxy
my %oldenv; # environment variables before test is started
my $UNITDIR="./unit";
my $CURLLOG="$LOGDIR/commands.log"; # all command lines run
-my $SERVERLOGS_LOCK="$LOGDIR/serverlogs.lock"; # server logs advisor read lock
my $defserverlogslocktimeout = 2; # timeout to await server logs lock removal
my $defpostcommanddelay = 0; # delay between command and postcheck sections
my $multiprocess; # nonzero with a separate test runner process
# Set this directory as ours
$LOGDIR = $logdir;
mkdir("$LOGDIR/$PIDDIR", 0777);
+ mkdir("$LOGDIR/$LOCKDIR", 0777);
# Initialize various server variables
initserverconfig();
}
+#######################################################################
+# Return a list of log locks that still exist
+#
+sub logslocked {
+ opendir(my $lockdir, "$LOGDIR/$LOCKDIR");
+ my @locks;
+ foreach (readdir $lockdir) {
+ if(/^(.*)\.lock$/) {
+ push @locks, $1;
+ }
+ }
+ return @locks;
+}
+
#######################################################################
# Memory allocation test and failure torture testing.
#
}
if($serverlogslocktimeout) {
my $lockretry = $serverlogslocktimeout * 20;
- while((-f $SERVERLOGS_LOCK) && $lockretry--) {
+ my @locks;
+ while((@locks = logslocked()) && $lockretry--) {
portable_sleep(0.05);
}
if(($lockretry < 0) &&
($serverlogslocktimeout >= $defserverlogslocktimeout)) {
logmsg "Warning: server logs lock timeout ",
- "($serverlogslocktimeout seconds) expired\n";
+ "($serverlogslocktimeout seconds) expired (locks: " .
+ join(", ", @locks) . ")\n";
}
}
opendir(my $dh, $dir) ||
return 0; # can't open dir
while($file = readdir($dh)) {
- # Don't clear the $PIDDIR since those need to live beyond one test
- if(($file !~ /^(\.|\.\.)\z/) && "$file" ne $PIDDIR) {
+ # Don't clear the $PIDDIR or $LOCKDIR since those need to live beyond
+ # one test
+ if(($file !~ /^(\.|\.\.)\z/) &&
+ "$file" ne $PIDDIR && "$file" ne $LOCKDIR) {
if(-d "$dir/$file") {
if(!cleardir("$dir/$file")) {
$done = 0;
if($singletest_state{$runnerid} == ST_INIT) {
my $logdir = getrunnerlogdir($runnerid);
- # first, remove all lingering log files
- if(!cleardir($logdir) && $clearlocks) {
- runnerac_clearlocks($runnerid, $logdir);
+ # first, remove all lingering log & lock files
+ if((!cleardir($logdir) || !cleardir("$logdir/$LOCKDIR"))
+ && $clearlocks) {
+ # On Windows, lock files can't be deleted when the process still
+ # has them open, so kill those processes first
+ runnerac_clearlocks($runnerid, "$logdir/$LOCKDIR");
$singletest_state{$runnerid} = ST_CLEARLOCKS;
} else {
$singletest_state{$runnerid} = ST_INITED;
# Maybe create & use & delete a temporary directory in that function
cleardir($LOGDIR);
mkdir($LOGDIR, 0777);
+mkdir("$LOGDIR/$LOCKDIR", 0777);
#######################################################################
# initialize some variables
if($ridready) {
# This runner is ready to be serviced
my $testnum = $runnersrunning{$ridready};
+ defined $testnum || die 'Internal error: test for runner unknown';
delete $runnersrunning{$ridready};
my ($error, $again) = singletest($ridready, $testnum, $countforrunner{$ridready}, $totaltests);
if($again) {
}
}
- msnprintf(loglockfile, sizeof(loglockfile), "%s/%s",
- logdir, SERVERLOGS_LOCK);
+ msnprintf(loglockfile, sizeof(loglockfile), "%s/%s/mqtt-%s.lock",
+ logdir, SERVERLOGS_LOCKDIR, ipv_inuse);
#ifdef WIN32
win32_init();
}
}
- msnprintf(loglockfile, sizeof(loglockfile), "%s/%s",
- logdir, SERVERLOGS_LOCK);
+ msnprintf(loglockfile, sizeof(loglockfile), "%s/%s/rtsp-%s.lock",
+ logdir, SERVERLOGS_LOCKDIR, ipv_inuse);
#ifdef WIN32
win32_init();
char port_str[11];
const char *location_str = port_str;
int keepalive_secs = 5;
+ const char *protocol_type = "HTTP";
/* a default CONNECT port is basically pointless but still ... */
size_t socket_idx;
else if(!strcmp("--gopher", argv[arg])) {
arg++;
use_gopher = TRUE;
+ protocol_type = "GOPHER";
end_of_headers = "\r\n"; /* gopher style is much simpler */
}
else if(!strcmp("--ipv4", argv[arg])) {
}
}
- msnprintf(loglockfile, sizeof(loglockfile), "%s/%s",
- logdir, SERVERLOGS_LOCK);
+ msnprintf(loglockfile, sizeof(loglockfile), "%s/%s/sws-%s%s-%s.lock",
+ logdir, SERVERLOGS_LOCKDIR, protocol_type,
+ is_proxy ? "-proxy" : "", socket_type);
#ifdef WIN32
win32_init();
msnprintf(port_str, sizeof(port_str), "port %hu", port);
logmsg("Running %s %s version on %s",
- use_gopher?"GOPHER":"HTTP", socket_type, location_str);
+ protocol_type, socket_type, location_str);
/* start accepting connections */
rc = listen(sock, 5);
}
}
- msnprintf(loglockfile, sizeof(loglockfile), "%s/%s",
- logdir, SERVERLOGS_LOCK);
+ msnprintf(loglockfile, sizeof(loglockfile), "%s/%s/tftp-%s.lock",
+ logdir, SERVERLOGS_LOCKDIR, ipv_inuse);
#ifdef WIN32
win32_init();
#define TEST_DATA_PATH "%s/data/test%ld"
#define ALTTEST_DATA_PATH "%s/test%ld"
-
-#define SERVERLOGS_LOCK "serverlogs.lock"
+#define SERVERLOGS_LOCKDIR "lock" /* within logdir */
/* global variable, where to find the 'data' dir */
extern const char *path;