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);
/* 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);
+
volatile unsigned long sleeping_thread_mask; /* Threads that are about to sleep in poll() */
/* global options */
struct global global = {
*/
#ifdef USE_THREAD
{
- pthread_t *threads = calloc(global.nbthread, sizeof(pthread_t));
- int i;
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);
pthread_join(threads[i], NULL);
free(threads);
+ threads = NULL;
#if defined(DEBUG_THREAD) || defined(DEBUG_FULL)
show_lock_stats();