diff options
author | cinap_lenrek <cinap_lenrek@felloff.net> | 2016-09-19 02:04:13 +0200 |
---|---|---|
committer | cinap_lenrek <cinap_lenrek@felloff.net> | 2016-09-19 02:04:13 +0200 |
commit | 6d354d07e81aa94b3798603093dfa26fac2f6488 (patch) | |
tree | 65813aa50fa4bbfdb74fde6ca378b06340e9cbb8 /sys/src/cmd/webfs | |
parent | 1447b95555d6afa39f7ab04f04f1415f8937d899 (diff) |
webfs: don't use cache connections when posting
we cannot retry posts and we do not know for sure if a
post had any side effect when we got no status, so always
make a new connection for a post request.
Diffstat (limited to 'sys/src/cmd/webfs')
-rw-r--r-- | sys/src/cmd/webfs/http.c | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/sys/src/cmd/webfs/http.c b/sys/src/cmd/webfs/http.c index 5645bc94d..ef53e4e8a 100644 --- a/sys/src/cmd/webfs/http.c +++ b/sys/src/cmd/webfs/http.c @@ -92,7 +92,7 @@ tlswrap(int fd, char *servername) } static Hconn* -hdial(Url *u) +hdial(Url *u, int cached) { char addr[128]; Hconn *h, *p; @@ -100,20 +100,22 @@ hdial(Url *u) snprint(addr, sizeof(addr), "tcp!%s!%s", u->host, u->port ? u->port : u->scheme); - qlock(&hpool); - for(p = nil, h = hpool.head; h; p = h, h = h->next){ - if(strcmp(h->addr, addr) == 0){ - if(p) - p->next = h->next; - else - hpool.head = h->next; - h->next = nil; - qunlock(&hpool); - return h; + if(cached){ + qlock(&hpool); + for(p = nil, h = hpool.head; h; p = h, h = h->next){ + if(strcmp(h->addr, addr) == 0){ + if(p) + p->next = h->next; + else + hpool.head = h->next; + h->next = nil; + qunlock(&hpool); + return h; + } } + hpool.active++; + qunlock(&hpool); } - hpool.active++; - qunlock(&hpool); if(debug) fprint(2, "hdial [%d] %s\n", hpool.active, addr); @@ -142,7 +144,7 @@ hdial(Url *u) h->time = 0; h->cancel = 0; h->tunnel = 0; - h->keep = 1; + h->keep = cached; h->len = 0; h->fd = fd; h->ctl = ctl; @@ -643,7 +645,7 @@ http(char *m, Url *u, Key *shdr, Buq *qbody, Buq *qpost) } if(h == nil){ alarm(timeout); - if((h = hdial(u)) == nil) + if((h = hdial(u, qpost!=nil)) == nil) break; } if(h->tunnel){ |