From: Willy Tarreau Date: Wed, 3 Oct 2018 08:33:02 +0000 (+0200) Subject: MINOR: h2: retrieve the front proxy from the caller instead of the session X-Git-Tag: v1.9-dev4~51 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=0b37d658e6bb14134581358b210b4b66d5373202;p=thirdparty%2Fhaproxy.git MINOR: h2: retrieve the front proxy from the caller instead of the session 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. --- diff --git a/src/mux_h2.c b/src/mux_h2.c index fc34f7cc54..c504935c07 100644 --- a/src/mux_h2.c +++ b/src/mux_h2.c @@ -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.