REORG: include: split mini-clist into haproxy/list and list-t.h

Half of the users of this include only need the type definitions and
not the manipulation macros nor the inline functions. Moves the various
types into mini-clist-t.h makes the files cleaner. The other one had all
its includes grouped at the top. A few files continued to reference it
without using it and were cleaned.

In addition it was about time that we'd rename that file, it's not
"mini" anymore and contains a bit more than just circular lists.
This commit is contained in:
Willy Tarreau 2020-05-27 18:01:47 +02:00
parent f0f1c80daf
commit 853b297c9b
66 changed files with 145 additions and 120 deletions

View File

@ -20,7 +20,6 @@
#include <unistd.h>
#include <common/chunk.h>
#include <common/hpack-dec.h>
#include <common/mini-clist.h>
#define MAX_RQ_SIZE 65536
#define MAX_HDR_NUM 1000

View File

@ -31,7 +31,7 @@
#include <event2/event_struct.h>
#include <event2/thread.h>
#include <common/mini-clist.h>
#include <haproxy/list.h>
#include <common/chunk.h>
#include <proto/spoe.h>

View File

@ -36,7 +36,7 @@
#include <event2/event_struct.h>
#include <event2/thread.h>
#include <common/mini-clist.h>
#include <haproxy/list.h>
#include <common/chunk.h>
#include <proto/spoe.h>

View File

@ -18,7 +18,7 @@
#include <common/buffer.h>
#include <common/htx.h>
#include <common/memory.h>
#include <common/mini-clist.h>
#include <haproxy/list.h>
#include <types/global.h>

View File

@ -23,7 +23,7 @@
#define _COMMON_CFGPARSE_H
#include <haproxy/api.h>
#include <common/mini-clist.h>
#include <haproxy/list-t.h>
#include <proto/log.h>
#include <proto/proxy.h>

View File

@ -29,7 +29,7 @@
#include <unistd.h>
#include <haproxy/api.h>
#include <common/mini-clist.h>
#include <haproxy/list.h>
#include <common/hathreads.h>
/* On architectures supporting threads and double-word CAS, we can implement

73
include/haproxy/list-t.h Normal file
View File

@ -0,0 +1,73 @@
/*
* include/haproxy/list-t.h
* Circular list manipulation types definitions
*
* Copyright (C) 2002-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_LIST_T_H
#define _HAPROXY_LIST_T_H
/* these are circular or bidirectionnal lists only. Each list pointer points to
* another list pointer in a structure, and not the structure itself. The
* pointer to the next element MUST be the first one so that the list is easily
* cast as a single linked list or pointer.
*/
struct list {
struct list *n; /* next */
struct list *p; /* prev */
};
/* This is similar to struct list, but we want to be sure the compiler will
* yell at you if you use macroes for one when you're using the other. You have
* to expicitely cast if that's really what you want to do.
*/
struct mt_list {
struct mt_list *next;
struct mt_list *prev;
};
/* a back-ref is a pointer to a target list entry. It is used to detect when an
* element being deleted is currently being tracked by another user. The best
* example is a user dumping the session table. The table does not fit in the
* output buffer so we have to set a mark on a session and go on later. But if
* that marked session gets deleted, we don't want the user's pointer to go in
* the wild. So we can simply link this user's request to the list of this
* session's users, and put a pointer to the list element in ref, that will be
* used as the mark for next iteration.
*/
struct bref {
struct list users;
struct list *ref; /* pointer to the target's list entry */
};
/* a word list is a generic list with a pointer to a string in each element. */
struct wordlist {
struct list list;
char *s;
};
/* this is the same as above with an additional pointer to a condition. */
struct cond_wordlist {
struct list list;
void *cond;
char *s;
};
#endif /* _HAPROXY_LIST_T_H */

View File

