mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2025-01-30 10:06:43 +00:00
MINOR: init/threads: make the threads array global
Currently the thread array is a local variable inside a function block and there is no access to it from outside, which often complicates debugging. Let's make it global and export it. Also the allocation return is now checked.
This commit is contained in:
parent
b4f7cc3839
commit
c40efc1919
@ -242,6 +242,7 @@ extern int master; /* 1 if in master, 0 otherwise */
|
||||
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
|
||||
|
@ -139,6 +139,8 @@ int relative_pid = 1; /* process id starting at 1 */
|
||||
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 = {
|
||||
@ -3125,9 +3127,15 @@ int main(int argc, char **argv)
|
||||
*/
|
||||
#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);
|
||||
@ -3182,6 +3190,7 @@ int main(int argc, char **argv)
|
||||
pthread_join(threads[i], NULL);
|
||||
|
||||
free(threads);
|
||||
threads = NULL;
|
||||
|
||||
#if defined(DEBUG_THREAD) || defined(DEBUG_FULL)
|
||||
show_lock_stats();
|
||||
|
Loading…
Reference in New Issue
Block a user