From 2741c8c4aa16cabdfa7d46d41c6ed35a8d73752c Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Tue, 2 Jun 2020 11:28:02 +0200 Subject: [PATCH] REORG: include: move common/buffer.h to haproxy/dynbuf{,-t}.h The pretty confusing "buffer.h" was in fact not the place to look for the definition of "struct buffer" but the one responsible for dynamic buffer allocation. As such it defines the struct buffer_wait and the few functions to allocate a buffer or wait for one. This patch moves it renaming it to dynbuf.h. The type definition was moved to its own file since it's included in a number of other structs. Doing this cleanup revealed that a significant number of files used to rely on this one to inherit struct buffer through it but didn't need anything from this file at all. --- .../prometheus-exporter/service-prometheus.c | 1 - include/common/h1.h | 2 +- include/haproxy/dynbuf-t.h | 42 +++++++++++++++++++ include/{common/buffer.h => haproxy/dynbuf.h} | 28 +++++-------- include/proto/channel.h | 1 + include/proto/session.h | 1 - include/proto/trace.h | 1 - include/types/applet.h | 4 +- include/types/channel.h | 2 +- include/types/compression.h | 2 +- include/types/sink.h | 2 +- include/types/spoe.h | 2 +- include/types/ssl_sock.h | 2 +- include/types/stream.h | 1 + include/types/trace.h | 1 - src/51d.c | 2 +- src/backend.c | 1 - src/buffer.c | 3 +- src/channel.c | 2 +- src/checks.c | 1 + src/compression.c | 1 + src/filters.c | 2 +- src/flt_http_comp.c | 2 +- src/haproxy.c | 1 + src/mux_h1.c | 1 + src/mux_h2.c | 1 + src/raw_sock.c | 2 +- src/session.c | 1 - src/ssl_sample.c | 2 +- src/ssl_sock.c | 2 +- src/ssl_utils.c | 3 +- src/stream.c | 3 +- src/stream_interface.c | 2 +- src/trace.c | 5 ++- src/wurfl.c | 2 +- 35 files changed, 85 insertions(+), 46 deletions(-) create mode 100644 include/haproxy/dynbuf-t.h rename include/{common/buffer.h => haproxy/dynbuf.h} (90%) diff --git a/contrib/prometheus-exporter/service-prometheus.c b/contrib/prometheus-exporter/service-prometheus.c index fe3431ccb..fe2520d62 100644 --- a/contrib/prometheus-exporter/service-prometheus.c +++ b/contrib/prometheus-exporter/service-prometheus.c @@ -15,7 +15,6 @@ #include #include -#include #include #include #include diff --git a/include/common/h1.h b/include/common/h1.h index 1295b1420..205a25ce2 100644 --- a/include/common/h1.h +++ b/include/common/h1.h @@ -23,8 +23,8 @@ #define _COMMON_H1_H #include +#include #include -#include #include #include #include diff --git a/include/haproxy/dynbuf-t.h b/include/haproxy/dynbuf-t.h new file mode 100644 index 000000000..451d58c53 --- /dev/null +++ b/include/haproxy/dynbuf-t.h @@ -0,0 +1,42 @@ +/* + * include/haproxy/dynbuf-t.h + * Structure definitions for dynamic buffer management. + * + * Copyright (C) 2000-2020 Willy Tarreau - w@1wt.eu + * + * 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_DYNBUF_T_H +#define _HAPROXY_DYNBUF_T_H + +#include + +/* an element of the list. It represents an object that need to + * acquire a buffer to continue its process. */ +struct buffer_wait { + void *target; /* The waiting object that should be woken up */ + int (*wakeup_cb)(void *); /* The function used to wake up the , passed as argument */ + struct mt_list list; /* Next element in the list */ +}; + +#endif /* _HAPROXY_DYNBUF_T_H */ + +/* + * Local variables: + * c-indent-level: 8 + * c-basic-offset: 8 + * End: + */ diff --git a/include/common/buffer.h b/include/haproxy/dynbuf.h similarity index 90% rename from include/common/buffer.h rename to include/haproxy/dynbuf.h index 4e19c22c2..01a784d4f 100644 --- a/include/common/buffer.h +++ b/include/haproxy/dynbuf.h @@ -1,8 +1,8 @@ /* - * include/common/buffer.h - * Buffer management definitions, macros and inline functions. + * include/haproxy/dynbuf.h + * Buffer management functions. * - * Copyright (C) 2000-2012 Willy Tarreau - w@1wt.eu + * Copyright (C) 2000-2020 Willy Tarreau - w@1wt.eu * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -19,30 +19,22 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#ifndef _COMMON_BUFFER_H -#define _COMMON_BUFFER_H +#ifndef _HAPROXY_DYNBUF_H +#define _HAPROXY_DYNBUF_H #include #include #include +#include +#include #include #include #include -#include -#include +#include +#include #include -#include - -/* an element of the list. It represents an object that need to - * acquire a buffer to continue its process. */ -struct buffer_wait { - void *target; /* The waiting object that should be woken up */ - int (*wakeup_cb)(void *); /* The function used to wake up the , passed as argument */ - struct mt_list list; /* Next element in the list */ -}; - extern struct pool_head *pool_head_buffer; extern struct mt_list buffer_wq; __decl_thread(extern HA_SPINLOCK_T buffer_wq_lock); @@ -210,7 +202,7 @@ static inline void offer_buffers(void *from, unsigned int threshold) } -#endif /* _COMMON_BUFFER_H */ +#endif /* _HAPROXY_DYNBUF_H */ /* * Local variables: diff --git a/include/proto/channel.h b/include/proto/channel.h index a36b63a61..d343c0276 100644 --- a/include/proto/channel.h +++ b/include/proto/channel.h @@ -29,6 +29,7 @@ #include #include +#include #include #include #include diff --git a/include/proto/session.h b/include/proto/session.h index 866217ec2..a52e982c9 100644 --- a/include/proto/session.h +++ b/include/proto/session.h @@ -23,7 +23,6 @@ #define _PROTO_SESSION_H #include -#include #include #include diff --git a/include/proto/trace.h b/include/proto/trace.h index 7a2b5e7e1..f16763d7f 100644 --- a/include/proto/trace.h +++ b/include/proto/trace.h @@ -23,7 +23,6 @@ #define _PROTO_TRACE_H #include -#include #include #include #include diff --git a/include/types/applet.h b/include/types/applet.h index ac7f38d71..7b21f9ab3 100644 --- a/include/types/applet.h +++ b/include/types/applet.h @@ -23,13 +23,13 @@ #define _TYPES_APPLET_H #include +#include +#include #include #include #include #include #include -#include -#include #include struct appctx; diff --git a/include/types/channel.h b/include/types/channel.h index 863c3fba6..d3823f262 100644 --- a/include/types/channel.h +++ b/include/types/channel.h @@ -23,7 +23,7 @@ #define _TYPES_CHANNEL_H #include -#include +#include /* The CF_* macros designate Channel Flags, which may be ORed in the bit field * member 'flags' in struct channel. Here we have several types of flags : diff --git a/include/types/compression.h b/include/types/compression.h index fc2ad2668..160490999 100644 --- a/include/types/compression.h +++ b/include/types/compression.h @@ -32,7 +32,7 @@ #include #endif -#include +#include struct comp { struct comp_algo *algos; diff --git a/include/types/sink.h b/include/types/sink.h index 3feb05ddf..aad6ba7d1 100644 --- a/include/types/sink.h +++ b/include/types/sink.h @@ -23,8 +23,8 @@ #define _TYPES_SINK_H #include -#include #include +#include /* A sink may be of 4 distinct types : * - file descriptor (such as stdout) diff --git a/include/types/spoe.h b/include/types/spoe.h index 42b4bd5a4..f08b9adcd 100644 --- a/include/types/spoe.h +++ b/include/types/spoe.h @@ -24,7 +24,7 @@ #include -#include +#include #include #include diff --git a/include/types/ssl_sock.h b/include/types/ssl_sock.h index 27633ecbd..ca41ffc2c 100644 --- a/include/types/ssl_sock.h +++ b/include/types/ssl_sock.h @@ -31,7 +31,7 @@ #include #include -#include +#include #include #include #include diff --git a/include/types/stream.h b/include/types/stream.h index 37bdb96c5..08e0f1255 100644 --- a/include/types/stream.h +++ b/include/types/stream.h @@ -29,6 +29,7 @@ #include #include +#include #include #include diff --git a/include/types/trace.h b/include/types/trace.h index c119ab33f..2114d410f 100644 --- a/include/types/trace.h +++ b/include/types/trace.h @@ -23,7 +23,6 @@ #define _TYPES_TRACE_H #include -#include #include #include #include diff --git a/src/51d.c b/src/51d.c index c53d68138..ab628fe64 100644 --- a/src/51d.c +++ b/src/51d.c @@ -3,7 +3,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/backend.c b/src/backend.c index ff6c37d2b..c9abbc7ab 100644 --- a/src/backend.c +++ b/src/backend.c @@ -20,7 +20,6 @@ #include #include -#include #include #include #include diff --git a/src/buffer.c b/src/buffer.c index ec07e76e6..b41716b7e 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -15,7 +15,8 @@ #include #include -#include +#include +#include #include #include diff --git a/src/channel.c b/src/channel.c index cd7da30b4..ae5c981c7 100644 --- a/src/channel.c +++ b/src/channel.c @@ -16,7 +16,7 @@ #include #include -#include +#include #include diff --git a/src/checks.c b/src/checks.c index 0a1d0e2e0..45de864c3 100644 --- a/src/checks.c +++ b/src/checks.c @@ -33,6 +33,7 @@ #include #include #include +#include #include #include #include diff --git a/src/compression.c b/src/compression.c index 45471c333..f1d739e70 100644 --- a/src/compression.c +++ b/src/compression.c @@ -27,6 +27,7 @@ #endif /* USE_ZLIB */ #include +#include #include #include #include diff --git a/src/filters.c b/src/filters.c index e9f846b66..1b7157353 100644 --- a/src/filters.c +++ b/src/filters.c @@ -11,7 +11,7 @@ */ #include -#include +#include #include #include #include diff --git a/src/flt_http_comp.c b/src/flt_http_comp.c index 9ca51e538..4b0e546ab 100644 --- a/src/flt_http_comp.c +++ b/src/flt_http_comp.c @@ -11,7 +11,7 @@ */ #include -#include +#include #include #include #include diff --git a/src/haproxy.c b/src/haproxy.c index 99e89075e..f178e51f6 100644 --- a/src/haproxy.c +++ b/src/haproxy.c @@ -84,6 +84,7 @@ #include #include #include +#include #include #include #include diff --git a/src/mux_h1.c b/src/mux_h1.c index 1c75e93cd..963ed16af 100644 --- a/src/mux_h1.c +++ b/src/mux_h1.c @@ -10,6 +10,7 @@ * */ #include +#include #include #include #include diff --git a/src/mux_h2.c b/src/mux_h2.c index 3c0ef5f8e..7050469a7 100644 --- a/src/mux_h2.c +++ b/src/mux_h2.c @@ -11,6 +11,7 @@ */ #include +#include #include #include #include diff --git a/src/raw_sock.c b/src/raw_sock.c index 4033625fe..faa8e1e97 100644 --- a/src/raw_sock.c +++ b/src/raw_sock.c @@ -23,7 +23,7 @@ #include #include -#include +#include #include #include #include diff --git a/src/session.c b/src/session.c index 804416901..d31806a2b 100644 --- a/src/session.c +++ b/src/session.c @@ -11,7 +11,6 @@ */ #include -#include #include #include diff --git a/src/ssl_sample.c b/src/ssl_sample.c index 8bc78e1c6..de3abeeb4 100644 --- a/src/ssl_sample.c +++ b/src/ssl_sample.c @@ -21,7 +21,7 @@ #include #include -#include +#include #include #include diff --git a/src/ssl_sock.c b/src/ssl_sock.c index fe194b7a7..e89fa5ae6 100644 --- a/src/ssl_sock.c +++ b/src/ssl_sock.c @@ -44,7 +44,7 @@ #include #include -#include +#include #include #include #include diff --git a/src/ssl_utils.c b/src/ssl_utils.c index 10b71d565..38efe7ec4 100644 --- a/src/ssl_utils.c +++ b/src/ssl_utils.c @@ -12,7 +12,8 @@ */ -#include +#include +#include #include #include diff --git a/src/stream.c b/src/stream.c index b6b2e1450..4af498602 100644 --- a/src/stream.c +++ b/src/stream.c @@ -16,7 +16,8 @@ #include #include -#include +#include +#include #include #include #include diff --git a/src/stream_interface.c b/src/stream_interface.c index 89f37ee13..d0f5f1abe 100644 --- a/src/stream_interface.c +++ b/src/stream_interface.c @@ -20,7 +20,7 @@ #include #include -#include +#include #include #include #include diff --git a/src/trace.c b/src/trace.c index a0b964884..4111bdbb7 100644 --- a/src/trace.c +++ b/src/trace.c @@ -18,9 +18,10 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include -#include #include +#include +#include +#include #include #include #include diff --git a/src/wurfl.c b/src/wurfl.c index 65a591732..0bc10fa98 100644 --- a/src/wurfl.c +++ b/src/wurfl.c @@ -2,9 +2,9 @@ #include #include +#include #include #include -#include #include #include #include