1
0
mirror of https://github.com/moparisthebest/curl synced 2024-12-21 23:58:49 -05:00

When staring a HTTP server, use the pidfile preferably since it turns out

sometimes the server can start but curl cannot speak to it, and then we must
remember the server (in order to kill it properly) anyway.

Also, make sure to kill all servers on exit everywhere.
This commit is contained in:
Daniel Stenberg 2005-04-28 13:54:48 +00:00
parent f71b3676bb
commit 9e037431b4

View File

@ -304,9 +304,6 @@ sub torture {
print "torture OK\n";
return 0;
#stopservers();
#exit; # for now, we stop after these tests
}
#######################################################################
@ -362,7 +359,7 @@ sub runhttpserver {
my ($verbose, $ipv6) = @_;
my $RUNNING;
my $pid;
my $cmd;
my $pidfile = $HTTPPIDFILE;
my $port = $HTTPPORT;
my $ip = $HOSTIP;
@ -378,8 +375,10 @@ sub runhttpserver {
$pid = checkserver($pidfile);
if($pid <= 0 ) {
# verify if our/any server is running on this port
my $cmd = "$CURL -o log/verifiedserver -g \"http://$ip:$port/verifiedserver\" 2>log/verifyhttp";
$cmd = "$CURL -o log/verifiedserver -g \"http://$ip:$port/verifiedserver\" 2>log/verifyhttp";
print "CMD; $cmd\n" if ($verbose);
my $res = system($cmd);
@ -414,12 +413,14 @@ sub runhttpserver {
print "RUN: Unknown server is running on port $port\n";
return -2;
}
}
if($pid > 0) {
my $res = kill (9, $pid); # die!
if(!$res) {
print "RUN: Failed to kill test HTTP$nameext server, do it ",
"manually and restart the tests.\n";
stopservers();
exit;
}
sleep(1);
@ -441,6 +442,13 @@ sub runhttpserver {
# verify that our server is up and running:
my $data=`$CURL --silent -g \"$ip:$port/verifiedserver\" 2>>log/verifyhttp`;
$pid = checkserver($pidfile);
if($pid) {
print STDERR "RUN: got http server pid from pidfile\n" if($verbose);
$verified = 1;
last;
}
if ( $data =~ /WE ROOLZ: (\d+)/ ) {
$pid = 0+$1;
$verified = 1;
@ -1228,6 +1236,7 @@ sub singletest {
if($@) {
print "perl: $code\n";
print "precommand: $@";
stopservers();
exit;
}
}
@ -1400,6 +1409,7 @@ sub singletest {
my $filename=$hash{'name'};
if(!$filename) {
print "ERROR: section verify=>file has no name attribute!\n";
stopservers();
exit;
}
my $filemode=$hash{'mode'};
@ -1953,7 +1963,6 @@ foreach $testnum (@at) {
#
close(CMDLOG);
# Tests done, stop the servers
stopservers();