mirror of
https://github.com/opnsense/src.git
synced 2026-06-08 16:22:46 -04:00
Attempt to untangle the timeout code a bit, also make the default ftp
and http timeouts the same, since when using a http proxy to do ftp transfers, the http timeout was being used for what is coming in via ftp.
This commit is contained in:
parent
02fa2cc705
commit
a43a248c32
2 changed files with 35 additions and 20 deletions
|
|
@ -1,4 +1,4 @@
|
|||
.\" $Id: fetch.1,v 1.6 1996/08/23 00:55:57 mpp Exp $
|
||||
.\" $Id: fetch.1,v 1.7 1996/08/31 22:03:00 jkh Exp $
|
||||
.Dd July 2, 1996
|
||||
.Dt FETCH 1
|
||||
.Os
|
||||
|
|
@ -81,9 +81,11 @@ to copy it.
|
|||
.It Fl T Ar seconds
|
||||
Set timeout value to
|
||||
.Ar seconds.
|
||||
Overrides
|
||||
Overrides the environment variables
|
||||
.Ev FTP_TIMEOUT
|
||||
environment variable, if set.
|
||||
for ftp transfers or
|
||||
.Ev HTTP_TIMEOUT
|
||||
for http transfers if set.
|
||||
.It Fl q
|
||||
Quiet mode. Do not report transfer progress on the terminal.
|
||||
.It Fl v
|
||||
|
|
@ -105,7 +107,7 @@ A transfer using the
|
|||
.Em http
|
||||
protocol will be aborted after the delay specified by the
|
||||
.Ev HTTP_TIMEOUT
|
||||
variable. The default is 60 (seconds)
|
||||
variable. The default is 300 (seconds)
|
||||
|
||||
.Ev FTP_LOGIN
|
||||
is the login name for the remote host. Default is
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@
|
|||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/* $Id: main.c,v 1.21 1996/09/10 19:49:41 jkh Exp $ */
|
||||
/* $Id: main.c,v 1.22 1996/09/19 17:31:34 peter Exp $ */
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
|
|
@ -55,7 +55,7 @@
|
|||
#include <ftpio.h>
|
||||
|
||||
#define BUFFER_SIZE 1024
|
||||
#define HTTP_TIMEOUT 60 /* seconds */
|
||||
#define HTTP_TIMEOUT 300 /* seconds */
|
||||
#define FTP_TIMEOUT 300 /* seconds */
|
||||
|
||||
char buffer[BUFFER_SIZE];
|
||||
|
|
@ -284,6 +284,7 @@ ftpget()
|
|||
off_t size, size0, seekloc;
|
||||
char ftp_pw[200];
|
||||
time_t t;
|
||||
time_t tout;
|
||||
struct itimerval timer;
|
||||
|
||||
if ((cp = getenv("FTP_PASSWORD")) != NULL)
|
||||
|
|
@ -351,16 +352,23 @@ ftpget()
|
|||
|
||||
signal (SIGALRM, timeout);
|
||||
if (timeout_ival)
|
||||
timer.it_interval.tv_sec = timer.it_value.tv_sec = timeout_ival;
|
||||
tout = timeout_ival;
|
||||
else if ((cp = getenv("FTP_TIMEOUT")) != NULL)
|
||||
timer.it_interval.tv_sec = timer.it_value.tv_sec = atoi(cp);
|
||||
tout = atoi(cp);
|
||||
else
|
||||
timer.it_interval.tv_sec = timer.it_value.tv_sec = FTP_TIMEOUT;
|
||||
timer.it_interval.tv_usec = timer.it_value.tv_usec = 0;
|
||||
setitimer(ITIMER_REAL, &timer, 0);
|
||||
tout = FTP_TIMEOUT;
|
||||
|
||||
|
||||
timer.it_interval.tv_sec = 0; /* Reload value */
|
||||
timer.it_interval.tv_usec = 0;
|
||||
|
||||
timer.it_value.tv_sec = tout; /* One-Shot value */
|
||||
timer.it_value.tv_usec = 0;
|
||||
|
||||
display (size, size0);
|
||||
while (1) {
|
||||
setitimer(ITIMER_REAL, &timer, 0); /* reset timeout */
|
||||
|
||||
n = status = fread (buffer, 1, BUFFER_SIZE, fp);
|
||||
if (status <= 0)
|
||||
break;
|
||||
|
|
@ -368,10 +376,11 @@ ftpget()
|
|||
status = fwrite (buffer, 1, n, file);
|
||||
if (status != n)
|
||||
break;
|
||||
timer.it_interval.tv_sec = timer.it_value.tv_sec = FTP_TIMEOUT;
|
||||
timer.it_interval.tv_usec = timer.it_value.tv_usec = 0;
|
||||
setitimer(ITIMER_REAL, &timer, 0);
|
||||
}
|
||||
timer.it_value.tv_sec = 0;
|
||||
timer.it_value.tv_usec = 0;
|
||||
setitimer(ITIMER_REAL, &timer, 0); /* disable timeout */
|
||||
|
||||
if (status < 0)
|
||||
die(0);
|
||||
fclose(fp);
|
||||
|
|
@ -555,7 +564,8 @@ void
|
|||
httpget ()
|
||||
{
|
||||
char *cp, str[1000];
|
||||
struct timeval tout;
|
||||
struct timeval tv;
|
||||
time_t tout;
|
||||
fd_set fdset;
|
||||
int i, s;
|
||||
|
||||
|
|
@ -570,11 +580,12 @@ httpget ()
|
|||
|
||||
FD_ZERO (&fdset);
|
||||
FD_SET (s, &fdset);
|
||||
if ((cp = getenv("HTTP_TIMEOUT")) != NULL)
|
||||
tout.tv_sec = atoi(cp);
|
||||
if (timeout_ival)
|
||||
tout = timeout_ival;
|
||||
else if ((cp = getenv("HTTP_TIMEOUT")) != NULL)
|
||||
tout = atoi(cp);
|
||||
else
|
||||
tout.tv_sec = HTTP_TIMEOUT;
|
||||
tout.tv_usec = 0;
|
||||
tout = HTTP_TIMEOUT;
|
||||
|
||||
if (strcmp (outputfile, "-")) {
|
||||
file = fopen (outputfile, "w");
|
||||
|
|
@ -586,7 +597,9 @@ httpget ()
|
|||
}
|
||||
|
||||
while (1) {
|
||||
i = select (s+1, &fdset, 0, 0, &tout);
|
||||
tv.tv_sec = tout;
|
||||
tv.tv_usec = 0;
|
||||
i = select (s+1, &fdset, 0, 0, &tv);
|
||||
switch (i) {
|
||||
case 0:
|
||||
warnx ("Timeout");
|
||||
|
|
|
|||
Loading…
Reference in a new issue