my $USER; # name of the current user
my $sshdid; # for socks server, ssh daemon version id
my $ftpchecktime=1; # time it took to verify our test FTP server
+my $SERVER_TIMEOUT_SEC = 15; # time for a server to spin up
# Variables shared with runtests.pl
our $SOCKSIN="socksd-request.log"; # what curl sent to the SOCKS proxy
my $pid2 = 0;
my $count = $timeout;
while($count--) {
- $pid2 = pidfromfile($pidfile);
+ $pid2 = pidfromfile($pidfile, 0);
if(($pid2 > 0) && pidexists($pid2)) {
# if $pid2 is valid, then make sure this pid is alive, as
# otherwise it is just likely to be the _previous_ pidfile or
$flags .= "--srcdir \"$srcdir\"";
my $cmd = "$exe $flags";
+
+ unlink($portfile); # need to see a new one
my ($httppid, $pid2) = startnew($cmd, $pidfile, 15, 0);
if($httppid <= 0 || !pidexists($httppid)) {
# where is it?
my $port = 0;
- my $waits = 0;
- # wait at max 15 seconds to the port file to become valid
- while(!$port_or_path && ($waits < (15 * 10))) {
- $port = $port_or_path = pidfromfile($portfile);
- Time::HiRes::sleep(0.1) unless $port_or_path;
- ++$waits;
- }
+ $port = $port_or_path = pidfromfile($portfile, $SERVER_TIMEOUT_SEC);
if(!$port) {
- logmsg "RUN: failed waiting for server to produce port file $portfile\n";
+ logmsg "RUN: timeout for $srvrname to produce port file $portfile\n";
+ stopserver($server, "$pid2");
+ $doesntrun{$pidfile} = 1;
return (1, 0, 0, 0);
}
$flags .= "--id $idnum " if($idnum > 1);
$flags .= "--ipv$ipvnum --port 0 --addr \"$ip\"";
+ unlink($portfile); # need to see a new one
my $cmd = "$perl " . shell_quote("$srcdir/ftpserver.pl") . " " . $flags;
my ($ftppid, $pid2) = startnew($cmd, $pidfile, 15, 0);
}
# where is it?
- my $port = pidfromfile($portfile);
+ my $port = pidfromfile($portfile, $SERVER_TIMEOUT_SEC);
+ if(!$port) {
+ logmsg "RUN: timeout for $srvrname to produce port file $portfile\n";
+ stopserver($server, "$pid2");
+ $doesntrun{$pidfile} = 1;
+ return (1, 0, 0, 0);
+ }
logmsg "PINGPONG runs on port $port ($portfile)\n" if($verb);
$flags .= "--id $idnum " if($idnum > 1);
$flags .= "--ipv$ipvnum --port 0 --srcdir \"$srcdir\"";
+ unlink($portfile); # need to see a new one
my $cmd = "$perl " . shell_quote("$srcdir/tftpserver.pl") . " " . $flags;
my ($tftppid, $pid2) = startnew($cmd, $pidfile, 15, 0);
return (1, 0, 0, 0);
}
- my $port = pidfromfile($portfile);
+ my $port = pidfromfile($portfile, $SERVER_TIMEOUT_SEC);
+ if(!$port) {
+ logmsg "RUN: timeout for $srvrname to produce port file $portfile\n";
+ stopserver($server, "$pid2");
+ $doesntrun{$pidfile} = 1;
+ return (1, 0, 0, 0);
+ }
if($verb) {
logmsg "RUN: $srvrname server on PID $tftppid port $port\n";
$cmd .= " --id $idnum" if($idnum > 1);
$cmd .= " --ipv$ipvnum";
+ unlink($portfile); # need to see a new one
# start DNS server on a random port
my ($dnspid, $pid2) = startnew($cmd, $pidfile, 15, 0);
return (1, 0, 0, 0);
}
- my $port = pidfromfile($portfile);
+ my $port = pidfromfile($portfile, $SERVER_TIMEOUT_SEC);
+ if(!$port) {
+ logmsg "RUN: timeout for $srvrname to produce port file $portfile\n";
+ stopserver($server, "$pid2");
+ $doesntrun{$pidfile} = 1;
+ return (1, 0, 0, 0);
+ }
if($verb) {
logmsg "RUN: $srvrname server on PID $dnspid port $port\n";
$flags .= "--id $idnum " if($idnum > 1);
$flags .= "--ipv$ipvnum --port 0 --srcdir \"$srcdir\"";
+ unlink($portfile); # need to see a new one
my $cmd = "$perl " . shell_quote("$srcdir/rtspserver.pl") . " " . $flags;
my ($rtsppid, $pid2) = startnew($cmd, $pidfile, 15, 0);
return (1, 0, 0, 0);
}
- my $port = pidfromfile($portfile);
+ my $port = pidfromfile($portfile, $SERVER_TIMEOUT_SEC);
+ if(!$port) {
+ logmsg "RUN: timeout for $srvrname to produce port file $portfile\n";
+ stopserver($server, "$pid2");
+ $doesntrun{$pidfile} = 1;
+ return (1, 0, 0, 0);
+ }
if($verb) {
logmsg "RUN: $srvrname server PID $rtsppid port $port\n";
my $srvrname = servername_str($proto, $ipvnum, $idnum);
my $logfile = server_logfilename($LOGDIR, $proto, $ipvnum, $idnum);
+ unlink($portfile); # need to see a new one
# start our MQTT server - on a random port!
my $cmd=server_exe('mqttd').
" --port 0".
return (1, 0, 0);
}
- my $mqttport = pidfromfile($portfile);
+ my $mqttport = pidfromfile($portfile, $SERVER_TIMEOUT_SEC);
+ if(!$mqttport) {
+ logmsg "RUN: timeout for $srvrname to produce port file $portfile\n";
+ stopserver($server, "$pid2");
+ $doesntrun{$pidfile} = 1;
+ return (1, 0, 0, 0);
+ }
if($verb) {
logmsg "RUN: $srvrname server is now running PID $pid2 on PORT $mqttport\n";
my $portfile = $serverportfile{$server};
my $logfile = server_logfilename($LOGDIR, $proto, $ipvnum, $idnum);
+ unlink($portfile); # need to see a new one
# start our socks server, get commands from the FTP cmd file
my $cmd="";
if($is_unix) {
" --unix-socket $SOCKSUNIXPATH".
" --backend $HOSTIP".
" --config $LOGDIR/$SERVERCMD";
+ $portfile = "none";
} else {
$cmd=server_exe('socksd').
" --port 0".
return (1, 0, 0, 0);
}
- my $port = pidfromfile($portfile);
+ my $port = 0;
+ if($portfile ne "none") {
+ $port = pidfromfile($portfile, $SERVER_TIMEOUT_SEC);
+ if(!$port) {
+ logmsg "RUN: timeout for $srvrname to produce port file $portfile\n";
+ stopserver($server, "$pid2");
+ $doesntrun{$pidfile} = 1;
+ return (1, 0, 0, 0);
+ }
+ }
if($verb) {
logmsg "RUN: $srvrname server is now running PID $pid2\n";