]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: h2: retrieve the front proxy from the caller instead of the session
authorWilly Tarreau <w@1wt.eu>
Wed, 3 Oct 2018 08:33:02 +0000 (10:33 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 12 Oct 2018 14:58:01 +0000 (16:58 +0200)
Till now in order to figure the timeouts, we used to retrieve the proxy
from the session's owner, but the new API provides it so it's better to
simply take it from the caller at init time. We take this opportunity to
store the pointer to the proxy into the h2 connection so that we can
reuse it later when needed.

src/mux_h2.c

index fc34f7cc548df8bb18d4de393e724df82138d8df..c504935c07e88686211e1360fa415d153a48b8bc 100644 (file)
@@ -115,6 +115,7 @@ struct h2c {
        int shut_timeout;   /* idle timeout duration in ticks after GOAWAY was sent */
        unsigned int nb_streams;  /* number of streams in the tree */
        unsigned int nb_cs;       /* number of attached conn_streams */
+       struct proxy *proxy; /* the proxy this connection was created for */
        struct task *task;  /* timeout management task */
        struct eb_root streams_by_id; /* all active streams by their ID */
        struct list send_list; /* list of blocked streams requesting to send */
@@ -358,7 +359,6 @@ static int h2_init(struct connection *conn, struct proxy *prx)
 {
        struct h2c *h2c;
        struct task *t = NULL;
-       struct session *sess = conn->owner;
 
        /* we don't support outgoing connections for now */
        if (conn->mux_ctx)
@@ -368,11 +368,11 @@ static int h2_init(struct connection *conn, struct proxy *prx)
        if (!h2c)
                goto fail_no_h2c;
 
+       h2c->shut_timeout = h2c->timeout = prx->timeout.client;
+       if (tick_isset(prx->timeout.clientfin))
+               h2c->shut_timeout = prx->timeout.clientfin;
 
-       h2c->shut_timeout = h2c->timeout = sess->fe->timeout.client;
-       if (tick_isset(sess->fe->timeout.clientfin))
-               h2c->shut_timeout = sess->fe->timeout.clientfin;
-
+       h2c->proxy = prx;
        h2c->task = NULL;
        if (tick_isset(h2c->timeout)) {
                t = task_new(tid_bit);
@@ -2357,7 +2357,6 @@ static struct task *h2_io_cb(struct task *t, void *ctx, unsigned short status)
 static int h2_process(struct h2c *h2c)
 {
        struct connection *conn = h2c->conn;
-       struct session *sess = conn->owner;
 
        if (b_data(&h2c->dbuf) && !(h2c->flags & H2_CF_DEM_BLOCK_ANY)) {
                h2_process_demux(h2c);
@@ -2370,7 +2369,7 @@ static int h2_process(struct h2c *h2c)
        }
        h2_send(h2c);
 
-       if (sess && unlikely(sess->fe->state == PR_STSTOPPED)) {
+       if (unlikely(h2c->proxy->state == PR_STSTOPPED)) {
                /* frontend is stopping, reload likely in progress, let's try
                 * to announce a graceful shutdown if not yet done. We don't
                 * care if it fails, it will be tried again later.