diff options
author | cinap_lenrek <cinap_lenrek@gmx.de> | 2012-05-16 17:00:19 +0200 |
---|---|---|
committer | cinap_lenrek <cinap_lenrek@gmx.de> | 2012-05-16 17:00:19 +0200 |
commit | 4c16111e66763cf0b427082c4132b53e050d4ba2 (patch) | |
tree | 27904493de5cf7121354583fe859a2199ff058c5 /sys/src/cmd/webfs | |
parent | 595f9c4a09bedffab4d7f6dc95c7c7c2720412cb (diff) |
webfs: add global timeout parameter settable in rootctl and command line
Diffstat (limited to 'sys/src/cmd/webfs')
-rw-r--r-- | sys/src/cmd/webfs/dat.h | 1 | ||||
-rw-r--r-- | sys/src/cmd/webfs/fs.c | 29 | ||||
-rw-r--r-- | sys/src/cmd/webfs/http.c | 9 |
3 files changed, 30 insertions, 9 deletions
diff --git a/sys/src/cmd/webfs/dat.h b/sys/src/cmd/webfs/dat.h index 4235e48b3..a7fe76281 100644 --- a/sys/src/cmd/webfs/dat.h +++ b/sys/src/cmd/webfs/dat.h @@ -65,3 +65,4 @@ struct Buq int debug; Url *proxy; +int timeout; diff --git a/sys/src/cmd/webfs/fs.c b/sys/src/cmd/webfs/fs.c index 7f8530434..2d2c7c063 100644 --- a/sys/src/cmd/webfs/fs.c +++ b/sys/src/cmd/webfs/fs.c @@ -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); diff --git a/sys/src/cmd/webfs/http.c b/sys/src/cmd/webfs/http.c index 7ed7d5cc7..423aab124 100644 --- a/sys/src/cmd/webfs/http.c +++ b/sys/src/cmd/webfs/http.c @@ -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; |