summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@gmx.de>2012-04-01 02:09:57 +0200
committercinap_lenrek <cinap_lenrek@gmx.de>2012-04-01 02:09:57 +0200
commitff7d9ab52561605053e69dfa3d7e842318444c03 (patch)
treecb50b54b87f71dbf878c1197ecc59a24a573e828 /sys
parent7f8fc0c5b453d0ed3e66b7fdca168af9f88c8286 (diff)
webfs: keep up to 4 connections per peer in pool
Diffstat (limited to 'sys')
-rw-r--r--sys/src/cmd/webfs/http.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/sys/src/cmd/webfs/http.c b/sys/src/cmd/webfs/http.c
index 6bdf48868..e72d4856f 100644
--- a/sys/src/cmd/webfs/http.c
+++ b/sys/src/cmd/webfs/http.c
@@ -37,6 +37,7 @@ struct Hpool
int active;
int limit;
+ int peer;
int idle;
};
@@ -49,6 +50,7 @@ struct Hauth
static Hpool hpool = {
.limit = 16,
+ .peer = 4,
.idle = 5, /* seconds */
};
@@ -128,16 +130,17 @@ static void
hclose(Hconn *h)
{
Hconn *x, *t;
- int i;
+ int i, n;
if(h == nil)
return;
qlock(&hpool);
if(h->keep && h->fd >= 0){
- for(i = 0, t = nil, x = hpool.head; x; x = x->next){
+ for(n = 0, i = 0, t = nil, x = hpool.head; x; x = x->next){
if(strcmp(x->addr, h->addr) == 0)
- break;
+ if(++n > hpool.peer)
+ break;
if(++i < hpool.limit)
t = x;
}