BUILD/MEDIUM: threads: rename thread_info struct to ha_thread_info
On Darwin, the thread_info name exists as a standard function thus
we need to rename our array to ha_thread_info to fix this conflict.
diff --git a/include/common/hathreads.h b/include/common/hathreads.h
index 8e78014..02568de 100644
--- a/include/common/hathreads.h
+++ b/include/common/hathreads.h
@@ -38,7 +38,7 @@
* only one thread is enabled, it equals 1.
*/
-/* thread info flags, for thread_info[].flags */
+/* thread info flags, for ha_thread_info[].flags */
#define TI_FL_STUCK 0x00000001
@@ -67,7 +67,7 @@
/* pad to cache line (64B) */
char __pad[0]; /* unused except to check remaining room */
char __end[0] __attribute__((aligned(64)));
-} thread_info[MAX_THREADS];
+} ha_thread_info[MAX_THREADS];
extern THREAD_LOCAL struct thread_info *ti; /* thread_info for the current thread */
@@ -167,7 +167,7 @@
static inline void ha_set_tid(unsigned int tid)
{
- ti = &thread_info[tid];
+ ti = &ha_thread_info[tid];
}
static inline void ha_thread_relax(void)
@@ -437,7 +437,7 @@
/* pad to cache line (64B) */
char __pad[0]; /* unused except to check remaining room */
char __end[0] __attribute__((aligned(64)));
-} thread_info[MAX_THREADS];
+} ha_thread_info[MAX_THREADS];
extern THREAD_LOCAL unsigned int tid; /* The thread id */
extern THREAD_LOCAL unsigned long tid_bit; /* The bit corresponding to the thread id */
@@ -480,7 +480,7 @@
{
tid = data;
tid_bit = (1UL << tid);
- ti = &thread_info[tid];
+ ti = &ha_thread_info[tid];
}
static inline void ha_thread_relax(void)
diff --git a/src/debug.c b/src/debug.c
index 5c4aa88..8dbc418 100644
--- a/src/debug.c
+++ b/src/debug.c
@@ -45,9 +45,9 @@
void ha_thread_dump(struct buffer *buf, int thr, int calling_tid)
{
unsigned long thr_bit = 1UL << thr;
- unsigned long long p = thread_info[thr].prev_cpu_time;
- unsigned long long n = now_cpu_time_thread(&thread_info[thr]);
- int stuck = !!(thread_info[thr].flags & TI_FL_STUCK);
+ unsigned long long p = ha_thread_info[thr].prev_cpu_time;
+ unsigned long long n = now_cpu_time_thread(&ha_thread_info[thr]);
+ int stuck = !!(ha_thread_info[thr].flags & TI_FL_STUCK);
chunk_appendf(buf,
"%c%cThread %-2u: act=%d glob=%d wq=%d rq=%d tl=%d tlsz=%d rqsz=%d\n"
diff --git a/src/haproxy.c b/src/haproxy.c
index 05b0afa..db6f21f 100644
--- a/src/haproxy.c
+++ b/src/haproxy.c
@@ -3362,9 +3362,9 @@
pthread_sigmask(SIG_SETMASK, &blocked_sig, &old_sig);
/* Create nbthread-1 thread. The first thread is the current process */
- thread_info[0].pthread = pthread_self();
+ ha_thread_info[0].pthread = pthread_self();
for (i = 1; i < global.nbthread; i++)
- pthread_create(&thread_info[i].pthread, NULL, &run_thread_poll_loop, (void *)(long)i);
+ pthread_create(&ha_thread_info[i].pthread, NULL, &run_thread_poll_loop, (void *)(long)i);
#ifdef USE_CPU_AFFINITY
/* Now the CPU affinity for all threads */
@@ -3391,7 +3391,7 @@
CPU_SET(j - 1, &cpuset);
cpu_map &= ~(1UL << (j - 1));
}
- pthread_setaffinity_np(thread_info[i].pthread,
+ pthread_setaffinity_np(ha_thread_info[i].pthread,
sizeof(cpuset), &cpuset);
}
}
@@ -3405,7 +3405,7 @@
/* Wait the end of other threads */
for (i = 1; i < global.nbthread; i++)
- pthread_join(thread_info[i].pthread, NULL);
+ pthread_join(ha_thread_info[i].pthread, NULL);
#if defined(DEBUG_THREAD) || defined(DEBUG_FULL)
show_lock_stats();
diff --git a/src/hathreads.c b/src/hathreads.c
index 6938523..14c5658 100644
--- a/src/hathreads.c
+++ b/src/hathreads.c
@@ -29,8 +29,8 @@
#include <types/global.h>
#include <proto/fd.h>
-struct thread_info thread_info[MAX_THREADS] = { };
-THREAD_LOCAL struct thread_info *ti = &thread_info[0];
+struct thread_info ha_thread_info[MAX_THREADS] = { };
+THREAD_LOCAL struct thread_info *ti = &ha_thread_info[0];
#ifdef USE_THREAD
@@ -134,7 +134,7 @@
/* send signal <sig> to thread <thr> */
void ha_tkill(unsigned int thr, int sig)
{
- pthread_kill(thread_info[thr].pthread, sig);
+ pthread_kill(ha_thread_info[thr].pthread, sig);
}
/* send signal <sig> to all threads. The calling thread is signaled last in
@@ -149,7 +149,7 @@
continue;
if (thr == tid)
continue;
- pthread_kill(thread_info[thr].pthread, sig);
+ pthread_kill(ha_thread_info[thr].pthread, sig);
}
raise(sig);
}
diff --git a/src/wdt.c b/src/wdt.c
index aa89fd4..8f31e94 100644
--- a/src/wdt.c
+++ b/src/wdt.c
@@ -43,7 +43,7 @@
its.it_value.tv_sec = 1; its.it_value.tv_nsec = 0;
its.it_interval.tv_sec = 0; its.it_interval.tv_nsec = 0;
- return timer_settime(thread_info[thr].wd_timer, 0, &its, NULL) == 0;
+ return timer_settime(ha_thread_info[thr].wd_timer, 0, &its, NULL) == 0;
}
/* This is the WDTSIG signal handler */
@@ -68,8 +68,8 @@
if (thr < 0 || thr >= global.nbthread)
break;
- p = thread_info[thr].prev_cpu_time;
- n = now_cpu_time_thread(&thread_info[thr]);
+ p = ha_thread_info[thr].prev_cpu_time;
+ n = now_cpu_time_thread(&ha_thread_info[thr]);
/* not yet reached the deadline of 1 sec */
if (n - p < 1000000000UL)
@@ -94,8 +94,8 @@
* If it's already set, then it's our second call with no
* progress and the thread is dead.
*/
- if (!(thread_info[thr].flags & TI_FL_STUCK)) {
- _HA_ATOMIC_OR(&thread_info[thr].flags, TI_FL_STUCK);
+ if (!(ha_thread_info[thr].flags & TI_FL_STUCK)) {
+ _HA_ATOMIC_OR(&ha_thread_info[thr].flags, TI_FL_STUCK);
goto update_and_leave;
}
@@ -118,7 +118,7 @@
* the current one not involved in this.
*/
if (thr != tid)
- pthread_kill(thread_info[thr].pthread, sig);
+ pthread_kill(ha_thread_info[thr].pthread, sig);
else
ha_panic();
return;