From 499cd47e63cb7fac3d8c4d4de31df6f55dec8fc6 Mon Sep 17 00:00:00 2001 From: Nick Bolton Date: Mon, 14 Oct 2013 17:10:51 +0000 Subject: [PATCH] - fixed: process should shut down when command is empty. - fixed: when command was empty quotes ("") daemon crashed. --- src/lib/platform/CMSWindowsRelauncher.cpp | 3 +- src/lib/synergy/CDaemonApp.cpp | 41 ++++++++++++++--------- 2 files changed, 28 insertions(+), 16 deletions(-) diff --git a/src/lib/platform/CMSWindowsRelauncher.cpp b/src/lib/platform/CMSWindowsRelauncher.cpp index 10c7e2c1..c398ebdc 100644 --- a/src/lib/platform/CMSWindowsRelauncher.cpp +++ b/src/lib/platform/CMSWindowsRelauncher.cpp @@ -175,6 +175,7 @@ CMSWindowsRelauncher::mainLoop(void*) // anything yet, so don't show it as a warning, only show it as // debug to devs to let them know why nothing happened. LOG((CLOG_DEBUG "nothing to launch, no command specified.")); + shutdownExistingProcesses(); continue; } @@ -231,7 +232,7 @@ CMSWindowsRelauncher::isProcessRunning() GetExitCodeProcess(m_processInfo.hProcess, &exitCode); running = (exitCode == STILL_ACTIVE); - if (!running) { + if (!running && !m_command.empty()) { m_failures++; LOG((CLOG_INFO "detected application not running, pid=%d, failures=%d", diff --git a/src/lib/synergy/CDaemonApp.cpp b/src/lib/synergy/CDaemonApp.cpp index b0997254..5c846790 100644 --- a/src/lib/synergy/CDaemonApp.cpp +++ b/src/lib/synergy/CDaemonApp.cpp @@ -298,25 +298,36 @@ CDaemonApp::handleIpcMessage(const CEvent& e, void*) case kIpcCommand: { CIpcCommandMessage* cm = static_cast(m); CString command = cm->command(); - LOG((CLOG_DEBUG "new command, elevate=%d command=%s", cm->elevate(), command.c_str())); - CString debugArg("--debug"); - UInt32 debugArgPos = static_cast(command.find(debugArg)); - if (debugArgPos != CString::npos) { - UInt32 from = debugArgPos + static_cast(debugArg.size()) + 1; - UInt32 nextSpace = static_cast(command.find(" ", from)); - CString logLevel(command.substr(from, nextSpace - from)); + // if empty quotes, clear. + if (command == "\"\"") { + command.clear(); + } + + if (!command.empty()) { + LOG((CLOG_DEBUG "new command, elevate=%d command=%s", cm->elevate(), command.c_str())); + + CString debugArg("--debug"); + UInt32 debugArgPos = static_cast(command.find(debugArg)); + if (debugArgPos != CString::npos) { + UInt32 from = debugArgPos + static_cast(debugArg.size()) + 1; + UInt32 nextSpace = static_cast(command.find(" ", from)); + CString logLevel(command.substr(from, nextSpace - from)); - try { - // change log level based on that in the command string - // and change to that log level now. - ARCH->setting("LogLevel", logLevel); - CLOG->setFilter(logLevel.c_str()); - } - catch (XArch& e) { - LOG((CLOG_ERR "failed to save LogLevel setting, %s", e.what().c_str())); + try { + // change log level based on that in the command string + // and change to that log level now. + ARCH->setting("LogLevel", logLevel); + CLOG->setFilter(logLevel.c_str()); + } + catch (XArch& e) { + LOG((CLOG_ERR "failed to save LogLevel setting, %s", e.what().c_str())); + } } } + else { + LOG((CLOG_DEBUG "empty command, elevate=%d", cm->elevate())); + } try { // store command in system settings. this is used when the daemon