From: Eric Bollengier Date: Fri, 23 Oct 2009 17:02:05 +0000 (+0200) Subject: Fix deadlock detection to work in daemon mode X-Git-Tag: Release-5.0.0~281^2~53 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=8bc88a2fabedefa8a54ef08d293a490a4bbc20a6;p=bacula%2Fbacula Fix deadlock detection to work in daemon mode --- diff --git a/bacula/src/dird/dird.c b/bacula/src/dird/dird.c index 86e73503a9..3975d50b41 100644 --- a/bacula/src/dird/dird.c +++ b/bacula/src/dird/dird.c @@ -261,13 +261,19 @@ int main (int argc, char *argv[]) if (background) { daemon_start(); init_stack_dump(); /* grab new pid */ - } - + } /* Create pid must come after we are a daemon -- so we have our final pid */ - create_pid_file(director->pid_directory, "bacula-dir", get_first_port_host_order(director->DIRaddrs)); - read_state_file(director->working_directory, "bacula-dir", get_first_port_host_order(director->DIRaddrs)); + create_pid_file(director->pid_directory, "bacula-dir", + get_first_port_host_order(director->DIRaddrs)); + read_state_file(director->working_directory, "bacula-dir", + get_first_port_host_order(director->DIRaddrs)); } + set_jcr_in_tsd(INVALID_JCR); + set_thread_concurrency(director->MaxConcurrentJobs * 2 + + 4 /* UA */ + 5 /* sched+watchdog+jobsvr+misc */); + lmgr_init_thread(); /* initialize the lockmanager stack */ + load_dir_plugins(director->plugin_directory); drop(uid, gid, false); /* reduce privileges if requested */ @@ -310,10 +316,6 @@ int main (int argc, char *argv[]) init_python_interpreter(&python_args); #endif /* HAVE_PYTHON */ - set_jcr_in_tsd(INVALID_JCR); - set_thread_concurrency(director->MaxConcurrentJobs * 2 + - 4 /* UA */ + 4 /* sched+watchdog+jobsvr+misc */); - Dmsg0(200, "Start UA server\n"); start_UA_server(director->DIRaddrs); diff --git a/bacula/src/filed/filed.c b/bacula/src/filed/filed.c index a8ee0b2163..aa4ea35ace 100644 --- a/bacula/src/filed/filed.c +++ b/bacula/src/filed/filed.c @@ -231,9 +231,14 @@ int main (int argc, char *argv[]) init_stack_dump(); /* set new pid */ } + set_thread_concurrency(me->MaxConcurrentJobs + 10); + lmgr_init_thread(); /* initialize the lockmanager stack */ + /* Maximum 1 daemon at a time */ - create_pid_file(me->pid_directory, "bacula-fd", get_first_port_host_order(me->FDaddrs)); - read_state_file(me->working_directory, "bacula-fd", get_first_port_host_order(me->FDaddrs)); + create_pid_file(me->pid_directory, "bacula-fd", + get_first_port_host_order(me->FDaddrs)); + read_state_file(me->working_directory, "bacula-fd", + get_first_port_host_order(me->FDaddrs)); load_fd_plugins(me->plugin_directory); @@ -255,8 +260,6 @@ int main (int argc, char *argv[]) init_python_interpreter(&python_args); #endif /* HAVE_PYTHON */ - set_thread_concurrency(10); - if (!no_signals) { start_watchdog(); /* start watchdog thread */ init_jcr_subsystem(); /* start JCR watchdogs etc. */ diff --git a/bacula/src/lib/signal.c b/bacula/src/lib/signal.c index e51010b08d..94500d8e06 100644 --- a/bacula/src/lib/signal.c +++ b/bacula/src/lib/signal.c @@ -232,7 +232,6 @@ extern "C" void signal_handler(int sig) void init_stack_dump(void) { main_pid = getpid(); /* save main thread's pid */ - lmgr_init_thread(); /* initialize the lockmanager stack */ } /* diff --git a/bacula/src/stored/bextract.c b/bacula/src/stored/bextract.c index b96f7dfd66..71c9da6bcb 100644 --- a/bacula/src/stored/bextract.c +++ b/bacula/src/stored/bextract.c @@ -105,6 +105,7 @@ int main (int argc, char *argv[]) bindtextdomain("bacula", LOCALEDIR); textdomain("bacula"); init_stack_dump(); + lmgr_init_thread(); working_directory = "/tmp"; my_name_is(argc, argv, "bextract"); diff --git a/bacula/src/stored/bls.c b/bacula/src/stored/bls.c index d8149750af..c7158c9b6b 100644 --- a/bacula/src/stored/bls.c +++ b/bacula/src/stored/bls.c @@ -110,6 +110,7 @@ int main (int argc, char *argv[]) bindtextdomain("bacula", LOCALEDIR); textdomain("bacula"); init_stack_dump(); + lmgr_init_thread(); working_directory = "/tmp"; my_name_is(argc, argv, "bls"); diff --git a/bacula/src/stored/bscan.c b/bacula/src/stored/bscan.c index fb04bc4c69..113915f572 100644 --- a/bacula/src/stored/bscan.c +++ b/bacula/src/stored/bscan.c @@ -150,6 +150,7 @@ int main (int argc, char *argv[]) bindtextdomain("bacula", LOCALEDIR); textdomain("bacula"); init_stack_dump(); + lmgr_init_thread(); my_name_is(argc, argv, "bscan"); init_msg(NULL, NULL); diff --git a/bacula/src/stored/stored.c b/bacula/src/stored/stored.c index 3ee885bad8..8c0bd6f416 100644 --- a/bacula/src/stored/stored.c +++ b/bacula/src/stored/stored.c @@ -256,8 +256,14 @@ int main (int argc, char *argv[]) init_stack_dump(); /* pick up new pid */ } - create_pid_file(me->pid_directory, "bacula-sd", get_first_port_host_order(me->sdaddrs)); - read_state_file(me->working_directory, "bacula-sd", get_first_port_host_order(me->sdaddrs)); + create_pid_file(me->pid_directory, "bacula-sd", + get_first_port_host_order(me->sdaddrs)); + read_state_file(me->working_directory, "bacula-sd", + get_first_port_host_order(me->sdaddrs)); + + /* Make sure on Solaris we can run concurrent, watch dog + servers + misc */ + set_thread_concurrency(me->max_concurrent_jobs * 2 + 4); + lmgr_init_thread(); /* initialize the lockmanager stack */ load_sd_plugins(me->plugin_directory); @@ -286,9 +292,6 @@ int main (int argc, char *argv[]) init_python_interpreter(&python_args); #endif /* HAVE_PYTHON */ - /* Make sure on Solaris we can run concurrent, watch dog + servers + misc */ - set_thread_concurrency(me->max_concurrent_jobs * 2 + 4); - /* * Start the device allocation thread */ diff --git a/bacula/src/tools/bbatch.c b/bacula/src/tools/bbatch.c index 286b908596..46bc909c07 100644 --- a/bacula/src/tools/bbatch.c +++ b/bacula/src/tools/bbatch.c @@ -103,6 +103,7 @@ int main (int argc, char *argv[]) bindtextdomain("bacula", LOCALEDIR); textdomain("bacula"); init_stack_dump(); + lmgr_init_thread(); char **files = (char **) malloc (10 * sizeof(char *)); int i; diff --git a/regress/tests/messages-test b/regress/tests/messages-test index 918943805f..a8456a79a8 100755 --- a/regress/tests/messages-test +++ b/regress/tests/messages-test @@ -33,7 +33,7 @@ cat <$tmp/bconcmds @$out /dev/null messages @$out $tmp/log1.out -setdebug level=100 storage=File +@#setdebug level=100 storage=File label volume=TestVolume001 storage=File pool=File run job=$JobName yes @sleep 1