]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: threads: Use __decl_hathreads to declare locks
authorChristopher Faulet <cfaulet@haproxy.com>
Mon, 13 Nov 2017 09:34:01 +0000 (10:34 +0100)
committerWilly Tarreau <w@1wt.eu>
Mon, 13 Nov 2017 10:38:17 +0000 (11:38 +0100)
This macro should be used to declare variables or struct members depending on
the USE_THREAD compile option. It avoids the encapsulation of such declarations
between #ifdef/#endif. It is used to declare all lock variables.

35 files changed:
include/common/buffer.h
include/common/hathreads.h
include/common/memory.h
include/proto/applet.h
include/proto/fd.h
include/proto/signal.h
include/proto/task.h
include/types/backend.h
include/types/dns.h
include/types/fd.h
include/types/global.h
include/types/listener.h
include/types/pattern.h
include/types/peers.h
include/types/proxy.h
include/types/server.h
include/types/spoe.h
include/types/stick_table.h
include/types/task.h
include/types/vars.h
src/applet.c
src/buffer.c
src/checks.c
src/compression.c
src/fd.c
src/hlua.c
src/listener.c
src/pattern.c
src/pipe.c
src/server.c
src/signal.c
src/ssl_sock.c
src/stream.c
src/task.c
src/vars.c

index acaa79aab3d470fe3f7183ba3ce8a1895f07c9f8..4216d937c7a0133df4f19b97dad6f145e6f2f377 100644 (file)
@@ -52,9 +52,7 @@ extern struct pool_head *pool2_buffer;
 extern struct buffer buf_empty;
 extern struct buffer buf_wanted;
 extern struct list buffer_wq;
-#ifdef USE_THREAD
-extern HA_SPINLOCK_T buffer_wq_lock;
-#endif
+__decl_hathreads(HA_SPINLOCK_T buffer_wq_lock);
 
 int init_buffer();
 void deinit_buffer();
index 3b8fb0bd844f134df07f68d8374095d40c2294e7..31d0f533b917abca029098b3efa23f94a36c543e 100644 (file)
@@ -30,6 +30,8 @@ extern THREAD_LOCAL unsigned int tid_bit; /* The bit corresponding to the thread
 
 #ifndef USE_THREAD
 
+#define __decl_hathreads(decl)
+
 #define HA_ATOMIC_CAS(val, old, new) ({((*val) == (*old)) ? (*(val) = (new) , 1) : (*(old) = *(val), 0);})
 #define HA_ATOMIC_ADD(val, i)        ({*(val) += (i);})
 #define HA_ATOMIC_SUB(val, i)        ({*(val) -= (i);})
@@ -93,6 +95,8 @@ extern THREAD_LOCAL unsigned int tid_bit; /* The bit corresponding to the thread
 #include <pthread.h>
 #include <import/plock.h>
 
+#define __decl_hathreads(decl) decl
+
 /* TODO: thread: For now, we rely on GCC builtins but it could be a good idea to
  * have a header file regrouping all functions dealing with threads. */
 #define HA_ATOMIC_CAS(val, old, new) __atomic_compare_exchange_n(val, old, new, 0, 0, 0)
