diff --git a/Makefile b/Makefile index 212cb55a3..28de8a39d 100644 --- a/Makefile +++ b/Makefile @@ -935,7 +935,7 @@ OBJS += src/mux_h2.o src/mux_fcgi.o src/http_ana.o src/mux_h1.o \ src/base64.o src/uri_auth.o src/time.o src/ebsttree.o src/ebistree.o \ src/dynbuf.o src/auth.o src/wdt.o src/pipe.o src/http_acl.o \ src/hpack-huff.o src/hpack-enc.o src/dict.o src/init.o src/freq_ctr.o \ - src/ebtree.o src/hash.o src/dgram.o src/version.o + src/ebtree.o src/hash.o src/dgram.o src/version.o src/conn_stream.o ifneq ($(TRACE),) OBJS += src/calltrace.o diff --git a/include/haproxy/conn_stream-t.h b/include/haproxy/conn_stream-t.h new file mode 100644 index 000000000..bf0726032 --- /dev/null +++ b/include/haproxy/conn_stream-t.h @@ -0,0 +1,102 @@ +/* + * include/haproxy/conn_stream-t.h + * This file describes the conn-stream struct and associated constants. + * + * Copyright 2021 Christopher Faulet + * + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation, version 2.1 + * exclusively. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef _HAPROXY_CONN_STREAM_T_H +#define _HAPROXY_CONN_STREAM_T_H + +#include + +struct connection; + +/* conn_stream flags */ +enum { + CS_FL_NONE = 0x00000000, /* Just for initialization purposes */ + CS_FL_SHRD = 0x00000010, /* read shut, draining extra data */ + CS_FL_SHRR = 0x00000020, /* read shut, resetting extra data */ + CS_FL_SHR = CS_FL_SHRD | CS_FL_SHRR, /* read shut status */ + + CS_FL_SHWN = 0x00000040, /* write shut, verbose mode */ + CS_FL_SHWS = 0x00000080, /* write shut, silent mode */ + CS_FL_SHW = CS_FL_SHWN | CS_FL_SHWS, /* write shut status */ + + + CS_FL_ERROR = 0x00000100, /* a fatal error was reported */ + CS_FL_RCV_MORE = 0x00000200, /* We may have more bytes to transfer */ + CS_FL_WANT_ROOM = 0x00000400, /* More bytes to transfer, but not enough room */ + CS_FL_ERR_PENDING = 0x00000800, /* An error is pending, but there's still data to be read */ + CS_FL_EOS = 0x00001000, /* End of stream delivered to data layer */ + /* unused: 0x00002000 */ + CS_FL_EOI = 0x00004000, /* end-of-input reached */ + CS_FL_MAY_SPLICE = 0x00008000, /* caller may use rcv_pipe() only if this flag is set */ + CS_FL_WAIT_FOR_HS = 0x00010000, /* This stream is waiting for handhskae */ + CS_FL_KILL_CONN = 0x00020000, /* must kill the connection when the CS closes */ + + /* following flags are supposed to be set by the mux and read/unset by + * the stream-interface : + */ + CS_FL_NOT_FIRST = 0x00100000, /* this stream is not the first one */ + + /* flags set by the mux relayed to the stream */ + CS_FL_WEBSOCKET = 0x00200000, /* websocket stream */ +}; + +/* cs_shutr() modes */ +enum cs_shr_mode { + CS_SHR_DRAIN = 0, /* read shutdown, drain any extra stuff */ + CS_SHR_RESET = 1, /* read shutdown, reset any extra stuff */ +}; + +/* cs_shutw() modes */ +enum cs_shw_mode { + CS_SHW_NORMAL = 0, /* regular write shutdown */ + CS_SHW_SILENT = 1, /* imminent close, don't notify peer */ +}; + +struct conn_stream; + +/* data_cb describes the data layer's recv and send callbacks which are called + * when I/O activity was detected after the transport layer is ready. These + * callbacks are supposed to make use of the xprt_ops above to exchange data + * from/to buffers and pipes. The callback is used to report activity + * at the transport layer, which can be a connection opening/close, or any + * data movement. It may abort a connection by returning < 0. + */ +struct data_cb { + int (*wake)(struct conn_stream *cs); /* data-layer callback to report activity */ + char name[8]; /* data layer name, zero-terminated */ +}; + +/* + * This structure describes the elements of a connection relevant to a stream + */ +struct conn_stream { + enum obj_type obj_type; /* differentiates connection from applet context */ + /* 3 bytes hole here */ + unsigned int flags; /* CS_FL_* */ + struct connection *conn; /* xprt-level connection */ + void *data; /* pointer to upper layer's entity (eg: stream interface) */ + const struct data_cb *data_cb; /* data layer callbacks. Must be set before xprt->init() */ + void *ctx; /* mux-specific context */ +}; + + +#endif /* _HAPROXY_CONN_STREAM_T_H */ diff --git a/include/haproxy/conn_stream.h b/include/haproxy/conn_stream.h new file mode 100644 index 000000000..cd833b2f0 --- /dev/null +++ b/include/haproxy/conn_stream.h @@ -0,0 +1,165 @@ +/* + * include/haproxy/conn_stream.h + * This file contains conn-stream function prototypes + * + * Copyright 2021 Christopher Faulet + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation, version 2.1 + * exclusively. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef _HAPROXY_CONN_STREAM_H +#define _HAPROXY_CONN_STREAM_H + +#include +#include +#include +#include +#include + +extern struct pool_head *pool_head_connstream; + +#define IS_HTX_CS(cs) (IS_HTX_CONN((cs)->conn)) + +struct conn_stream *cs_new(struct connection *conn, void *target); +void cs_free(struct conn_stream *cs); + +/* + * Initializes all required fields for a new conn_strema. + */ +static inline void cs_init(struct conn_stream *cs, struct connection *conn) +{ + cs->obj_type = OBJ_TYPE_CS; + cs->flags = CS_FL_NONE; + cs->conn = conn; + cs->ctx = conn; +} + +/* Returns the conn from a cs. If cs is NULL, returns NULL */ +static inline struct connection *cs_conn(const struct conn_stream *cs) +{ + return cs ? cs->conn : NULL; +} + +/* Attaches a conn_stream to a data layer and sets the relevant callbacks */ +static inline void cs_attach(struct conn_stream *cs, void *data, const struct data_cb *data_cb) +{ + cs->data_cb = data_cb; + cs->data = data; +} + +/* Detach the conn_stream from the connection, if any. If a mux owns the + * connection ->detach() callback is called. Otherwise, it means the conn-stream + * owns the connection. In this case the connection is closed and released. The + * conn-stream is not released. + */ +static inline void cs_detach(struct conn_stream *cs) +{ + if (cs_conn(cs)) { + if (cs->conn->mux) + cs->conn->mux->detach(cs); + else { + /* It's too early to have a mux, let's just destroy + * the connection + */ + struct connection *conn = cs->conn; + + conn_stop_tracking(conn); + conn_full_close(conn); + if (conn->destroy_cb) + conn->destroy_cb(conn); + conn_free(conn); + } + } + cs_init(cs, NULL); +} + +/* Release a conn_stream */ +static inline void cs_destroy(struct conn_stream *cs) +{ + cs_detach(cs); + cs_free(cs); +} + +static inline const char *cs_get_data_name(const struct conn_stream *cs) +{ + if (!cs || !cs->data_cb) + return "NONE"; + return cs->data_cb->name; +} + +/* shut read */ +static inline void cs_shutr(struct conn_stream *cs, enum cs_shr_mode mode) +{ + if (!cs_conn(cs) || cs->flags & CS_FL_SHR) + return; + + /* clean data-layer shutdown */ + if (cs->conn->mux && cs->conn->mux->shutr) + cs->conn->mux->shutr(cs, mode); + cs->flags |= (mode == CS_SHR_DRAIN) ? CS_FL_SHRD : CS_FL_SHRR; +} + +/* shut write */ +static inline void cs_shutw(struct conn_stream *cs, enum cs_shw_mode mode) +{ + if (!cs_conn(cs) || cs->flags & CS_FL_SHW) + return; + + /* clean data-layer shutdown */ + if (cs->conn->mux && cs->conn->mux->shutw) + cs->conn->mux->shutw(cs, 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); +} + +/* completely close a conn_stream after draining possibly pending data (but do not detach it) */ +static inline void cs_drain_and_close(struct conn_stream *cs) +{ + cs_shutw(cs, CS_SHW_SILENT); + cs_shutr(cs, CS_SHR_DRAIN); +} + +/* sets CS_FL_ERROR or CS_FL_ERR_PENDING on the cs */ +static inline void cs_set_error(struct conn_stream *cs) +{ + if (cs->flags & CS_FL_EOS) + cs->flags |= CS_FL_ERROR; + else + cs->flags |= CS_FL_ERR_PENDING; +} + +/* Retrieves any valid conn_stream from this connection, preferably the first + * valid one. The purpose is to be able to figure one other end of a private + * connection for purposes like source binding or proxy protocol header + * emission. In such cases, any conn_stream is expected to be valid so the + * mux is encouraged to return the first one it finds. If the connection has + * no mux or the mux has no get_first_cs() method or the mux has no valid + * conn_stream, NULL is returned. The output pointer is purposely marked + * const to discourage the caller from modifying anything there. + */ +static inline const struct conn_stream *cs_get_first(const struct connection *conn) +{ + if (!conn || !conn->mux || !conn->mux->get_first_cs) + return NULL; + return conn->mux->get_first_cs(conn); +} + +#endif /* _HAPROXY_CONN_STREAM_H */ diff --git a/include/haproxy/connection-t.h b/include/haproxy/connection-t.h index a5a596ced..132733392 100644 --- a/include/haproxy/connection-t.h +++ b/include/haproxy/connection-t.h @@ -33,6 +33,7 @@ #include #include +#include #include #include #include @@ -59,50 +60,6 @@ enum sub_event_type { SUB_RETRY_SEND = 0x00000002, /* Schedule the tasklet when we can attempt to send again */ }; -/* conn_stream flags */ -enum { - CS_FL_NONE = 0x00000000, /* Just for initialization purposes */ - CS_FL_SHRD = 0x00000010, /* read shut, draining extra data */ - CS_FL_SHRR = 0x00000020, /* read shut, resetting extra data */ - CS_FL_SHR = CS_FL_SHRD | CS_FL_SHRR, /* read shut status */ - - CS_FL_SHWN = 0x00000040, /* write shut, verbose mode */ - CS_FL_SHWS = 0x00000080, /* write shut, silent mode */ - CS_FL_SHW = CS_FL_SHWN | CS_FL_SHWS, /* write shut status */ - - - CS_FL_ERROR = 0x00000100, /* a fatal error was reported */ - CS_FL_RCV_MORE = 0x00000200, /* We may have more bytes to transfer */ - CS_FL_WANT_ROOM = 0x00000400, /* More bytes to transfer, but not enough room */ - CS_FL_ERR_PENDING = 0x00000800, /* An error is pending, but there's still data to be read */ - CS_FL_EOS = 0x00001000, /* End of stream delivered to data layer */ - /* unused: 0x00002000 */ - CS_FL_EOI = 0x00004000, /* end-of-input reached */ - CS_FL_MAY_SPLICE = 0x00008000, /* caller may use rcv_pipe() only if this flag is set */ - CS_FL_WAIT_FOR_HS = 0x00010000, /* This stream is waiting for handhskae */ - CS_FL_KILL_CONN = 0x00020000, /* must kill the connection when the CS closes */ - - /* following flags are supposed to be set by the mux and read/unset by - * the stream-interface : - */ - CS_FL_NOT_FIRST = 0x00100000, /* this stream is not the first one */ - - /* flags set by the mux relayed to the stream */ - CS_FL_WEBSOCKET = 0x00200000, /* websocket stream */ -}; - -/* cs_shutr() modes */ -enum cs_shr_mode { - CS_SHR_DRAIN = 0, /* read shutdown, drain any extra stuff */ - CS_SHR_RESET = 1, /* read shutdown, reset any extra stuff */ -}; - -/* cs_shutw() modes */ -enum cs_shw_mode { - CS_SHW_NORMAL = 0, /* regular write shutdown */ - CS_SHW_SILENT = 1, /* imminent close, don't notify peer */ -}; - /* For each direction, we have a CO_FL_XPRT__ENA flag, which * indicates if read or write is desired in that direction for the respective * layers. The current status corresponding to the current layer being used is @@ -446,18 +403,6 @@ struct mux_stopping_data { struct task *task; /* task woken up on soft-stop */ }; -/* data_cb describes the data layer's recv and send callbacks which are called - * when I/O activity was detected after the transport layer is ready. These - * callbacks are supposed to make use of the xprt_ops above to exchange data - * from/to buffers and pipes. The callback is used to report activity - * at the transport layer, which can be a connection opening/close, or any - * data movement. It may abort a connection by returning < 0. - */ -struct data_cb { - int (*wake)(struct conn_stream *cs); /* data-layer callback to report activity */ - char name[8]; /* data layer name, zero-terminated */ -}; - struct my_tcphdr { uint16_t source; uint16_t dest; @@ -480,19 +425,6 @@ struct conn_src { #endif }; -/* - * This structure describes the elements of a connection relevant to a stream - */ -struct conn_stream { - enum obj_type obj_type; /* differentiates connection from applet context */ - /* 3 bytes hole here */ - unsigned int flags; /* CS_FL_* */ - struct connection *conn; /* xprt-level connection */ - void *data; /* pointer to upper layer's entity (eg: stream interface) */ - const struct data_cb *data_cb; /* data layer callbacks. Must be set before xprt->init() */ - void *ctx; /* mux-specific context */ -}; - /* Hash header flag reflecting the input parameters present * CAUTION! Always update CONN_HASH_PARAMS_TYPE_COUNT when adding a new entry. */ diff --git a/include/haproxy/connection.h b/include/haproxy/connection.h index 169cd581a..bfa658768 100644 --- a/include/haproxy/connection.h +++ b/include/haproxy/connection.h @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -37,16 +38,15 @@ #include extern struct pool_head *pool_head_connection; -extern struct pool_head *pool_head_connstream; extern struct pool_head *pool_head_conn_hash_node; extern struct pool_head *pool_head_sockaddr; extern struct pool_head *pool_head_authority; +extern struct pool_head *pool_head_uniqueid; extern struct xprt_ops *registered_xprt[XPRT_ENTRIES]; extern struct mux_proto_list mux_proto_list; extern struct mux_stopping_data mux_stopping_data[MAX_THREADS]; #define IS_HTX_CONN(conn) ((conn)->mux && ((conn)->mux->flags & MX_FL_HTX)) -#define IS_HTX_CS(cs) (IS_HTX_CONN((cs)->conn)) /* receive a PROXY protocol header over a connection */ int conn_recv_proxy(struct connection *conn, int flag); @@ -88,8 +88,6 @@ void conn_free(struct connection *conn); struct conn_hash_node *conn_alloc_hash_node(struct connection *conn); struct sockaddr_storage *sockaddr_alloc(struct sockaddr_storage **sap, const struct sockaddr_storage *orig, socklen_t len); void sockaddr_free(struct sockaddr_storage **sap); -void cs_free(struct conn_stream *cs); -struct conn_stream *cs_new(struct connection *conn, void *target); /* connection hash stuff */ @@ -246,58 +244,6 @@ static inline void conn_xprt_shutw_hard(struct connection *c) c->xprt->shutw(c, c->xprt_ctx, 0); } -/* Returns the conn from a cs. If cs is NULL, returns NULL */ -static inline struct connection *cs_conn(const struct conn_stream *cs) -{ - return cs ? cs->conn : NULL; -} - -/* shut read */ -static inline void cs_shutr(struct conn_stream *cs, enum cs_shr_mode mode) -{ - if (!cs_conn(cs) || cs->flags & CS_FL_SHR) - return; - - /* clean data-layer shutdown */ - if (cs->conn->mux && cs->conn->mux->shutr) - cs->conn->mux->shutr(cs, mode); - cs->flags |= (mode == CS_SHR_DRAIN) ? CS_FL_SHRD : CS_FL_SHRR; -} - -/* shut write */ -static inline void cs_shutw(struct conn_stream *cs, enum cs_shw_mode mode) -{ - if (!cs_conn(cs) || cs->flags & CS_FL_SHW) - return; - - /* clean data-layer shutdown */ - if (cs->conn->mux && cs->conn->mux->shutw) - cs->conn->mux->shutw(cs, 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); -} - -/* completely close a conn_stream after draining possibly pending data (but do not detach it) */ -static inline void cs_drain_and_close(struct conn_stream *cs) -{ - cs_shutw(cs, CS_SHW_SILENT); - cs_shutr(cs, CS_SHR_DRAIN); -} - -/* sets CS_FL_ERROR or CS_FL_ERR_PENDING on the cs */ -static inline void cs_set_error(struct conn_stream *cs) -{ - if (cs->flags & CS_FL_EOS) - cs->flags |= CS_FL_ERROR; - else - cs->flags |= CS_FL_ERR_PENDING; -} /* detect sock->data read0 transition */ static inline int conn_xprt_read0_pending(struct connection *c) @@ -328,17 +274,6 @@ static inline int conn_prepare(struct connection *conn, const struct protocol *p return ret; } -/* - * Initializes all required fields for a new conn_strema. - */ -static inline void cs_init(struct conn_stream *cs, struct connection *conn) -{ - cs->obj_type = OBJ_TYPE_CS; - cs->flags = CS_FL_NONE; - cs->conn = conn; - cs->ctx = conn; -} - /* returns 0 if the connection is valid and is a frontend connection, otherwise * returns 1 indicating it's a backend connection. And uninitialized connection * also returns 1 to better handle the usage in the middle of initialization. @@ -367,22 +302,6 @@ static inline void conn_set_private(struct connection *conn) } } -/* Retrieves any valid conn_stream from this connection, preferably the first - * valid one. The purpose is to be able to figure one other end of a private - * connection for purposes like source binding or proxy protocol header - * emission. In such cases, any conn_stream is expected to be valid so the - * mux is encouraged to return the first one it finds. If the connection has - * no mux or the mux has no get_first_cs() method or the mux has no valid - * conn_stream, NULL is returned. The output pointer is purposely marked - * const to discourage the caller from modifying anything there. - */ -static inline const struct conn_stream *cs_get_first(const struct connection *conn) -{ - if (!conn || !conn->mux || !conn->mux->get_first_cs) - return NULL; - return conn->mux->get_first_cs(conn); -} - static inline void conn_force_unsubscribe(struct connection *conn) { if (!conn->subs) @@ -391,39 +310,6 @@ static inline void conn_force_unsubscribe(struct connection *conn) conn->subs = NULL; } -/* Detach the conn_stream from the connection, if any. If a mux owns the - * connection ->detach() callback is called. Otherwise, it means the conn-stream - * owns the connection. In this case the connection is closed and released. The - * conn-stream is not released. - */ -static inline void cs_detach(struct conn_stream *cs) -{ - if (cs_conn(cs)) { - if (cs->conn->mux) - cs->conn->mux->detach(cs); - else { - /* It's too early to have a mux, let's just destroy - * the connection - */ - struct connection *conn = cs->conn; - - conn_stop_tracking(conn); - conn_full_close(conn); - if (conn->destroy_cb) - conn->destroy_cb(conn); - conn_free(conn); - } - } - cs_init(cs, NULL); -} - -/* Release a conn_stream */ -static inline void cs_destroy(struct conn_stream *cs) -{ - cs_detach(cs); - cs_free(cs); -} - /* Returns the source address of the connection or NULL if not set */ static inline const struct sockaddr_storage *conn_src(struct connection *conn) { @@ -540,13 +426,6 @@ static inline void conn_set_quickack(const struct connection *conn, int value) #endif } -/* Attaches a conn_stream to a data layer and sets the relevant callbacks */ -static inline void cs_attach(struct conn_stream *cs, void *data, const struct data_cb *data_cb) -{ - cs->data_cb = data_cb; - cs->data = data; -} - static inline struct wait_event *wl_set_waitcb(struct wait_event *wl, struct task *(*cb)(struct task *, void *, unsigned int), void *ctx) { if (!wl->tasklet->process) { @@ -597,13 +476,6 @@ static inline const char *conn_get_mux_name(const struct connection *conn) return conn->mux->name; } -static inline const char *cs_get_data_name(const struct conn_stream *cs) -{ - if (!cs || !cs->data_cb) - return "NONE"; - return cs->data_cb->name; -} - /* registers pointer to transport layer (XPRT_*) */ static inline void xprt_register(int id, struct xprt_ops *xprt) { diff --git a/include/haproxy/stream_interface.h b/include/haproxy/stream_interface.h index da07127ff..2a373d291 100644 --- a/include/haproxy/stream_interface.h +++ b/include/haproxy/stream_interface.h @@ -26,6 +26,8 @@ #include #include #include +#include +#include #include #include diff --git a/src/conn_stream.c b/src/conn_stream.c new file mode 100644 index 000000000..43e6fd0a2 --- /dev/null +++ b/src/conn_stream.c @@ -0,0 +1,55 @@ +/* + * Conn-stream management functions + * + * Copyright 2021 Christopher Faulet + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version + * 2 of the License, or (at your option) any later version. + * + */ + +#include +#include +#include +#include +//#include + +DECLARE_POOL(pool_head_connstream, "conn_stream", sizeof(struct conn_stream)); + + +/* Tries to allocate a new conn_stream and initialize its main fields. If + * is NULL, then a new connection is allocated on the fly, initialized, + * and assigned to cs->conn ; this connection will then have to be released + * using pool_free() or conn_free(). The conn_stream is initialized and added + * to the mux's stream list on success, then returned. On failure, nothing is + * allocated and NULL is returned. + */ +struct conn_stream *cs_new(struct connection *conn, void *target) +{ + struct conn_stream *cs; + + cs = pool_alloc(pool_head_connstream); + if (unlikely(!cs)) + return NULL; + + if (!conn) { + conn = conn_new(target); + if (unlikely(!conn)) { + cs_free(cs); + return NULL; + } + } + + cs_init(cs, conn); + return cs; +} + +/* Releases a conn_stream previously allocated by cs_new(), as well as any + * buffer it would still hold. + */ +void cs_free(struct conn_stream *cs) +{ + pool_free(pool_head_connstream, cs); +} diff --git a/src/connection.c b/src/connection.c index 76becfc2b..9d125627d 100644 --- a/src/connection.c +++ b/src/connection.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -26,14 +27,14 @@ #include #include #include -#include +#include #include +#include #include #include DECLARE_POOL(pool_head_connection, "connection", sizeof(struct connection)); -DECLARE_POOL(pool_head_connstream, "conn_stream", sizeof(struct conn_stream)); DECLARE_POOL(pool_head_conn_hash_node, "conn_hash_node", sizeof(struct conn_hash_node)); DECLARE_POOL(pool_head_sockaddr, "sockaddr", sizeof(struct sockaddr_storage)); DECLARE_POOL(pool_head_authority, "authority", PP2_AUTHORITY_MAX); @@ -559,42 +560,6 @@ void sockaddr_free(struct sockaddr_storage **sap) *sap = NULL; } -/* Releases a conn_stream previously allocated by cs_new(), as well as any - * buffer it would still hold. - */ -void cs_free(struct conn_stream *cs) -{ - - pool_free(pool_head_connstream, cs); -} - -/* Tries to allocate a new conn_stream and initialize its main fields. If - * is NULL, then a new connection is allocated on the fly, initialized, - * and assigned to cs->conn ; this connection will then have to be released - * using pool_free() or conn_free(). The conn_stream is initialized and added - * to the mux's stream list on success, then returned. On failure, nothing is - * allocated and NULL is returned. - */ -struct conn_stream *cs_new(struct connection *conn, void *target) -{ - struct conn_stream *cs; - - cs = pool_alloc(pool_head_connstream); - if (unlikely(!cs)) - return NULL; - - if (!conn) { - conn = conn_new(target); - if (unlikely(!conn)) { - cs_free(cs); - return NULL; - } - } - - cs_init(cs, conn); - return cs; -} - /* Try to add a handshake pseudo-XPRT. If the connection's first XPRT is * raw_sock, then just use the new XPRT as the connection XPRT, otherwise * call the xprt's add_xprt() method. diff --git a/src/h3.c b/src/h3.c index 965812e77..31b9c00d7 100644 --- a/src/h3.c +++ b/src/h3.c @@ -18,6 +18,7 @@ #include #include +#include #include #include #include diff --git a/src/mux_fcgi.c b/src/mux_fcgi.c index d5558a68b..374d26e46 100644 --- a/src/mux_fcgi.c +++ b/src/mux_fcgi.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include diff --git a/src/mux_h1.c b/src/mux_h1.c index db3483fb1..2e1090a77 100644 --- a/src/mux_h1.c +++ b/src/mux_h1.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include diff --git a/src/mux_h2.c b/src/mux_h2.c index 0cc9eb373..1389f8487 100644 --- a/src/mux_h2.c +++ b/src/mux_h2.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include diff --git a/src/mux_pt.c b/src/mux_pt.c index 4d6d2ba08..8530564c2 100644 --- a/src/mux_pt.c +++ b/src/mux_pt.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include diff --git a/src/mux_quic.c b/src/mux_quic.c index 15c8ebc03..e286d6a9a 100644 --- a/src/mux_quic.c +++ b/src/mux_quic.c @@ -4,6 +4,7 @@ #include #include +#include #include #include #include diff --git a/src/payload.c b/src/payload.c index 7dd08c814..7e66f0408 100644 --- a/src/payload.c +++ b/src/payload.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include diff --git a/src/ssl_sample.c b/src/ssl_sample.c index 191c54a40..0ba14e90a 100644 --- a/src/ssl_sample.c +++ b/src/ssl_sample.c @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include diff --git a/src/tcpcheck.c b/src/tcpcheck.c index 294e49bcc..9376d3244 100644 --- a/src/tcpcheck.c +++ b/src/tcpcheck.c @@ -39,6 +39,7 @@ #include #include #include +#include #include #include #include