webfs: add global timeout parameter settable in rootctl and command line
This commit is contained in:
parent
595f9c4a09
commit
4c16111e66
4 changed files with 37 additions and 10 deletions
|
@ -4,6 +4,12 @@ webfs \- world wide web file system
|
|||
.SH SYNOPSIS
|
||||
.B webfs
|
||||
[
|
||||
.B -A
|
||||
.I useragent
|
||||
] [
|
||||
.B -T
|
||||
.I timeout
|
||||
] [
|
||||
.B -m
|
||||
.I mtpt
|
||||
]
|
||||
|
@ -131,7 +137,7 @@ The resulting data may be read from
|
|||
as it arrives.
|
||||
.PP
|
||||
The following is a list of attributes that can be
|
||||
set to to a connection prior initiating the request:
|
||||
set to do a connection prior initiating the request:
|
||||
.TP
|
||||
.B url,baseurl
|
||||
See above.
|
||||
|
|
|
@ -65,3 +65,4 @@ struct Buq
|
|||
|
||||
int debug;
|
||||
Url *proxy;
|
||||
int timeout;
|
||||
|
|
|
@ -506,7 +506,7 @@ fsread(Req *r)
|
|||
respond(r, nil);
|
||||
return;
|
||||
case Qrctl:
|
||||
buf[0] = 0;
|
||||
snprint(buf, sizeof(buf), "useragent %s\ntimeout %d\n", agent, timeout);
|
||||
String:
|
||||
readstr(r, buf);
|
||||
respond(r, nil);
|
||||
|
@ -561,6 +561,16 @@ rootctl(char *ctl, char *arg)
|
|||
return nil;
|
||||
}
|
||||
|
||||
if(!strcmp(ctl, "timeout")){
|
||||
if(arg && *arg)
|
||||
timeout = atoi(arg);
|
||||
else
|
||||
timeout = 0;
|
||||
if(timeout < 0)
|
||||
timeout = 0;
|
||||
return nil;
|
||||
}
|
||||
|
||||
return "bad ctl message";
|
||||
}
|
||||
|
||||
|
@ -714,7 +724,7 @@ Srv fs =
|
|||
void
|
||||
usage(void)
|
||||
{
|
||||
fprint(2, "usage: %s [-D] [-m mtpt] [-s srv]\n", argv0);
|
||||
fprint(2, "usage: %s [-D] [-A useragent] [-T timeout] [-m mtpt] [-s srv]\n", argv0);
|
||||
exits("usage");
|
||||
}
|
||||
|
||||
|
@ -731,11 +741,21 @@ main(int argc, char *argv[])
|
|||
mtpt = "/mnt/web";
|
||||
user = getuser();
|
||||
time0 = time(0);
|
||||
timeout = 10000;
|
||||
agent = nil;
|
||||
|
||||
ARGBEGIN {
|
||||
case 'D':
|
||||
chatty9p++;
|
||||
break;
|
||||
case 'A':
|
||||
agent = EARGF(usage());
|
||||
break;
|
||||
case 'T':
|
||||
timeout = atoi(EARGF(usage()));
|
||||
if(timeout < 0)
|
||||
timeout = 0;
|
||||
break;
|
||||
case 'm':
|
||||
mtpt = EARGF(usage());
|
||||
break;
|
||||
|
@ -751,7 +771,10 @@ main(int argc, char *argv[])
|
|||
|
||||
rfork(RFNOTEG);
|
||||
|
||||
agent = estrdup("hjdicks");
|
||||
if(agent == nil)
|
||||
agent = "hjdicks";
|
||||
agent = estrdup(agent);
|
||||
|
||||
if(s = getenv("httpproxy")){
|
||||
proxy = saneurl(url(s, 0));
|
||||
free(s);
|
||||
|
|
|
@ -542,9 +542,8 @@ http(char *m, Url *u, Key *shdr, Buq *qbody, Buq *qpost)
|
|||
qunlock(qpost);
|
||||
}
|
||||
|
||||
/* give 10 seconds to dial */
|
||||
if(h == nil){
|
||||
alarm(10000);
|
||||
alarm(timeout);
|
||||
if((h = hdial(proxy ? proxy : u)) == nil)
|
||||
break;
|
||||
}
|
||||
|
@ -619,10 +618,8 @@ http(char *m, Url *u, Key *shdr, Buq *qbody, Buq *qpost)
|
|||
}
|
||||
/* no timeout when posting */
|
||||
alarm(0);
|
||||
} else {
|
||||
/* wait 20 seconds for the response */
|
||||
alarm(20000);
|
||||
}
|
||||
} else
|
||||
alarm(timeout);
|
||||
|
||||
Cont:
|
||||
rhdr = 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue