mirror of
https://github.com/moparisthebest/curl
synced 2024-12-22 16:18:48 -05:00
Wait longer for servers to start up since the ssh server needs to generate
keys the first time (which can take a while on a slow or loaded host). Enforce a longer startup wait time for the ssh client SOCKS server, too. Check for an error code from startnew() when starting any server.
This commit is contained in:
parent
1e718a515a
commit
c45d44fee9
@ -290,7 +290,7 @@ sub startnew {
|
|||||||
print OUT $child . "\n";
|
print OUT $child . "\n";
|
||||||
close(OUT);
|
close(OUT);
|
||||||
# could/should do a while connect fails sleep a bit and loop
|
# could/should do a while connect fails sleep a bit and loop
|
||||||
sleep 2;
|
sleep 5;
|
||||||
if (checkdied($child)) {
|
if (checkdied($child)) {
|
||||||
logmsg "startnew: Warning: child process has failed to start\n" if($verbose);
|
logmsg "startnew: Warning: child process has failed to start\n" if($verbose);
|
||||||
return (-1,-1);
|
return (-1,-1);
|
||||||
@ -607,7 +607,9 @@ sub verifysocks {
|
|||||||
|
|
||||||
#######################################################################
|
#######################################################################
|
||||||
# Verify that the server that runs on $ip, $port is our server.
|
# Verify that the server that runs on $ip, $port is our server.
|
||||||
# Retry during 5 seconds before giving up.
|
# Retry over several seconds before giving up. The ssh server in
|
||||||
|
# particular can take a long time to start if it needs to generate
|
||||||
|
# keys on a slow or loaded host.
|
||||||
#
|
#
|
||||||
|
|
||||||
my %protofunc = ('http' => \&verifyhttp,
|
my %protofunc = ('http' => \&verifyhttp,
|
||||||
@ -621,7 +623,7 @@ my %protofunc = ('http' => \&verifyhttp,
|
|||||||
sub verifyserver {
|
sub verifyserver {
|
||||||
my ($proto, $ip, $port) = @_;
|
my ($proto, $ip, $port) = @_;
|
||||||
|
|
||||||
my $count = 5; # try for this many seconds
|
my $count = 30; # try for this many seconds
|
||||||
my $pid;
|
my $pid;
|
||||||
|
|
||||||
while($count--) {
|
while($count--) {
|
||||||
@ -676,7 +678,7 @@ sub runhttpserver {
|
|||||||
my ($httppid, $pid2) =
|
my ($httppid, $pid2) =
|
||||||
startnew($cmd, $pidfile,0); # start the server in a new process
|
startnew($cmd, $pidfile,0); # start the server in a new process
|
||||||
|
|
||||||
if(!kill(0, $httppid)) {
|
if($httppid <= 0 || !kill(0, $httppid)) {
|
||||||
# it is NOT alive
|
# it is NOT alive
|
||||||
logmsg "RUN: failed to start the HTTP server\n";
|
logmsg "RUN: failed to start the HTTP server\n";
|
||||||
stopservers($verbose);
|
stopservers($verbose);
|
||||||
@ -730,7 +732,7 @@ sub runhttpsserver {
|
|||||||
|
|
||||||
my ($httpspid, $pid2) = startnew($cmd, $HTTPSPIDFILE,0);
|
my ($httpspid, $pid2) = startnew($cmd, $HTTPSPIDFILE,0);
|
||||||
|
|
||||||
if(!kill(0, $httpspid)) {
|
if($httpspid <= 0 || !kill(0, $httpspid)) {
|
||||||
# it is NOT alive
|
# it is NOT alive
|
||||||
logmsg "RUN: failed to start the HTTPS server\n";
|
logmsg "RUN: failed to start the HTTPS server\n";
|
||||||
stopservers($verbose);
|
stopservers($verbose);
|
||||||
@ -796,7 +798,7 @@ sub runftpserver {
|
|||||||
|
|
||||||
my ($ftppid, $pid2) = startnew($cmd, $pidfile,0);
|
my ($ftppid, $pid2) = startnew($cmd, $pidfile,0);
|
||||||
|
|
||||||
if(!$ftppid || !kill(0, $ftppid)) {
|
if($ftppid <= 0 || !kill(0, $ftppid)) {
|
||||||
# it is NOT alive
|
# it is NOT alive
|
||||||
logmsg "RUN: failed to start the FTP$id$nameext server\n";
|
logmsg "RUN: failed to start the FTP$id$nameext server\n";
|
||||||
return -1;
|
return -1;
|
||||||
@ -849,7 +851,7 @@ sub runftpsserver {
|
|||||||
|
|
||||||
my ($ftpspid, $pid2) = startnew($cmd, $FTPSPIDFILE,0);
|
my ($ftpspid, $pid2) = startnew($cmd, $FTPSPIDFILE,0);
|
||||||
|
|
||||||
if(!kill(0, $ftpspid)) {
|
if($ftpspid <= 0 || !kill(0, $ftpspid)) {
|
||||||
# it is NOT alive
|
# it is NOT alive
|
||||||
logmsg "RUN: failed to start the FTPS server\n";
|
logmsg "RUN: failed to start the FTPS server\n";
|
||||||
stopservers($verbose);
|
stopservers($verbose);
|
||||||
@ -915,7 +917,7 @@ sub runtftpserver {
|
|||||||
|
|
||||||
my ($tftppid, $pid2) = startnew($cmd, $pidfile,0);
|
my ($tftppid, $pid2) = startnew($cmd, $pidfile,0);
|
||||||
|
|
||||||
if(!$tftppid || !kill(0, $tftppid)) {
|
if($tftppid <= 0 || !kill(0, $tftppid)) {
|
||||||
# it is NOT alive
|
# it is NOT alive
|
||||||
logmsg "RUN: failed to start the FTP$id$nameext server\n";
|
logmsg "RUN: failed to start the FTP$id$nameext server\n";
|
||||||
return -1;
|
return -1;
|
||||||
@ -958,7 +960,7 @@ sub runsshserver {
|
|||||||
my ($sshpid, $pid2) =
|
my ($sshpid, $pid2) =
|
||||||
startnew($cmd, $pidfile,0); # start the server in a new process
|
startnew($cmd, $pidfile,0); # start the server in a new process
|
||||||
|
|
||||||
if(!$sshpid || !kill(0, $sshpid)) {
|
if($sshpid <= 0 || !kill(0, $sshpid)) {
|
||||||
# it is NOT alive
|
# it is NOT alive
|
||||||
logmsg "RUN: failed to start the SSH server\n";
|
logmsg "RUN: failed to start the SSH server\n";
|
||||||
# failed to talk to it properly. Kill the server and return failure
|
# failed to talk to it properly. Kill the server and return failure
|
||||||
@ -2261,7 +2263,7 @@ sub startservers {
|
|||||||
if (!checkcmd("ssh")) {
|
if (!checkcmd("ssh")) {
|
||||||
return "failed to find SSH client for socks support";
|
return "failed to find SSH client for socks support";
|
||||||
}
|
}
|
||||||
if ($what eq "socks5") {
|
if(!$run{'socks'}) {
|
||||||
my $sshversion=`ssh -V 2>&1`;
|
my $sshversion=`ssh -V 2>&1`;
|
||||||
if ($sshversion =~ /SSH_(\d+)\.(\d+)/i) {
|
if ($sshversion =~ /SSH_(\d+)\.(\d+)/i) {
|
||||||
if ($1*10+$2 < 37) {
|
if ($1*10+$2 < 37) {
|
||||||
@ -2271,8 +2273,7 @@ sub startservers {
|
|||||||
} else {
|
} else {
|
||||||
return "Unsupported ssh client\n";
|
return "Unsupported ssh client\n";
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if(!$run{'socks'}) {
|
|
||||||
($pid, $pid2) = runsocksserver("", $verbose);
|
($pid, $pid2) = runsocksserver("", $verbose);
|
||||||
if($pid <= 0) {
|
if($pid <= 0) {
|
||||||
return "failed starting socks server";
|
return "failed starting socks server";
|
||||||
|
Loading…
Reference in New Issue
Block a user