]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MEDIUM: mux: Add an optional "reset" method.
authorOlivier Houchard <ohouchard@haproxy.com>
Tue, 11 Dec 2018 15:47:14 +0000 (16:47 +0100)
committerWilly Tarreau <w@1wt.eu>
Thu, 13 Dec 2018 16:32:15 +0000 (17:32 +0100)
Add a new method to mux, "reset", that is used to let the mux know the
connection attempt failed, and we're about to retry, so it just have to
reinit itself. Currently only the H1 mux needs it.

include/types/connection.h
src/backend.c
src/mux_h1.c

index 27c839f81fe87544da27487ab64fdb71aab299a8..bcc29650a75e8dc4a947752511fe361ee43073e7 100644 (file)
@@ -337,6 +337,7 @@ struct mux_ops {
        int (*avail_streams)(struct connection *conn); /* Returns the number of streams still available for a connection */
        int (*max_streams)(struct connection *conn);   /* Returns the max number of streams available for that connection. */
        void (*destroy)(struct connection *conn); /* Let the mux know one of its users left, so it may have to disappear */
+       void (*reset)(struct connection *conn); /* Reset the mux, because we're re-trying to connect */
        const struct cs_info *(*get_cs_info)(struct conn_stream *cs); /* Return info on the specified conn_stream or NULL if not defined */
        unsigned int flags;                           /* some flags characterizing the mux's capabilities (MX_FL_*) */
        char name[8];                                 /* mux layer name, zero-terminated */
index f494773108911f2543b2e28bde631837a760279b..34a04c35b358631dab217f23fa0e4ba33b16e32a 100644 (file)
@@ -1293,7 +1293,7 @@ int connect_server(struct stream *s)
                        return SF_ERR_INTERNAL;
        }
 
-       if (!conn_xprt_ready(srv_conn)) {
+       if (!conn_xprt_ready(srv_conn) && !srv_conn->mux) {
                /* the target was only on the stream, assign it to the SI now */
                srv_conn->target = s->target;
 
@@ -1361,6 +1361,10 @@ int connect_server(struct stream *s)
 
                assign_tproxy_address(s);
        }
+       else if (!conn_xprt_ready(srv_conn)) {
+               if (srv_conn->mux->reset)
+                       srv_conn->mux->reset(srv_conn);
+       }
        else
                s->flags |= SF_SRV_REUSED;
 
index da5d5c17e2e861e9b14fa32ec130f5842d431b9f..5ca3c28a0fc8dbb547d34b9a743352f552a38f89 100644 (file)
@@ -1824,6 +1824,13 @@ static struct task *h1_io_cb(struct task *t, void *ctx, unsigned short status)
        return NULL;
 }
 
+static void h1_reset(struct connection *conn)
+{
+       struct h1c *h1c = conn->mux_ctx;
+
+       /* Reset the flags, and let the mux know we're waiting for a connection */
+       h1c->flags = H1C_F_CS_WAIT_CONN;
+}
 
 static int h1_wake(struct connection *conn)
 {
@@ -2171,6 +2178,7 @@ const struct mux_ops mux_h1_ops = {
        .unsubscribe = h1_unsubscribe,
        .shutr       = h1_shutr,
        .shutw       = h1_shutw,
+       .reset       = h1_reset,
        .flags       = MX_FL_NONE,
        .name        = "h1",
 };