From b4811b918bdb099446c0dcd13983d5e00fbe5595 Mon Sep 17 00:00:00 2001 From: koichirok <koichiro@rworks.jp> Date: Tue, 12 Aug 2014 06:18:57 +0000 Subject: [PATCH] 2014-08-12 Koichiro Kikuchi <koichiro@rworks.jp> * bin/pandora_server: Fixed issue that pandora_server failed to shut down properly on non-Linux systems. Merged r10335 from branch 5.0. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@10402 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_server/ChangeLog | 7 +++++++ pandora_server/bin/pandora_server | 11 +++++++++++ 2 files changed, 18 insertions(+) diff --git a/pandora_server/ChangeLog b/pandora_server/ChangeLog index 147dfca0ca..e6083fdeb2 100644 --- a/pandora_server/ChangeLog +++ b/pandora_server/ChangeLog @@ -1,3 +1,10 @@ +2014-08-12 Koichiro Kikuchi <koichiro@rworks.jp> + + * bin/pandora_server: Fixed issue that pandora_server failed to + shut down properly on non-Linux systems. + + Merged r10335 from branch 5.0. + 2014-08-12 Koichiro Kikuchi <koichiro@rworks.jp> * pandora_server_installer: Refactord implementation, added diff --git a/pandora_server/bin/pandora_server b/pandora_server/bin/pandora_server index 316e9ca69c..79b18c6fb0 100755 --- a/pandora_server/bin/pandora_server +++ b/pandora_server/bin/pandora_server @@ -47,11 +47,22 @@ my %Config :shared; my @Servers; my $DBH; my $RUN :shared = 1; +my $MainThread = threads->self; ######################################################################################## # Server shutdown. Handler to do a controlled shutdown. ######################################################################################## sub pandora_shutdown () { + my $signal = shift; + + logger (\%Config, 'Pandora FMS Server \'' . $Config{'servername'} . '\' Caught SIG' . $signal . ' by thread(' . threads->self()->tid() . ')', 10); + + if (!threads->self->equal($MainThread)) { + # deliver signal to the main thread since no other threads than main thread + # could disconnet $DBH properly + $MainThread->kill($signal); + return; + } logger (\%Config, 'Pandora FMS Server \'' . $Config{'servername'} . '\' Shutdown by signal ', 1); # Stop servers