From: Willy Tarreau Date: Fri, 15 Sep 2017 09:01:04 +0000 (+0200) Subject: MINOR: peers: don't reference the incoming listener on outgoing connections X-Git-Tag: v1.8-dev3~100 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=04b928693322932339840bcd3c5772263488d5e5;p=thirdparty%2Fhaproxy.git MINOR: peers: don't reference the incoming listener on outgoing connections Since v1.7 it's pointless to reference a listener when greating a session for an outgoing connection, it only complicates the code. SPOE and Lua were cleaned up in 1.8-dev1 but the peers code was forgotten. This patch fixes this by not assigning such a listener for outgoing connections. It also has the extra benefit of not discounting the outgoing connections from the number of allowed incoming connections (the code currently adds a safety marging of 3 extra connections to take care of this). --- diff --git a/src/peers.c b/src/peers.c index d03e72fef0..8fb3b78ae8 100644 --- a/src/peers.c +++ b/src/peers.c @@ -1779,8 +1779,7 @@ void peers_setup_frontend(struct proxy *fe) */ static struct appctx *peer_session_create(struct peers *peers, struct peer *peer) { - struct listener *l = LIST_NEXT(&peers->peers_fe->conf.listeners, struct listener *, by_fe); - struct proxy *p = l->bind_conf->frontend; /* attached frontend */ + struct proxy *p = peers->peers_fe; /* attached frontend */ struct appctx *appctx; struct session *sess; struct stream *s; @@ -1797,7 +1796,7 @@ static struct appctx *peer_session_create(struct peers *peers, struct peer *peer appctx->st0 = PEER_SESS_ST_CONNECT; appctx->ctx.peers.ptr = (void *)peer; - sess = session_new(p, l, &appctx->obj_type); + sess = session_new(p, NULL, &appctx->obj_type); if (!sess) { Alert("out of memory in peer_session_create().\n"); goto out_free_appctx; @@ -1836,11 +1835,8 @@ static struct appctx *peer_session_create(struct peers *peers, struct peer *peer s->res.flags |= CF_READ_DONTWAIT; - l->nbconn++; /* warning! right now, it's up to the handler to decrease this */ p->feconn++;/* beconn will be increased later */ jobs++; - if (!(s->sess->listener->options & LI_O_UNLIMITED)) - actconn++; totalconn++; peer->appctx = appctx;