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.
This commit is contained in:
Willy Tarreau 2020-06-02 11:28:02 +02:00
parent a04ded58dc
commit 2741c8c4aa
35 changed files with 85 additions and 46 deletions

View File

@ -15,7 +15,6 @@
#include <haproxy/api.h>
#include <common/cfgparse.h>
#include <common/buffer.h>
#include <common/htx.h>
#include <haproxy/pool.h>
#include <haproxy/list.h>

View File

@ -23,8 +23,8 @@
#define _COMMON_H1_H
#include <haproxy/api.h>
#include <haproxy/dynbuf.h>
#include <haproxy/intops.h>
#include <common/buffer.h>
#include <common/http.h>
#include <common/http-hdr.h>
#include <import/ist.h>

View File

@ -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 <haproxy/list-t.h>
/* an element of the <buffer_wq> 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 <target>, passed as argument */
struct mt_list list; /* Next element in the <buffer_wq> list */
};
#endif /* _HAPROXY_DYNBUF_T_H */
/*
* Local variables:
* c-indent-level: 8
* c-basic-offset: 8
* End:
*/

View File

@ -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 <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <import/ist.h>
#include <haproxy/activity.h>
#include <haproxy/api.h>
#include <haproxy/buf.h>
#include <haproxy/chunk.h>
#include <import/ist.h>
#include <haproxy/istbuf.h>
#include <haproxy/dynbuf-t.h>
#include <haproxy/list-t.h>
#include <haproxy/pool.h>
#include <haproxy/activity.h>
/* an element of the <buffer_wq> 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 <target>, passed as argument */
struct mt_list list; /* Next element in the <buffer_wq> 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:

View File

@ -29,6 +29,7 @@
#include <haproxy/api.h>
#include <haproxy/chunk.h>
#include <haproxy/dynbuf.h>
#include <common/htx.h>
#include <common/ticks.h>
#include <haproxy/time.h>

View File

@ -23,7 +23,6 @@
#define _PROTO_SESSION_H
#include <haproxy/api.h>
#include <common/buffer.h>
#include <haproxy/pool.h>
#include <types/global.h>

View File

@ -23,7 +23,6 @@
#define _PROTO_TRACE_H
#include <haproxy/api.h>
#include <common/buffer.h>
#include <common/standard.h>
#include <import/ist.h>
#include <haproxy/list.h>

View File

@ -23,13 +23,13 @@
#define _TYPES_APPLET_H
#include <haproxy/api-t.h>
#include <haproxy/buf.h>
#include <haproxy/dynbuf-t.h>
#include <haproxy/freq_ctr-t.h>
#include <types/hlua.h>
#include <types/obj_type.h>
#include <types/proxy.h>
#include <types/stream.h>
#include <common/buffer.h>
#include <haproxy/chunk.h>
#include <common/xref.h>
struct appctx;

View File

@ -23,7 +23,7 @@
#define _TYPES_CHANNEL_H
#include <haproxy/api-t.h>
#include <common/buffer.h>
#include <haproxy/buf-t.h>
/* 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 :

View File

@ -32,7 +32,7 @@
#include <zlib.h>
#endif
#include <common/buffer.h>
#include <haproxy/buf-t.h>
struct comp {
struct comp_algo *algos;

View File

@ -23,8 +23,8 @@
#define _TYPES_SINK_H
#include <haproxy/api-t.h>
#include <common/buffer.h>
#include <import/ist.h>
#include <haproxy/api.h>
/* A sink may be of 4 distinct types :
* - file descriptor (such as stdout)

View File

@ -24,7 +24,7 @@
#include <sys/time.h>
#include <common/buffer.h>
#include <haproxy/dynbuf-t.h>
#include <haproxy/list-t.h>
#include <haproxy/thread.h>

View File

@ -31,7 +31,7 @@
#include <types/ssl_ckch.h>
#include <types/ssl_crtlist.h>
#include <common/buffer.h>
#include <haproxy/buf-t.h>
#include <haproxy/thread.h>
#include <haproxy/list-t.h>
#include <haproxy/openssl-compat.h>

View File

@ -29,6 +29,7 @@
#include <arpa/inet.h>
#include <haproxy/api-t.h>
#include <haproxy/dynbuf-t.h>
#include <haproxy/list-t.h>
#include <types/channel.h>

View File

@ -23,7 +23,6 @@
#define _TYPES_TRACE_H
#include <haproxy/api-t.h>
#include <common/buffer.h>
#include <import/ist.h>
#include <haproxy/list-t.h>
#include <types/sink.h>

View File

@ -3,7 +3,7 @@
#include <haproxy/api.h>
#include <common/cfgparse.h>
#include <haproxy/chunk.h>
#include <common/buffer.h>
#include <haproxy/buf-t.h>
#include <haproxy/errors.h>
#include <haproxy/thread.h>
#include <types/global.h>

View File

@ -20,7 +20,6 @@
#include <sys/types.h>
#include <haproxy/api.h>
#include <common/buffer.h>
#include <haproxy/hash.h>
#include <common/htx.h>
#include <common/ticks.h>

View File

@ -15,7 +15,8 @@
#include <string.h>
#include <haproxy/api.h>
#include <common/buffer.h>
#include <haproxy/dynbuf.h>
#include <haproxy/list.h>
#include <haproxy/pool.h>
#include <types/global.h>

View File

@ -16,7 +16,7 @@
#include <string.h>
#include <haproxy/api.h>
#include <common/buffer.h>
#include <haproxy/buf.h>
#include <proto/channel.h>

View File

@ -33,6 +33,7 @@
#include <haproxy/api.h>
#include <common/cfgparse.h>
#include <haproxy/chunk.h>
#include <haproxy/istbuf.h>
#include <haproxy/list.h>
#include <common/standard.h>
#include <haproxy/time.h>

View File

@ -27,6 +27,7 @@
#endif /* USE_ZLIB */
#include <haproxy/api.h>
#include <haproxy/dynbuf.h>
#include <common/cfgparse.h>
#include <haproxy/thread.h>
#include <haproxy/pool.h>