@ -1,8 +1,8 @@
/*
* include/common/mini-clist.h
* Circular list manipulation macros and structures.
* include/haproxy/list.h
* Circular list manipulation macros and functions.
*
* Copyright (C) 2002-2014 Willy Tarreau - w@1wt.eu
* Copyright (C) 2002-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,56 +19,12 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef _COMMON_MINI_CLIST_H
#define _COMMON_MINI_CLIST_H
#ifndef _HAPROXY_LIST_H
#define _HAPROXY_LIST_H
/* these are circular or bidirectionnal lists only. Each list pointer points to
* another list pointer in a structure, and not the structure itself. The
* pointer to the next element MUST be the first one so that the list is easily
* cast as a single linked list or pointer.
*/
struct list {
struct list *n; /* next */
struct list *p; /* prev */
};
/* This is similar to struct list, but we want to be sure the compiler will
* yell at you if you use macroes for one when you're using the other. You have
* to expicitely cast if that's really what you want to do.
*/
struct mt_list {
struct mt_list *next;
struct mt_list *prev;
};
/* a back-ref is a pointer to a target list entry. It is used to detect when an
* element being deleted is currently being tracked by another user. The best
* example is a user dumping the session table. The table does not fit in the
* output buffer so we have to set a mark on a session and go on later. But if
* that marked session gets deleted, we don't want the user's pointer to go in
* the wild. So we can simply link this user's request to the list of this
* session's users, and put a pointer to the list element in ref, that will be
* used as the mark for next iteration.
*/
struct bref {
struct list users;
struct list *ref; /* pointer to the target's list entry */
};
/* a word list is a generic list with a pointer to a string in each element. */
struct wordlist {
struct list list;
char *s;
};
/* this is the same as above with an additional pointer to a condition. */
struct cond_wordlist {
struct list list;
void *cond;
char *s;
};
#include <haproxy/api.h>
#include <haproxy/list-t.h>
#include <common/hathreads.h>
/* First undefine some macros which happen to also be defined on OpenBSD,
* in sys/queue.h, used by sys/event.h
@ -257,15 +213,13 @@ struct cond_wordlist {
&item->member != (list_head); \
item = back, back = LIST_ELEM(back->member.p, typeof(back), member))
#include <haproxy/api.h>
#include <common/hathreads.h>
#define MT_LIST_BUSY ((struct mt_list *)1)
/*
* Locked version of list manipulation macros.
* It is OK to use those concurrently from multiple threads, as long as the
* list is only used with the locked variants.
*/
#define MT_LIST_BUSY ((struct mt_list *)1)
/*
* Add an item at the beginning of a list.
@ -733,4 +687,4 @@ static __inline struct mt_list *list_to_mt_list(struct list *list)
}
#endif /* _COMMON_MINI_CLIST_H */
#endif /* _HAPROXY_LIST_H */

View File

@ -26,7 +26,7 @@
#include <haproxy/api.h>
#include <common/memory.h>
#include <common/mini-clist.h>
#include <haproxy/list.h>
#include <types/applet.h>
#include <proto/task.h>

View File

@ -23,7 +23,7 @@
#define _PROTO_HTTP_RULES_H
#include <haproxy/api.h>
#include <common/mini-clist.h>
#include <haproxy/list.h>
#include <types/action.h>
#include <types/proxy.h>

View File

@ -24,7 +24,6 @@
#include <haproxy/api.h>
#include <common/memory.h>
#include <common/mini-clist.h>
#include <types/proxy.h>
#include <types/queue.h>

View File

@ -14,7 +14,7 @@
#ifndef SHCTX_H
#define SHCTX_H
#include <common/mini-clist.h>
#include <haproxy/list.h>
#include <types/shctx.h>
#include <inttypes.h>

View File

@ -22,7 +22,7 @@
#ifndef _PROTO_SINK_H
#define _PROTO_SINK_H
#include <common/mini-clist.h>
#include <haproxy/list-t.h>
#include <types/sink.h>
extern struct list sink_list;

View File

@ -27,7 +27,7 @@
#include <haproxy/api.h>
#include <common/memory.h>
#include <common/mini-clist.h>
#include <haproxy/list.h>
#include <common/standard.h>
#include <common/ticks.h>
#include <common/hathreads.h>

View File

@ -25,7 +25,7 @@
#include <haproxy/api.h>
#include <common/buffer.h>
#include <import/ist.h>
#include <common/mini-clist.h>
#include <haproxy/list.h>
#include <types/log.h>
#include <types/sink.h>
#include <types/trace.h>

View File

@ -23,7 +23,7 @@
#define _TYPES_ACL_H
#include <haproxy/api-t.h>
#include <common/mini-clist.h>
#include <haproxy/list-t.h>
#include <types/arg.h>
#include <types/auth.h>

