ref: 6d354d07e81aa94b3798603093dfa26fac2f6488
parent: 1447b95555d6afa39f7ab04f04f1415f8937d899
author: cinap_lenrek <[email protected]>
date: Sun Sep 18 22:04:13 EDT 2016
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.
--- a/sys/src/cmd/webfs/http.c
+++ b/sys/src/cmd/webfs/http.c
@@ -92,7 +92,7 @@
}
static Hconn*
-hdial(Url *u)
+hdial(Url *u, int cached)
{
char addr[128];
Hconn *h, *p;
@@ -100,20 +100,22 @@
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 @@
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 @@
}
if(h == nil){
alarm(timeout);
- if((h = hdial(u)) == nil)
+ if((h = hdial(u, qpost!=nil)) == nil)
break;
}
if(h->tunnel){