]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: connection: add cs_close() to close a conn_stream
authorWilly Tarreau <w@1wt.eu>
Thu, 5 Oct 2017 16:19:43 +0000 (18:19 +0200)
committerWilly Tarreau <w@1wt.eu>
Tue, 31 Oct 2017 17:03:24 +0000 (18:03 +0100)
This basically calls cs_shutw() followed by cs_shutr(). Both of them
are called in the most conservative mode so that any previous call is
still respected. The CS flags are cleared so that it can be reused
(this is important for connection retries when conn and CS are reused
without being reallocated).

include/proto/connection.h

index 1ce0b05371e0adea151e7e30d6c27a1539e64345..cae5dc34357caf6f7d7d0f70b1f2c2519d4d0365 100644 (file)
@@ -559,6 +559,14 @@ static inline void cs_shutw(struct conn_stream *cs, enum cs_shw_mode mode)
        cs->flags |= (mode == CS_SHW_NORMAL) ? CS_FL_SHWN : CS_FL_SHWS;
 }
 
+/* completely close a conn_stream (but do not detach it) */
+static inline void cs_close(struct conn_stream *cs)
+{
+       cs_shutw(cs, CS_SHW_SILENT);
+       cs_shutr(cs, CS_SHR_RESET);
+       cs->flags = CS_FL_NONE;
+}
+
 /* detect sock->data read0 transition */
 static inline int conn_xprt_read0_pending(struct connection *c)
 {