View File

@ -26,7 +26,7 @@
#include <netinet/in.h>
#include <common/chunk.h>
#include <common/mini-clist.h>
#include <haproxy/list-t.h>
#include <types/vars.h>
#include <types/protocol_buffers.h>

View File

@ -14,7 +14,7 @@
#define _TYPES_AUTH_H
#include <haproxy/api-t.h>
#include <common/mini-clist.h>
#include <haproxy/list-t.h>
#include <types/auth.h>

View File

@ -18,7 +18,7 @@
#include <common/standard.h>
#include <import/ist.h>
#include <common/mini-clist.h>
#include <haproxy/list-t.h>
#include <common/regex.h>
#include <haproxy/buf-t.h>

View File

@ -20,7 +20,7 @@
#ifndef _TYPES_CLI_H
#define _TYPES_CLI_H
#include <common/mini-clist.h>
#include <haproxy/list-t.h>
#include <types/applet.h>
/* Access level for a stats socket */

View File

@ -24,7 +24,7 @@
#include <import/eb32tree.h>
#include <common/mini-clist.h>
#include <haproxy/list-t.h>
#include <common/hathreads.h>
#include <types/connection.h>

View File

@ -25,7 +25,7 @@
#include <haproxy/api-t.h>
#include <import/ist.h>
#include <common/fcgi.h>
#include <common/mini-clist.h>
#include <haproxy/list-t.h>
#include <common/regex.h>
#include <import/ebistree.h>

View File

@ -22,7 +22,7 @@
#define _TYPES_FILTERS_H
#include <haproxy/api-t.h>
#include <common/mini-clist.h>
#include <haproxy/list-t.h>
struct http_msg;
struct proxy;

View File

@ -30,7 +30,7 @@
#include <haproxy/openssl-compat.h>
#endif
#include <common/mini-clist.h>
#include <haproxy/list-t.h>
#include <common/hathreads.h>
#include <types/obj_type.h>

View File

@ -27,7 +27,7 @@
#include <netinet/in.h>
#include <haproxy/api-t.h>
#include <common/hathreads.h>
#include <common/mini-clist.h>
#include <haproxy/list-t.h>
#include <types/ring.h>
#define NB_LOG_FACILITIES 24

View File

@ -23,7 +23,7 @@
#define _TYPES_PATTERN_H
#include <haproxy/api-t.h>
#include <common/mini-clist.h>
#include <haproxy/list-t.h>
#include <common/regex.h>
#include <types/sample.h>

View File

@ -28,7 +28,7 @@
#include <arpa/inet.h>
#include <haproxy/api-t.h>
#include <common/mini-clist.h>
#include <haproxy/list-t.h>
#include <common/regex.h>
#include <import/eb32tree.h>

View File

@ -26,7 +26,7 @@
#include <sys/socket.h>
#include <haproxy/api-t.h>
#include <common/mini-clist.h>
#include <haproxy/list-t.h>
#include <import/eb32tree.h>
/* some pointer types referenced below */

View File

@ -30,7 +30,7 @@
#include <haproxy/api-t.h>
#include <common/chunk.h>
#include <common/http.h>
#include <common/mini-clist.h>
#include <haproxy/list-t.h>
#include <common/regex.h>
#include <common/hathreads.h>

View File

@ -23,7 +23,7 @@
#define _TYPES_QUEUE_H
#include <haproxy/api-t.h>
#include <common/mini-clist.h>
#include <haproxy/list-t.h>
#include <common/hathreads.h>
#include <types/server.h>

View File

@ -28,7 +28,7 @@
#include <haproxy/buf-t.h>
#include <common/http.h>
#include <common/mini-clist.h>
#include <haproxy/list-t.h>
struct arg;

View File

@ -26,7 +26,7 @@
#include <arpa/inet.h>
#include <haproxy/api-t.h>
#include <common/mini-clist.h>
#include <haproxy/api.h>
#include <common/hathreads.h>
#include <haproxy/openssl-compat.h>

View File

@ -29,7 +29,7 @@
#include <arpa/inet.h>
#include <haproxy/api-t.h>
#include <common/mini-clist.h>
#include <haproxy/list-t.h>
#include <types/obj_type.h>
#include <types/proxy.h>

