From 6978db35e92ccf4777d040b92a4c1b2ef144f202 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Thu, 5 Oct 2017 18:19:43 +0200 Subject: [PATCH] MINOR: connection: add cs_close() to close a conn_stream 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 | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/include/proto/connection.h b/include/proto/connection.h index 1ce0b05371..cae5dc3435 100644 --- a/include/proto/connection.h +++ b/include/proto/connection.h @@ -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) {