View File

@ -11,7 +11,7 @@
*/
#include <haproxy/api.h>
#include <common/buffer.h>
#include <haproxy/buf-t.h>
#include <common/cfgparse.h>
#include <haproxy/errors.h>
#include <common/htx.h>

View File

@ -11,7 +11,7 @@
*/
#include <haproxy/api.h>
#include <common/buffer.h>
#include <haproxy/dynbuf.h>
#include <common/cfgparse.h>
#include <common/htx.h>
#include <haproxy/list.h>

View File

@ -84,6 +84,7 @@
#include <haproxy/base64.h>
#include <common/cfgparse.h>
#include <haproxy/chunk.h>
#include <haproxy/dynbuf.h>
#include <haproxy/errors.h>
#include <haproxy/pool.h>
#include <haproxy/list.h>

View File

@ -10,6 +10,7 @@
*
*/
#include <haproxy/api.h>
#include <haproxy/istbuf.h>
#include <common/cfgparse.h>
#include <common/h1.h>
#include <common/h2.h>

View File

@ -11,6 +11,7 @@
*/
#include <haproxy/api.h>
#include <haproxy/istbuf.h>
#include <common/cfgparse.h>
#include <common/h1.h>
#include <common/h2.h>

View File

@ -23,7 +23,7 @@
#include <netinet/tcp.h>
#include <haproxy/api.h>
#include <common/buffer.h>
#include <haproxy/buf.h>
#include <common/standard.h>
#include <common/ticks.h>
#include <haproxy/time.h>

View File

@ -11,7 +11,6 @@
*/
#include <haproxy/api.h>
#include <common/buffer.h>
#include <common/http.h>
#include <haproxy/pool.h>

View File

@ -21,7 +21,7 @@
#include <unistd.h>
#include <haproxy/api.h>
#include <common/buffer.h>
#include <haproxy/buf-t.h>
#include <haproxy/openssl-compat.h>
#include <common/standard.h>

View File

@ -44,7 +44,7 @@
#include <import/lru.h>
#include <import/xxhash.h>
#include <common/buffer.h>
#include <haproxy/dynbuf.h>
#include <haproxy/chunk.h>
#include <haproxy/errors.h>
#include <haproxy/openssl-compat.h>

View File

@ -12,7 +12,8 @@
*/
#include <common/buffer.h>
#include <haproxy/api.h>
#include <haproxy/buf-t.h>
#include <haproxy/openssl-compat.h>
#include <proto/ssl_sock.h>

View File

@ -16,7 +16,8 @@
#include <haproxy/api.h>
#include <common/cfgparse.h>
#include <common/buffer.h>
#include <haproxy/dynbuf.h>
#include <haproxy/istbuf.h>
#include <haproxy/thread.h>
#include <common/htx.h>
#include <haproxy/pool.h>

View File

@ -20,7 +20,7 @@
#include <sys/types.h>
#include <haproxy/api.h>
#include <common/buffer.h>
#include <haproxy/dynbuf.h>
#include <common/standard.h>
#include <common/ticks.h>
#include <haproxy/time.h>

View File

@ -18,9 +18,10 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <haproxy/api.h>
#include <common/buffer.h>
#include <import/ist.h>
#include <haproxy/api.h>
#include <haproxy/buf.h>
#include <haproxy/istbuf.h>
#include <haproxy/list.h>
#include <proto/cli.h>
#include <proto/log.h>

View File

@ -2,9 +2,9 @@
#include <stdarg.h>
#include <haproxy/api.h>
#include <haproxy/buf-t.h>
#include <common/cfgparse.h>
#include <haproxy/chunk.h>
#include <common/buffer.h>
#include <haproxy/errors.h>
#include <types/global.h>
#include <proto/arg.h>