From 729c69f6e5c9098901d2242d86cf56bbf9ac6fe3 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Thu, 12 Mar 2015 22:51:10 +0100 Subject: [PATCH] MINOR: connection: perform the call to xprt->shutw() in conn_data_shutw() This will save callers from having to care about conn->xprt and xprt->shutw. Note that shutw() takes a second argument indicating whether it's a clean or a hard shutw. This is used by SSL which tries to close cleanly in most cases. Here we provide two versions, conn_data_shutw() which performs the clean close, and conn_data_shutw_hard() which does the unclean one. --- include/proto/connection.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/include/proto/connection.h b/include/proto/connection.h index fc97f1c33..5f80cc5ba 100644 --- a/include/proto/connection.h +++ b/include/proto/connection.h @@ -420,6 +420,20 @@ static inline void conn_data_shutw(struct connection *c) { c->flags |= CO_FL_DATA_WR_SH; __conn_data_stop_send(c); + + /* clean data-layer shutdown */ + if (c->xprt && c->xprt->shutw) + c->xprt->shutw(c, 1); +} + +static inline void conn_data_shutw_hard(struct connection *c) +{ + c->flags |= CO_FL_DATA_WR_SH; + __conn_data_stop_send(c); + + /* unclean data-layer shutdown */ + if (c->xprt && c->xprt->shutw) + c->xprt->shutw(c, 0); } /* detect sock->data read0 transition */