View File

@ -17,7 +17,7 @@
#include <signal.h>
#include <haproxy/api-t.h>
#include <common/mini-clist.h>
#include <haproxy/list-t.h>
#include <common/standard.h>
/* flags for -> flags */

View File

@ -25,7 +25,7 @@
#include <sys/time.h>
#include <common/buffer.h>
#include <common/mini-clist.h>
#include <haproxy/list-t.h>
#include <common/hathreads.h>
#include <types/filters.h>

View File

@ -33,7 +33,7 @@
#define _TYPES_SSL_CKCH_H
#ifdef USE_OPENSSL
#include <common/mini-clist.h>
#include <haproxy/list-t.h>
#include <haproxy/openssl-compat.h>
/* This is used to preload the certificate, private key

View File

@ -25,7 +25,7 @@
#include <import/ebmbtree.h>
#include <common/mini-clist.h>
#include <haproxy/list-t.h>
/* forward declarations for structures below */
struct bind_conf;

View File

@ -33,7 +33,7 @@
#include <common/buffer.h>
#include <common/hathreads.h>
#include <common/mini-clist.h>
#include <haproxy/list-t.h>
#include <haproxy/openssl-compat.h>
/* ***** READ THIS before adding code here! *****

View File

@ -29,7 +29,7 @@
#include <arpa/inet.h>
#include <haproxy/api-t.h>
#include <common/mini-clist.h>
#include <haproxy/list-t.h>
#include <types/channel.h>
#include <types/filters.h>

View File

@ -25,7 +25,7 @@
#include <sys/time.h>
#include <haproxy/api-t.h>
#include <common/mini-clist.h>
#include <haproxy/list-t.h>
#include <import/eb32sctree.h>
#include <import/eb32tree.h>

View File

@ -25,7 +25,7 @@
#include <haproxy/api-t.h>
#include <common/buffer.h>
#include <import/ist.h>
#include <common/mini-clist.h>
#include <haproxy/list-t.h>
#include <types/sink.h>
/* the macros below define an optional type for each of the 4 args passed to

View File

@ -1,7 +1,7 @@
#ifndef _TYPES_VARS_H
#define _TYPES_VARS_H
#include <common/mini-clist.h>
#include <haproxy/list-t.h>
#include <common/hathreads.h>
#include <types/sample.h>

View File

@ -15,7 +15,7 @@
#include <string.h>
#include <haproxy/api.h>
#include <common/mini-clist.h>
#include <haproxy/list.h>
#include <common/standard.h>
#include <common/uri_auth.h>

View File

@ -12,7 +12,7 @@
#include <haproxy/api.h>
#include <common/memory.h>
#include <common/mini-clist.h>
#include <haproxy/list.h>
#include <common/standard.h>
#include <proto/action.h>

View File

@ -14,7 +14,7 @@
#include <stdlib.h>
#include <haproxy/api.h>
#include <common/mini-clist.h>
#include <haproxy/list.h>
#include <proto/applet.h>
#include <proto/channel.h>
#include <proto/stream.h>

View File

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

View File

@ -29,7 +29,7 @@
#include <haproxy/api.h>
#include <common/cfgparse.h>
#include <common/memory.h>
#include <common/mini-clist.h>
#include <haproxy/list.h>
#include <common/standard.h>
#include <common/ticks.h>
#include <common/time.h>

View File

@ -14,7 +14,7 @@
#include <common/buffer.h>
#include <common/cfgparse.h>
#include <common/htx.h>
#include <common/mini-clist.h>
#include <haproxy/list.h>
#include <common/standard.h>
#include <types/compression.h>

View File

@ -86,7 +86,7 @@
#include <common/chunk.h>
#include <haproxy/errors.h>
#include <common/memory.h>
#include <common/mini-clist.h>
#include <haproxy/list.h>
#include <common/namespace.h>
#include <common/net_helper.h>
#include <haproxy/openssl-compat.h>

View File

@ -21,7 +21,7 @@
#include <haproxy/api.h>
#include <common/cfgparse.h>
#include <haproxy/errors.h>
#include <common/mini-clist.h>
#include <haproxy/list.h>
#include <common/standard.h>
#include <common/time.h>

View File

@ -20,7 +20,7 @@
#include <common/cfgparse.h>
#include <common/hathreads.h>
#include <common/memory.h>
#include <common/mini-clist.h>
#include <haproxy/list.h>
#include <common/standard.h>
#include <types/activity.h>

View File

@ -16,7 +16,7 @@
#include <common/h1.h>
#include <common/htx.h>
#include <import/ist.h>
#include <common/mini-clist.h>
#include <haproxy/list.h>
#include <common/net_helper.h>
#include <types/proxy.h>

View File

@ -19,7 +19,7 @@
#include <haproxy/api.h>
#include <common/cfgparse.h>
#include <common/mini-clist.h>
#include <haproxy/list.h>
#include <haproxy/version.h>
#include <types/cli.h>

View File

@ -28,7 +28,7 @@
#include <haproxy/api.h>
#include <haproxy/errors.h>
#include <common/mini-clist.h>
#include <haproxy/list.h>
#include <common/standard.h>
#include <common/time.h>
#include <haproxy/version.h>

View File

@ -32,7 +32,7 @@
#include <haproxy/api.h>
#include <haproxy/errors.h>
#include <common/mini-clist.h>
#include <haproxy/list.h>
#include <common/standard.h>
#include <common/namespace.h>

View File

@ -28,7 +28,7 @@
#include <haproxy/api.h>
#include <haproxy/errors.h>
#include <common/mini-clist.h>
#include <haproxy/list.h>
#include <common/standard.h>
#include <common/time.h>
#include <haproxy/version.h>

View File

@ -15,7 +15,7 @@
#include <haproxy/api.h>
#include <haproxy/errors.h>
#include <common/mini-clist.h>
#include <haproxy/list.h>
#include <common/standard.h>
#include <proto/protocol.h>

View File

@ -15,7 +15,7 @@
#include <arpa/inet.h>
#include <import/ebmbtree.h>
#include <types/global.h>
#include <common/mini-clist.h>
#include <haproxy/list.h>
#include "proto/shctx.h"
#if !defined (USE_PRIVATE_CACHE)

View File

@ -21,7 +21,7 @@
#include <haproxy/api.h>
#include <common/cfgparse.h>
#include <import/ist.h>
#include <common/mini-clist.h>
#include <haproxy/list.h>
#include <common/time.h>
#include <proto/cli.h>
#include <proto/log.h>

View File

@ -30,7 +30,7 @@
#include <common/http.h>
#include <common/htx.h>
#include <common/memory.h>
#include <common/mini-clist.h>
#include <haproxy/list.h>
#include <common/standard.h>
#include <common/ticks.h>
#include <common/time.h>

View File

@ -17,7 +17,7 @@
#include <haproxy/api.h>
#include <common/cfgparse.h>
#include <common/memory.h>
#include <common/mini-clist.h>
#include <haproxy/list.h>
#include <common/net_helper.h>
#include <common/standard.h>
#include <common/time.h>

View File

@ -14,7 +14,7 @@
#include <haproxy/api.h>
#include <common/memory.h>
#include <common/mini-clist.h>
#include <haproxy/list.h>
#include <common/standard.h>
#include <common/time.h>
#include <import/eb32sctree.h>

View File

@ -11,7 +11,7 @@
*/
#include <haproxy/api.h>
#include <common/cfgparse.h>
#include <common/mini-clist.h>
#include <haproxy/list.h>
#include <common/standard.h>
#include <common/ticks.h>
#include <common/time.h>

View File

@ -21,7 +21,7 @@
#include <haproxy/api.h>
#include <common/buffer.h>
#include <import/ist.h>
#include <common/mini-clist.h>
#include <haproxy/list.h>
#include <proto/cli.h>
#include <proto/log.h>
#include <proto/sink.h>

View File

@ -3,7 +3,7 @@
#include <haproxy/api.h>
#include <common/cfgparse.h>
#include <common/http.h>
#include <common/mini-clist.h>
#include <haproxy/list.h>
#include <types/vars.h>

View File

@ -2,7 +2,7 @@
#include <stdio.h>
#include <stdlib.h>
#define USE_THREAD
#include <common/mini-clist.h>
#include <haproxy/list.h>
/* Stress test the mt_lists.
* Compile from the haproxy directory with :