]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUILD/MEDIUM: threads: rename thread_info struct to ha_thread_info
authorDavid Carlier <devnexen@gmail.com>
Fri, 13 Sep 2019 04:03:12 +0000 (05:03 +0100)
committerWilly Tarreau <w@1wt.eu>
Thu, 17 Oct 2019 05:15:17 +0000 (07:15 +0200)
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.

include/common/hathreads.h
src/debug.c
src/haproxy.c
src/hathreads.c
src/wdt.c

index 8e780142ca4f8d3d5f561594e141117ef4e61745..02568de12ac1400254cbf2b830925413708b0e34 100644 (file)
@@ -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 @@ extern struct thread_info {
        /* 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 @@ extern THREAD_LOCAL struct thread_info *ti; /* thread_info for the current threa
 
 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 @@ extern struct thread_info {
        /* 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 @@ static inline void ha_set_tid(unsigned int data)
 {
        tid     = data;
        tid_bit = (1UL << tid);
-       ti      = &thread_info[tid];
+       ti      = &ha_thread_info[tid];
 }
 
 static inline void ha_thread_relax(void)
index 5c4aa880ae57fcecd29519e9ae5e48da606b166f..8dbc4184887194a9b590a760e9d39646b9c19917 100644 (file)
@@ -45,9 +45,9 @@ volatile unsigned long threads_to_dump = 0;
 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"
index 05b0afa32f2b6ca40b49c9b841a8282299172801..db6f21f560684efe13447c774f68abe08cf3073d 100644 (file)
@@ -3362,9 +3362,9 @@ int main(int argc, char **argv)
                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 @@ int main(int argc, char **argv)
                                        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 @@ int main(int argc, char **argv)
 
                /* 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();
index 69385236793c09b9ea52552991f6269dad25dcf3..14c5658978d3fbbaf6575447acea86fb8eedde27 100644 (file)
@@ -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 @@ void thread_sync_release()
 /* 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 @@ void ha_tkillall(int sig)
                        continue;
                if (thr == tid)
                        continue;
-               pthread_kill(thread_info[thr].pthread, sig);
+               pthread_kill(ha_thread_info[thr].pthread, sig);
        }
        raise(sig);
 }
index aa89fd443e76e73c6bcca73a168534c4f3819316..8f31e94920975a5cb27ec515e90529069b521583 100644 (file)
--- a/src/wdt.c
+++ b/src/wdt.c
@@ -43,7 +43,7 @@ int wdt_ping(int thr)
 
        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 @@ void wdt_handler(int sig, siginfo_t *si, void *arg)
                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 @@ void wdt_handler(int sig, siginfo_t *si, void *arg)
                 * 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 @@ void wdt_handler(int sig, siginfo_t *si, void *arg)
         * 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;