webfs: keep up to 4 connections per peer in pool
This commit is contained in:
parent
7f8fc0c5b4
commit
ff7d9ab525
1 changed files with 6 additions and 3 deletions
|
@ -37,6 +37,7 @@ struct Hpool
|
||||||
int active;
|
int active;
|
||||||
|
|
||||||
int limit;
|
int limit;
|
||||||
|
int peer;
|
||||||
int idle;
|
int idle;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -49,6 +50,7 @@ struct Hauth
|
||||||
|
|
||||||
static Hpool hpool = {
|
static Hpool hpool = {
|
||||||
.limit = 16,
|
.limit = 16,
|
||||||
|
.peer = 4,
|
||||||
.idle = 5, /* seconds */
|
.idle = 5, /* seconds */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -128,16 +130,17 @@ static void
|
||||||
hclose(Hconn *h)
|
hclose(Hconn *h)
|
||||||
{
|
{
|
||||||
Hconn *x, *t;
|
Hconn *x, *t;
|
||||||
int i;
|
int i, n;
|
||||||
|
|
||||||
if(h == nil)
|
if(h == nil)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
qlock(&hpool);
|
qlock(&hpool);
|
||||||
if(h->keep && h->fd >= 0){
|
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)
|
if(strcmp(x->addr, h->addr) == 0)
|
||||||
break;
|
if(++n > hpool.peer)
|
||||||
|
break;
|
||||||
if(++i < hpool.limit)
|
if(++i < hpool.limit)
|
||||||
t = x;
|
t = x;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue