BUG/MINOR: mux-h1: Properly handle http-request and http-keep-alive timeouts

It is now the turn for the H1 mux to be fix to properly handle http-request
and http-keep-alive timeouts. It is quite surprising but it is broken since
the 2.2. For idle connections on client side, the smallest value between the
client timeout and the http-request/http-keep-alive timeout is used while
the client timeout should only be used if other ones are not defined. So, if
the client timeout is the smallest value, the keep-alive timeout is not
respected.

It is only an issue for idle client connections. The http-request timeout is
respected from the moment part of the next request was received.

This patch should fix the issue #2334. It must be backported as far as 2.2. But
be careful during the backports. The H1 mux had evolved a lot since the 2.2.

(cherry picked from commit 2c9c2f9d77b9dac5a32d33838c5bca67f61fb1f5)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit bc378bb1938149ec16cf5975577297e98697f415)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 5ce99b07e5a7fa08e43045a2daebdad18bb032c0)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 91bc63f208419193fb27368f358c3c3532f2cb77)
[cf: is_idle_conn variable was removed]
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
diff --git a/src/mux_h1.c b/src/mux_h1.c
index 1324c20..c16caf0 100644
--- a/src/mux_h1.c
+++ b/src/mux_h1.c
@@ -515,6 +515,11 @@
 			h1c->task->expire = tick_add(now_ms, h1c->timeout);
 			TRACE_DEVEL("refreshing connection's timeout (pending outgoing data)", H1_EV_H1C_SEND|H1_EV_H1C_RECV, h1c->conn);
 		}
+		else if ((h1c->flags & (H1C_F_IS_BACK|H1C_F_ST_IDLE)) == H1C_F_ST_IDLE) {
+			/* idle front connections. */
+			h1c->task->expire = (tick_isset(h1c->idle_exp) ? h1c->idle_exp : tick_add(now_ms, h1c->timeout));
+			TRACE_DEVEL("refreshing connection's timeout (idle front h1c)", H1_EV_H1C_SEND|H1_EV_H1C_RECV, h1c->conn);
+		}
 		else if (!(h1c->flags & (H1C_F_IS_BACK|H1C_F_ST_READY))) {
 			/* front connections waiting for a fully usable stream need a timeout. */
 			h1c->task->expire = tick_add(now_ms, h1c->timeout);