extern unsigned int rlim_fd_cur_at_boot;
extern unsigned int rlim_fd_max_at_boot;
extern int atexit_flag;
-__decl_hathreads(extern pthread_t *threads);
+
+extern struct thread_info {
+ __decl_hathreads(pthread_t pthread);
+} thread_info[MAX_THREADS];
/* bit values to go with "warned" above */
#define WARN_BLOCK_DEPRECATED 0x00000001
unsigned long pid_bit = 1; /* bit corresponding to the process id */
unsigned long all_proc_mask = 1; /* mask of all processes */
-__decl_hathreads(pthread_t *threads = NULL);
+struct thread_info thread_info[MAX_THREADS] = { };
volatile unsigned long sleeping_thread_mask; /* Threads that are about to sleep in poll() */
/* global options */
sigset_t blocked_sig, old_sig;
int i;
- threads = calloc(global.nbthread, sizeof(*threads));
- if (!threads) {
- ha_alert("Cannot allocate memory for threads.\n");
- protocol_unbind_all();
- exit(1);
- }
-
/* ensure the signals will be blocked in every thread */
sigfillset(&blocked_sig);
sigdelset(&blocked_sig, SIGPROF);
threads_want_rdv_mask = all_threads_mask;
/* Create nbthread-1 thread. The first thread is the current process */
- threads[0] = pthread_self();
+ thread_info[0].pthread = pthread_self();
for (i = 1; i < global.nbthread; i++)
- pthread_create(&threads[i], NULL, &run_thread_poll_loop, (void *)(long)i);
+ pthread_create(&thread_info[i].pthread, NULL, &run_thread_poll_loop, (void *)(long)i);
#ifdef USE_CPU_AFFINITY
/* Now the CPU affinity for all threads */
CPU_SET(j - 1, &cpuset);
cpu_map &= ~(1UL << (j - 1));
}
- pthread_setaffinity_np(threads[i],
+ pthread_setaffinity_np(thread_info[i].pthread,
sizeof(cpuset), &cpuset);
}
}
/* Wait the end of other threads */
for (i = 1; i < global.nbthread; i++)
- pthread_join(threads[i], NULL);
-
- free(threads);
- threads = NULL;
+ pthread_join(thread_info[i].pthread, NULL);
#if defined(DEBUG_THREAD) || defined(DEBUG_FULL)
show_lock_stats();