From: Willy Tarreau Date: Wed, 3 Oct 2018 11:52:41 +0000 (+0200) Subject: MINOR: h2: unify the mux init function X-Git-Tag: v1.9-dev4~52 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=7dc24e49cc428354f355efdc333918f078103398;p=thirdparty%2Fhaproxy.git MINOR: h2: unify the mux init function The init function was split into the mux init and the front init, but it appears that most of the code will be common between the two sides when implementing the backend init. Thus let's simply make this a unique h2_init() function. --- diff --git a/src/mux_h2.c b/src/mux_h2.c index c380dc9afa..fc34f7cc54 100644 --- a/src/mux_h2.c +++ b/src/mux_h2.c @@ -349,13 +349,21 @@ static inline void h2_release_buf(struct h2c *h2c, struct buffer *bptr) /* functions below are dedicated to the mux setup and management */ /*****************************************************************/ -/* tries to initialize the inbound h2c mux. Returns < 0 in case of failure. */ -static int h2c_frt_init(struct connection *conn) +/* Initialize the mux once it's attached. For outgoing connections, the context + * is already initialized before installing the mux, so we detect incoming + * connections from the fact that the context is still NULL. Returns < 0 on + * error. + */ +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) + goto fail_no_h2c; + h2c = pool_alloc(pool_head_h2c); if (!h2c) goto fail_no_h2c; @@ -431,21 +439,6 @@ static int h2c_frt_init(struct connection *conn) return -1; } -/* Initialize the mux once it's attached. For outgoing connections, the context - * is already initialized before installing the mux, so we detect incoming - * connections from the fact that the context is still NULL. Returns < 0 on - * error. - */ -static int h2_init(struct connection *conn, struct proxy *prx) -{ - if (conn->mux_ctx) { - /* we don't support outgoing connections for now */ - return -1; - } - - return h2c_frt_init(conn); -} - /* returns the stream associated with id or NULL if not found */ static inline struct h2s *h2c_st_by_id(struct h2c *h2c, int id) {