"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "lib/cli/daemoncommand.cpp" between
icinga2-2.11.5.tar.gz and icinga2-2.12.0.tar.gz

About: Icinga 2 is an enterprise grade monitoring system which keeps watch over networks and any conceivable network resource.

daemoncommand.cpp  (icinga2-2.11.5):daemoncommand.cpp  (icinga2-2.12.0)
skipping to change at line 194 skipping to change at line 194
} }
#ifndef _WIN32 #ifndef _WIN32
// The PID of the Icinga umbrella process // The PID of the Icinga umbrella process
pid_t l_UmbrellaPid = 0; pid_t l_UmbrellaPid = 0;
// Whether the umbrella process allowed us to continue working beyond config val idation // Whether the umbrella process allowed us to continue working beyond config val idation
static Atomic<bool> l_AllowedToWork (false); static Atomic<bool> l_AllowedToWork (false);
#endif /* _WIN32 */ #endif /* _WIN32 */
#ifdef I2_DEBUG
/**
* Determine whether the developer wants to delay the worker process to attach a
debugger to it.
*
* @return Internal.DebugWorkerDelay double
*/
static double GetDebugWorkerDelay()
{
Namespace::Ptr internal = ScriptGlobal::Get("Internal", &Empty);
Value vdebug;
if (internal && internal->Get("DebugWorkerDelay", &vdebug))
return Convert::ToDouble(vdebug);
return 0.0;
}
#endif /* I2_DEBUG */
/** /**
* Do the actual work (config loading, ...) * Do the actual work (config loading, ...)
* *
* @param configs Files to read config from * @param configs Files to read config from
* @param closeConsoleLog Whether to close the console log after config loading * @param closeConsoleLog Whether to close the console log after config loading
* @param stderrFile Where to log errors * @param stderrFile Where to log errors
* *
* @return Exit code * @return Exit code
*/ */
static inline static inline
int RunWorker(const std::vector<std::string>& configs, bool closeConsoleLog = fa lse, const String& stderrFile = String()) int RunWorker(const std::vector<std::string>& configs, bool closeConsoleLog = fa lse, const String& stderrFile = String())
{ {
#ifdef I2_DEBUG
double delay = GetDebugWorkerDelay();
if (delay > 0.0) {
Log(LogInformation, "RunWorker")
<< "DEBUG: Current PID: " << Utility::GetPid() << ". Slee
ping for " << delay << " seconds to allow lldb/gdb -p <PID> attachment.";
Utility::Sleep(delay);
}
#endif /* I2_DEBUG */
Log(LogInformation, "cli", "Loading configuration file(s)."); Log(LogInformation, "cli", "Loading configuration file(s).");
{ {
std::vector<ConfigItem::Ptr> newItems; std::vector<ConfigItem::Ptr> newItems;
if (!DaemonUtility::LoadConfigFiles(configs, newItems, Configurat ion::ObjectsPath, Configuration::VarsPath)) { if (!DaemonUtility::LoadConfigFiles(configs, newItems, Configurat ion::ObjectsPath, Configuration::VarsPath)) {
Log(LogCritical, "cli", "Config validation failed. Re-run with 'icinga2 daemon -C' after fixing the config."); Log(LogCritical, "cli", "Config validation failed. Re-run with 'icinga2 daemon -C' after fixing the config.");
return EXIT_FAILURE; return EXIT_FAILURE;
} }
skipping to change at line 327 skipping to change at line 357
*/ */
static void UmbrellaSignalHandler(int num, siginfo_t *info, void*) static void UmbrellaSignalHandler(int num, siginfo_t *info, void*)
{ {
switch (num) { switch (num) {
case SIGUSR1: case SIGUSR1:
// Someone requested to re-open logs // Someone requested to re-open logs
l_RequestedReopenLogs.store(true); l_RequestedReopenLogs.store(true);
break; break;
case SIGUSR2: case SIGUSR2:
if (l_CurrentlyStartingUnixWorkerState.load() == UnixWork erState::Pending if (l_CurrentlyStartingUnixWorkerState.load() == UnixWork erState::Pending
&& info->si_pid == l_CurrentlyStartingUnixWorkerP id.load()) { && (info->si_pid == 0 || info->si_pid == l_Curren tlyStartingUnixWorkerPid.load()) ) {
// The seemless worker currently being started by StartUnixWorker() successfully loaded its config // The seemless worker currently being started by StartUnixWorker() successfully loaded its config
l_CurrentlyStartingUnixWorkerState.store(UnixWork erState::LoadedConfig); l_CurrentlyStartingUnixWorkerState.store(UnixWork erState::LoadedConfig);
} }
break; break;
case SIGCHLD: case SIGCHLD:
if (l_CurrentlyStartingUnixWorkerState.load() == UnixWork erState::Pending if (l_CurrentlyStartingUnixWorkerState.load() == UnixWork erState::Pending
&& info->si_pid == l_CurrentlyStartingUnixWorkerP id.load()) { && (info->si_pid == 0 || info->si_pid == l_Curren tlyStartingUnixWorkerPid.load()) ) {
// The seemless worker currently being started by StartUnixWorker() failed // The seemless worker currently being started by StartUnixWorker() failed
l_CurrentlyStartingUnixWorkerState.store(UnixWork erState::Failed); l_CurrentlyStartingUnixWorkerState.store(UnixWork erState::Failed);
} }
break; break;
case SIGINT: case SIGINT:
case SIGTERM: case SIGTERM:
// Someone requested our termination // Someone requested our termination
{ {
struct sigaction sa; struct sigaction sa;
skipping to change at line 371 skipping to change at line 401
} }
} }
/** /**
* Seemless worker's signal handlers * Seemless worker's signal handlers
*/ */
static void WorkerSignalHandler(int num, siginfo_t *info, void*) static void WorkerSignalHandler(int num, siginfo_t *info, void*)
{ {
switch (num) { switch (num) {
case SIGUSR2: case SIGUSR2:
if (info->si_pid == l_UmbrellaPid) { if (info->si_pid == 0 || info->si_pid == l_UmbrellaPid) {
// The umbrella process allowed us to continue wo rking beyond config validation // The umbrella process allowed us to continue wo rking beyond config validation
l_AllowedToWork.store(true); l_AllowedToWork.store(true);
} }
break; break;
case SIGINT: case SIGINT:
case SIGTERM: case SIGTERM:
if (info->si_pid == l_UmbrellaPid) { if (info->si_pid == 0 || info->si_pid == l_UmbrellaPid) {
// The umbrella process requested our termination // The umbrella process requested our termination
Application::RequestShutdown(); Application::RequestShutdown();
} }
break; break;
default: default:
// Programming error (or someone has broken the userspace ) // Programming error (or someone has broken the userspace )
VERIFY(!"Caught unexpected signal"); VERIFY(!"Caught unexpected signal");
} }
} }
 End of changes. 6 change blocks. 
4 lines changed or deleted 36 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)