mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-09-22 06:11:32 +02:00
MINOR: thread: make "ti" a const pointer and clean up thread_info a bit
We want to make sure that the current thread_info accessed via "ti" will remain constant, so that we don't accidentally place new variable parts there and so that the compiler knows that info retrieved from there is not expected to have changed between two function calls. Only a few init locations had to be adjusted to use the array and the rest is unaffected.
This commit is contained in:
parent
b4e34766a3
commit
6036342f58
@ -39,7 +39,9 @@ enum {
|
||||
#define TH_FL_STUCK 0x00000001
|
||||
|
||||
/* This structure describes all the per-thread info we need. When threads are
|
||||
* disabled, it contains the same info for the single running thread.
|
||||
* disabled, it contains the same info for the single running thread. This is
|
||||
* stable across all of a thread's life, and is being pointed to by the
|
||||
* thread-local "ti" pointer.
|
||||
*/
|
||||
struct thread_info {
|
||||
/* pad to cache line (64B) */
|
||||
|
@ -27,7 +27,7 @@
|
||||
|
||||
/* the structs are in thread.c */
|
||||
extern struct thread_info ha_thread_info[MAX_THREADS];
|
||||
extern THREAD_LOCAL struct thread_info *ti; /* thread_info for the current thread */
|
||||
extern THREAD_LOCAL const struct thread_info *ti; /* thread_info for the current thread */
|
||||
|
||||
extern struct thread_ctx ha_thread_ctx[MAX_THREADS];
|
||||
extern THREAD_LOCAL struct thread_ctx *th_ctx; /* ha_thread_ctx for the current thread */
|
||||
|
@ -51,7 +51,7 @@
|
||||
#include <haproxy/tools.h>
|
||||
|
||||
struct thread_info ha_thread_info[MAX_THREADS] = { };
|
||||
THREAD_LOCAL struct thread_info *ti = &ha_thread_info[0];
|
||||
THREAD_LOCAL const struct thread_info *ti = &ha_thread_info[0];
|
||||
|
||||
struct thread_ctx ha_thread_ctx[MAX_THREADS] = { };
|
||||
THREAD_LOCAL struct thread_ctx *th_ctx = &ha_thread_ctx[0];
|
||||
|
Loading…
x
Reference in New Issue
Block a user