index ee394f8af0f9cf227c777adfb764ecb8b13f6c3e..a5c0ec49ef794a7f9c43de70426babce738c1c03 100644 (file)
@@ -47,9 +47,7 @@
 
 struct pool_head {
        void **free_list;
-#ifdef USE_THREAD
-       HA_SPINLOCK_T lock;     /* the spin lock */
-#endif
+       __decl_hathreads(HA_SPINLOCK_T lock); /* the spin lock */
        struct list list;       /* list of all known pools */
        unsigned int used;      /* how many chunks are currently in use */
        unsigned int allocated; /* how many chunks have been allocated */
index 1a621a1dc322b7de70df8482cb7b1c803a815190..914b496f52aaabf515340b3350b670f3f00ed8fc 100644 (file)
@@ -31,9 +31,7 @@
 
 extern unsigned int nb_applets;
 extern unsigned int applets_active_queue;
-#ifdef USE_THREAD
-extern HA_SPINLOCK_T applet_active_lock;
-#endif
+__decl_hathreads(extern HA_SPINLOCK_T applet_active_lock);
 extern struct list applet_active_queue;
 
 void applet_run_active();
index 813e4f3999b1ddc5cbf92c49fe3c412190adf700..f81c64624e89c7aee87491094280ed64478e03de 100644 (file)
@@ -39,11 +39,9 @@ extern int fd_cache_num;            // number of events in the cache
 extern THREAD_LOCAL int *fd_updt;  // FD updates list
 extern THREAD_LOCAL int fd_nbupdt; // number of updates in the list
 
-#ifdef USE_THREAD
-HA_SPINLOCK_T fdtab_lock;      /* global lock to protect fdtab array */
-HA_RWLOCK_T   fdcache_lock;    /* global lock to protect fd_cache array */
-HA_SPINLOCK_T poll_lock;       /* global lock to protect poll info */
-#endif
+__decl_hathreads(HA_SPINLOCK_T fdtab_lock);      /* global lock to protect fdtab array */
+__decl_hathreads(HA_RWLOCK_T   fdcache_lock);    /* global lock to protect fd_cache array */
+__decl_hathreads(HA_SPINLOCK_T poll_lock);       /* global lock to protect poll info */
 
 /* Deletes an FD from the fdsets, and recomputes the maxfd limit.
  * The file descriptor is also closed.
index 084fa7d151e0395d99b837fcf1bf299432d0e32b..32f6ce6fc13f52da62413b323f45a83062aa32af 100644 (file)
@@ -22,9 +22,7 @@ extern int signal_queue_len;
 extern struct signal_descriptor signal_state[];
 extern struct pool_head *pool2_sig_handlers;
 
-#ifdef USE_THREAD
-extern HA_SPINLOCK_T signals_lock;
-#endif
+__decl_hathreads(extern HA_SPINLOCK_T signals_lock);
 
 void signal_handler(int sig);
 void __signal_process_queue();
index e6ba4618b095ca2bd64cfc1e4bf30dcdc6ddf287..9461b594e0aee792fd362a00b8672b9402ffed2a 100644 (file)
@@ -89,10 +89,9 @@ extern unsigned int nb_tasks_cur;
 extern unsigned int niced_tasks;  /* number of niced tasks in the run queue */
 extern struct pool_head *pool2_task;
 extern struct pool_head *pool2_notification;
-#ifdef USE_THREAD
-extern HA_SPINLOCK_T rq_lock;        /* spin lock related to run queue */
-extern HA_SPINLOCK_T wq_lock;        /* spin lock related to wait queue */
-#endif
+
+__decl_hathreads(extern HA_SPINLOCK_T rq_lock);  /* spin lock related to run queue */
+__decl_hathreads(extern HA_SPINLOCK_T wq_lock);  /* spin lock related to wait queue */
 
 /* return 0 if task is in run queue, otherwise non-zero */
 static inline int task_in_rq(struct task *t)
index 68d312538737b3c66dcd4ba4dd796c15312db3cf..c7f9fa3274ff9714fc5e3902d36ae6df11a5acb3 100644 (file)
@@ -147,9 +147,8 @@ struct lbprm {
        struct lb_fwlc fwlc;
        struct lb_chash chash;
        struct lb_fas fas;
-#ifdef USE_THREAD
-       HA_SPINLOCK_T lock;
-#endif
+       __decl_hathreads(HA_SPINLOCK_T lock);
+
        /* Call backs for some actions. Any of them may be NULL (thus should be ignored). */
        void (*update_server_eweight)(struct server *);  /* to be called after eweight change */
        void (*set_server_status_up)(struct server *);   /* to be called after status changes to UP */
index bdc8cfc5e8f0abf520494582e07908d49c45bcf8..b1f068a6133820d664aeaa5bd7349b653b49c367 100644 (file)
@@ -193,9 +193,7 @@ struct dns_resolvers {
        struct eb_root query_ids;           /* tree to quickly lookup/retrieve query ids currently in use
                                              * used by each nameserver, but stored in resolvers since there must
                                              * be a unique relation between an eb_root and an eb_node (resolution) */
-#ifdef USE_THREAD
-       HA_SPINLOCK_T lock;
-#endif
+       __decl_hathreads(HA_SPINLOCK_T lock);
        struct list list;                   /* resolvers list */
 };
 
index 2da65992a2dd44596a2fea1562bc28d3677783a6..2d8237ba18612d06329231969c6b83e935f345ee 100644 (file)
@@ -95,9 +95,7 @@ struct fdtab {
        void (*iocb)(int fd);                /* I/O handler */
        void *owner;                         /* the connection or listener associated with this fd, NULL if closed */
        unsigned long thread_mask;           /* mask of thread IDs authorized to process the task */
-#ifdef USE_THREAD
-       HA_SPINLOCK_T lock;
-#endif
+       __decl_hathreads(HA_SPINLOCK_T lock);
        unsigned int  cache;                 /* position+1 in the FD cache. 0=not in cache. */
        unsigned char state;                 /* FD state for read and write directions (2*3 bits) */
        unsigned char ev;                    /* event seen in return of poll() : FD_POLL_* */
index 48b6f9d84f2f5875397bb44de2a03b68bae4f046..6793c83cdfa270181332d862b325d98e1c5b90a1 100644 (file)
@@ -163,11 +163,7 @@ struct global {
        } unix_bind;
 #ifdef USE_CPU_AFFINITY
        unsigned long cpu_map[LONGBITS];              /* list of CPU masks for the 32/64 first processes */
-
-#ifdef USE_THREAD
-       unsigned long thread_map[LONGBITS][LONGBITS]; /* list of CPU masks for the 32/64 first threads per process */
-#endif
-
+       __decl_hathreads(unsigned long thread_map[LONGBITS][LONGBITS]); /* list of CPU masks for the 32/64 first threads per process */
 #endif
        struct proxy *stats_fe;     /* the frontend holding the stats settings */
        struct vars   vars;         /* list of variables for the process scope. */
index ac39758ca4e627a7a7082a4fd9b95891a7844d64..545f88c450a5d51906b5efdbc6ef7d24dd5886e6 100644 (file)
@@ -200,9 +200,7 @@ struct listener {
        int tcp_ut;                     /* for TCP, user timeout */
        char *interface;                /* interface name or NULL */
 
-#ifdef USE_THREAD
-       HA_SPINLOCK_T lock;
-#endif
+       __decl_hathreads(HA_SPINLOCK_T lock);
 
        const struct netns_entry *netns; /* network namespace of the listener*/
 
index d5c340a9cf68da5c77ac00d9a4efc50105d55e2c..a0bb08e16b138e2e0062c01b9b9e51a7bb712ec9 100644 (file)
@@ -107,9 +107,7 @@ struct pat_ref {
        char *display; /* String displayed to identify the pattern origin. */
        struct list head; /* The head of the list of struct pat_ref_elt. */
        struct list pat; /* The head of the list of struct pattern_expr. */
-#ifdef USE_THREAD
-       HA_SPINLOCK_T lock; /* Lock used to protect pat ref elements */
-#endif
+       __decl_hathreads(HA_SPINLOCK_T lock); /* Lock used to protect pat ref elements */
 };
 
 /* This is a part of struct pat_ref. Each entry contain one
@@ -202,9 +200,7 @@ struct pattern_expr {
        struct eb_root pattern_tree;  /* may be used for lookup in large datasets */
        struct eb_root pattern_tree_2;  /* may be used for different types */
        int mflags;                     /* flags relative to the parsing or matching method. */
-#ifdef USE_THREAD
-       HA_RWLOCK_T lock;               /* lock used to protect patterns */
-#endif
+       __decl_hathreads(HA_RWLOCK_T lock);               /* lock used to protect patterns */
 };
 
 /* This is a list of expression. A struct pattern_expr can be used by
index 2fc7435c1ca7d3896066bfe12a83efa5db6f5fa8..58c8c4ee9895c73eb5a5533f7517aa283ae430d6 100644 (file)
@@ -67,9 +67,7 @@ struct peer {
        struct shared_table *remote_table;
        struct shared_table *last_local_table;
        struct shared_table *tables;
-#ifdef USE_THREAD
-       HA_SPINLOCK_T lock;      /* lock used to handle this peer section */
-#endif
+       __decl_hathreads(HA_SPINLOCK_T lock); /* lock used to handle this peer section */
        struct peer *next;        /* next peer in the list */
 };
 
index 719c8dd99a441099d1bbaa55a019818d7ef5c74e..3b7d9a3e5a0576a7ce75cb60792985f881168fcb 100644 (file)
@@ -239,9 +239,7 @@ struct email_alertq {
                                         * code even though they are not checks. This structure
                                         * is as a parameter to the check code.
                                         * Each check corresponds to a mailer */
-#ifdef USE_THREAD
-       HA_SPINLOCK_T lock;
-#endif
+       __decl_hathreads(HA_SPINLOCK_T lock);
 };
 
 struct proxy {
@@ -444,10 +442,7 @@ struct proxy {
                                                 * name is used
                                                 */
        struct list filter_configs;             /* list of the filters that are declared on this proxy */
-
-#ifdef USE_THREAD
-       HA_SPINLOCK_T lock;
-#endif
+       __decl_hathreads(HA_SPINLOCK_T lock);
 };
 
 struct switching_rule {
index 76225f7d326ff146e3127c5b53e4589693433d1a..adedca43cd460a1bead9881ae9dd3eaba8d8160c 100644 (file)
@@ -286,10 +286,7 @@ struct server {
                struct sample_expr *sni;        /* sample expression for SNI */
        } ssl_ctx;
 #endif
-
-#ifdef USE_THREAD
-       HA_SPINLOCK_T lock;
-#endif
+       __decl_hathreads(HA_SPINLOCK_T lock);
        struct {
                const char *file;               /* file where the section appears */
                int line;                       /* line where the section appears */
index aead2ba98bcc129121e2fb8795021b968f694501..53e7200c8822122f144ee0ef17556c87288cf5db 100644 (file)
@@ -264,10 +264,7 @@ struct spoe_agent {
                struct list     applets;        /* List of available SPOE applets */
                struct list     sending_queue;  /* Queue of streams waiting to send data */
                struct list     waiting_queue;  /* Queue of streams waiting for a ack, in async mode */
-
-#ifdef USE_THREAD
-               HA_SPINLOCK_T   lock;
-#endif
+               __decl_hathreads(HA_SPINLOCK_T lock);
        } *rt;
 
 };
index 4f5de998659fffcfbcbbf0739bc2e550a29e5ef4..4a8d8c7db2fa08098997a97904803156e219bd82 100644 (file)
@@ -129,9 +129,7 @@ extern struct stktable_type stktable_types[];
 struct stksess {
        unsigned int expire;      /* session expiration date */
        unsigned int ref_cnt;     /* reference count, can only purge when zero */
-#ifdef USE_THREAD
-       HA_RWLOCK_T lock;         /* lock related to the table entry */
-#endif
+       __decl_hathreads(HA_RWLOCK_T lock); /* lock related to the table entry */
        struct eb32_node exp;     /* ebtree node used to hold the session in expiration tree */
        struct eb32_node upd;     /* ebtree node used to hold the update sequence tree */
        struct ebmb_node key;     /* ebtree node used to hold the session in table */
@@ -146,9 +144,7 @@ struct stktable {
        struct eb_root exps;      /* head of sticky session expiration tree */
        struct eb_root updates;   /* head of sticky updates sequence tree */
        struct pool_head *pool;   /* pool used to allocate sticky sessions */
-#ifdef USE_THREAD
-       HA_SPINLOCK_T lock;       /* spin lock related to the table */
-#endif
+       __decl_hathreads(HA_SPINLOCK_T lock); /* spin lock related to the table */
        struct task *exp_task;    /* expiration task */
        struct task *sync_task;   /* sync task */
        unsigned int update;
index 70fc68119d70163ae00c7235331963c5b9f19eae..991e3a4672fbfbb260f05056e25e6c3c7711b239 100644 (file)
@@ -57,9 +57,7 @@ struct notification {
        struct list wake_me; /* Part of list of signals to be targeted if an
                                event occurs. */
        struct task *task; /* The task to be wake if an event occurs. */
-#ifdef USE_THREAD
-       HA_SPINLOCK_T lock;
-#endif
+       __decl_hathreads(HA_SPINLOCK_T lock);
 };
 
 /* The base for all tasks */
index 8a4f7aa35963aebf8bc3fc1a349e2b5131324fcf..9b166e9d650f59f69fcb8717b7e19792260cb5cd 100644 (file)
@@ -18,9 +18,7 @@ struct vars {
        struct list head;
        enum vars_scope scope;
        unsigned int size;
-#ifdef USE_THREAD
-       HA_RWLOCK_T rwlock;
-#endif
+       __decl_hathreads(HA_RWLOCK_T rwlock);
 };
 
 /* This struct describes a variable. */
index 0e550c262cd37c893d691d3a187e0da6fddd1d56..1df6b091ea0af7f062713af4e35ba3380b33ceca 100644 (file)
 
 unsigned int nb_applets = 0;
 unsigned int applets_active_queue = 0;
-
-#ifdef USE_THREAD
-HA_SPINLOCK_T applet_active_lock;        /* spin lock related to applet active queue */
-#endif
+__decl_hathreads(HA_SPINLOCK_T applet_active_lock);  /* spin lock related to applet active queue */
 
 struct list applet_active_queue = LIST_HEAD_INIT(applet_active_queue);
 
index b365888d089548d34d78fa8f906244248b5b7512..66d117a5ec15f82c578fe9d669c155435351c856 100644 (file)
@@ -33,9 +33,7 @@ struct buffer buf_wanted = { .p = buf_wanted.data };
 
 /* list of objects waiting for at least one buffer */
 struct list buffer_wq = LIST_HEAD_INIT(buffer_wq);
-#ifdef USE_THREAD
-HA_SPINLOCK_T buffer_wq_lock;
-#endif
+__decl_hathreads(HA_SPINLOCK_T buffer_wq_lock);
 
 /* this buffer is always the same size as standard buffers and is used for
  * swapping data inside a buffer.
index 8d5822a6a7064195ef669e3c8632c1652db66e8a..4b47cf390d3c7c6f019b6d801a59b118989b360b 100644 (file)
@@ -1613,9 +1613,7 @@ static int connect_conn_chk(struct task *t)
 
 static struct list pid_list = LIST_HEAD_INIT(pid_list);
 static struct pool_head *pool2_pid_list;
-#ifdef USE_THREAD
-HA_SPINLOCK_T pid_list_lock;
-#endif
+__decl_hathreads(HA_SPINLOCK_T pid_list_lock);
 
 void block_sigchld(void)
 {
index 594399a2ffe02512204c05e75fdd9b6fc141d38c..4961ef36e8ac5484fd8f05dbe8982e490472b6a9 100644 (file)
@@ -42,9 +42,7 @@
 
 
 #if defined(USE_SLZ) || defined(USE_ZLIB)
-#ifdef USE_THREAD
-static HA_SPINLOCK_T comp_pool_lock;
-#endif
+__decl_hathreads(static HA_SPINLOCK_T comp_pool_lock);
 #endif
 
 #ifdef USE_ZLIB
index d2e9569d50aa3cbaf162f057b85295adf04d69d5..9fb09ab715ad6ca8bed8f3ea29584bdb647b8af4 100644 (file)
--- a/src/fd.c
+++ b/src/fd.c
@@ -174,11 +174,9 @@ int fd_cache_num = 0;          // number of events in the cache
 THREAD_LOCAL int *fd_updt  = NULL;  // FD updates list
 THREAD_LOCAL int  fd_nbupdt = 0;   // number of updates in the list
 
-#ifdef USE_THREAD
-HA_SPINLOCK_T fdtab_lock;       /* global lock to protect fdtab array */
-HA_RWLOCK_T   fdcache_lock;     /* global lock to protect fd_cache array */
-HA_SPINLOCK_T poll_lock;        /* global lock to protect poll info */
-#endif
+__decl_hathreads(HA_SPINLOCK_T fdtab_lock);       /* global lock to protect fdtab array */
+__decl_hathreads(HA_RWLOCK_T   fdcache_lock);     /* global lock to protect fd_cache array */
+__decl_hathreads(HA_SPINLOCK_T poll_lock);        /* global lock to protect poll info */
 
 /* Deletes an FD from the fdsets, and recomputes the maxfd limit.
  * The file descriptor is also closed.
index 439bbf45690c66c2750766bffc404651ff24c766..dbdc975c5c518b02a920125b4cd2f8de6ec4caa6 100644 (file)
  * and RESET_SAFE_LJMP manipulates the Lua stack, so it will be careful
  * to set mutex around these functions.
  */
-#ifdef USE_THREAD
-HA_SPINLOCK_T hlua_global_lock;
-#endif
+__decl_hathreads(HA_SPINLOCK_T hlua_global_lock);
 THREAD_LOCAL jmp_buf safe_ljmp_env;
 static int hlua_panic_safe(lua_State *L) { return 0; }
 static int hlua_panic_ljmp(lua_State *L) { longjmp(safe_ljmp_env, 1); }
index a6bd4497bded621f6603fadb82bdb0bbb00001df..c7db79a89b173955d9a168432a18f8e0c3841429 100644 (file)
 #include <proto/stream.h>
 #include <proto/task.h>
 
-#ifdef USE_THREAD
  /* listner_queue lock (same for global and per proxy queues) */
-static HA_SPINLOCK_T lq_lock;
-#endif
+__decl_hathreads(static HA_SPINLOCK_T lq_lock);
 
 /* List head of all known bind keywords */
 static struct bind_kw_list bind_keywords = {
index 47e8aeeb8d8702de36bc9016655002d54d784432..fe672f12e8314029f8cb7593d499d35ec3922b9f 100644 (file)
@@ -155,9 +155,7 @@ static THREAD_LOCAL struct sample_data static_sample_data;
 struct list pattern_reference = LIST_HEAD_INIT(pattern_reference);
 
 static struct lru64_head *pat_lru_tree;
-#ifdef USE_THREAD
-HA_SPINLOCK_T pat_lru_tree_lock;
-#endif
+__decl_hathreads(HA_SPINLOCK_T pat_lru_tree_lock);
 static unsigned long long pat_lru_seed;
 
 /*
index c161f960f52fe28cd9992b9a382a4be8f754e116..bab86203e7ee5fc2f1b685a3e996d818d4a868e5 100644 (file)
@@ -22,9 +22,9 @@
 
 struct pool_head *pool2_pipe = NULL;
 struct pipe *pipes_live = NULL; /* pipes which are still ready to use */
-#ifdef USE_THREAD
-HA_SPINLOCK_T pipes_lock;       /* lock used to protect pipes list */
-#endif
+
+__decl_hathreads(HA_SPINLOCK_T pipes_lock); /* lock used to protect pipes list */
+
 int pipes_used = 0;             /* # of pipes in use (2 fds each) */
 int pipes_free = 0;             /* # of pipes unused */
 
index d79e9512f88ad51c692027ebdafdec8103bb27c8..5e995f8a781a68f8513e8931fefdc7a23a7ed139 100644 (file)
 #include <netinet/tcp.h>
 
 struct list updated_servers = LIST_HEAD_INIT(updated_servers);
-
-#ifdef USE_THREAD
-HA_SPINLOCK_T updated_servers_lock;
-#endif
+__decl_hathreads(HA_SPINLOCK_T updated_servers_lock);
 
 static void srv_register_update(struct server *srv);
 static void srv_update_state(struct server *srv, int version, char **params);
index 3409e760695fb9feae5684a1c5a311ac9cb72093..e996c46d6d03566e4e3a32feea03faa7789bd6de 100644 (file)
@@ -31,9 +31,7 @@ struct pool_head *pool2_sig_handlers = NULL;
 sigset_t blocked_sig;
 int signal_pending = 0; /* non-zero if t least one signal remains unprocessed */
 
-#ifdef USE_THREAD
-HA_SPINLOCK_T signals_lock;
-#endif
+__decl_hathreads(HA_SPINLOCK_T signals_lock);
 
 /* Common signal handler, used by all signals. Received signals are queued.
  * Signal number zero has a specific status, as it cannot be delivered by the
index 72d9b8aeee5dfd4b019d7f2b06ee9f1672dd5a4a..25f3ecaaffecd68ed2d163272859cfcfa8bf9dac 100644 (file)
@@ -206,6 +206,7 @@ static struct {
 };
 
 #ifdef USE_THREAD
+
 static HA_RWLOCK_T *ssl_rwlocks;
 
 
@@ -246,6 +247,7 @@ static int ssl_locking_init(void)
 
        return 0;
 }
+
 #endif
 
 
@@ -302,10 +304,7 @@ static char *x509v3_ext_values[X509V3_EXT_SIZE] = {
 static struct lru64_head *ssl_ctx_lru_tree = NULL;
 static unsigned int       ssl_ctx_lru_seed = 0;
 static unsigned int      ssl_ctx_serial;
-
-#ifdef USE_THREAD
-static HA_RWLOCK_T ssl_ctx_lru_rwlock;
-#endif
+__decl_hathreads(static HA_RWLOCK_T ssl_ctx_lru_rwlock);
 
 #endif // SSL_CTRL_SET_TLSEXT_HOSTNAME
 
index 19d94f39b42043f604cb62adad6df14001a082e6..d71b6ce8174589afa3d90392828354928b42a895 100644 (file)
 
 struct pool_head *pool2_stream;
 struct list streams;
+__decl_hathreads(HA_SPINLOCK_T streams_lock);
 
-#ifdef USE_THREAD
-HA_SPINLOCK_T streams_lock;
-#endif
 /* List of all use-service keywords. */
 static struct list service_keywords = LIST_HEAD_INIT(service_keywords);
 
index 98829038e41c0e96ecc03a2bf35452b58cde3c88..4f9b049ca5c97e1c147fc3d1c462957b3d675bab 100644 (file)
@@ -37,10 +37,8 @@ unsigned int tasks_run_queue_cur = 0;    /* copy of the run queue size */
 unsigned int nb_tasks_cur = 0;     /* copy of the tasks count */
 unsigned int niced_tasks = 0;      /* number of niced tasks in the run queue */
 
-#ifdef USE_THREAD
-HA_SPINLOCK_T rq_lock;        /* spin lock related to run queue */
-HA_SPINLOCK_T wq_lock;        /* spin lock related to wait queue */
-#endif
+__decl_hathreads(HA_SPINLOCK_T rq_lock); /* spin lock related to run queue */
+__decl_hathreads(HA_SPINLOCK_T wq_lock); /* spin lock related to wait queue */
 
 static struct eb_root timers;      /* sorted timers tree */
 static struct eb_root rqueue;      /* tree constituting the run queue */
index fef36855d5513d04d4940a325e31ae272eac994f..2192fa5ebd296966fad76f8afbbeaa65087b1c5f 100644 (file)
@@ -32,9 +32,7 @@ static unsigned int var_txn_limit = 0;
 static unsigned int var_reqres_limit = 0;
 
 
-#ifdef USE_THREAD
-HA_RWLOCK_T   var_names_rwlock;
-#endif
+__decl_hathreads(HA_RWLOCK_T var_names_rwlock);
 
 /* This function adds or remove memory size from the accounting. The inner
  * pointers may be null when setting the outer ones only.