From 81d484326b25ee585d1b9176475ef24db433e77c Mon Sep 17 00:00:00 2001 From: Christopher Faulet <cfaulet@haproxy.com> Date: Mon, 19 Nov 2018 21:22:43 +0100 Subject: [PATCH] BUG/MINOR: mux-h1: Enable keep-alive on server side Don't force the close on server side anymore. Since commit 7c6f8b146 ("MAJOR: connections: Detach connections from streams"), it is possible to release a stream without the underlying connection. Because of this change, we must be sure to create a new stream to handle the next HTTP transaction only on the client side. And we must be sure to correctly handle the read0 event in h1_recv, to be sure to call h1_process(). --- src/mux_h1.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/mux_h1.c b/src/mux_h1.c index cbbcd90aa..66d12cc56 100644 --- a/src/mux_h1.c +++ b/src/mux_h1.c @@ -613,10 +613,6 @@ static void h1_set_srv_conn_mode(struct h1s *h1s, struct h1m *h1m) /* If KAL, check if the backend is stopping. If yes, switch in CLO mode */ if (h1s->flags & H1S_F_WANT_KAL && be->state == PR_STSTOPPED) h1s->flags = (h1s->flags & ~H1S_F_WANT_MSK) | H1S_F_WANT_CLO; - - /* TODO: For now on the server-side, we disable keep-alive */ - if (h1s->flags & H1S_F_WANT_KAL) - h1s->flags = (h1s->flags & ~H1S_F_WANT_MSK) | H1S_F_WANT_CLO; } static void h1_update_req_conn_hdr(struct h1s *h1s, struct h1m *h1m, @@ -1351,6 +1347,8 @@ static int h1_recv(struct h1c *h1c) if (h1_recv_allowed(h1c)) conn->xprt->subscribe(conn, SUB_CAN_RECV, &h1c->wait_event); + else + rcvd = 1; end: if (!b_data(&h1c->ibuf)) @@ -1462,7 +1460,7 @@ static int h1_process(struct h1c * h1c) conn->flags & CO_FL_ERROR || conn_xprt_read0_pending(conn)) goto release; - if (!(h1c->flags & (H1C_F_CS_SHUTW_NOW|H1C_F_CS_SHUTW))) { + if (!conn_is_back(conn) && !(h1c->flags & (H1C_F_CS_SHUTW_NOW|H1C_F_CS_SHUTW))) { if (!h1s_create(h1c, NULL)) goto release; } @@ -1486,7 +1484,7 @@ static struct task *h1_io_cb(struct task *t, void *ctx, unsigned short status) ret = h1_send(h1c); if (!(h1c->wait_event.wait_reason & SUB_CAN_RECV)) ret |= h1_recv(h1c); - if (ret/* || b_data(&h1c->ibuf)*/) + if (ret || !h1c->h1s) h1_process(h1c); return NULL; }