]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: stream: Make sure polling is right on retry.
authorOlivier Houchard <cognet@ci0.org>
Sun, 21 Oct 2018 01:18:11 +0000 (03:18 +0200)
committerWilly Tarreau <w@1wt.eu>
Sun, 21 Oct 2018 03:55:32 +0000 (05:55 +0200)
When retrying to connect to a server, because the previous connection failed,
make sure if we subscribed to the previous connection, the polling flags will
be true for the new fd.

No backport is needed.

src/backend.c
src/stream.c

index b154b804571172a3d950db3d3cf46d7250102919..cbeadff0ef25fcc1cdb71aef5c6fb5c2582676a3 100644 (file)
@@ -1061,12 +1061,16 @@ int connect_server(struct stream *s)
        struct server *srv;
        int reuse = 0;
        int err;
+       void *send_wait = NULL, *recv_wait = NULL;
 
        srv = objt_server(s->target);
        srv_cs = objt_cs(s->si[1].end);
        srv_conn = cs_conn(srv_cs);
-       if (srv_conn)
+       if (srv_conn) {
                reuse = s->target == srv_conn->target;
+               send_wait = srv_conn->send_wait;
+               recv_wait = srv_conn->recv_wait;
+       }
 
        if (srv && !reuse) {
                old_cs = srv_cs;
@@ -1163,6 +1167,8 @@ int connect_server(struct stream *s)
                LIST_DEL(&srv_conn->list);
                LIST_INIT(&srv_conn->list);
        }
+       srv_conn->send_wait = send_wait;
+       srv_conn->recv_wait = recv_wait;
 
        if (!srv_cs)
                return SF_ERR_RESOURCE;
index 42a6c48c97e89ceb4ac3f3510634e5b11b85aaa5..7444115a47a88cebeea5a7aa966d36c1401d876c 100644 (file)
@@ -883,11 +883,22 @@ static void sess_update_stream_int(struct stream *s)
                srv = objt_server(s->target);
 
                if (conn_err == SF_ERR_NONE) {
+                       struct connection *conn;
+
+                       conn = cs_conn(objt_cs(si->end));
                        /* state = SI_ST_CON or SI_ST_EST now */
                        if (srv)
                                srv_inc_sess_ctr(srv);
                        if (srv)
                                srv_set_sess_last(srv);
+                       /* If we're retrying to connect to the server, and
+                        * somebody subscribed to recv or send events, we have
+                        * to make sure the polling is active on the new fd.
+                        */
+                       if (conn->send_wait)
+                               conn_xprt_want_send(conn);
+                       if (conn->recv_wait)
+                               conn_xprt_want_recv(conn);
                        return;
                }