]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: peers: don't reference the incoming listener on outgoing connections
authorWilly Tarreau <w@1wt.eu>
Fri, 15 Sep 2017 09:01:04 +0000 (11:01 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 15 Sep 2017 09:01:04 +0000 (11:01 +0200)
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).

src/peers.c

index d03e72fef02cfcc438998637d974d92da18ead31..8fb3b78ae8c5971835c49d9b558dd0fe06faa4ed 100644 (file)
@@ -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;