From 4378e520f0d8a2967683d126ad3fef54ede67fe0 Mon Sep 17 00:00:00 2001 From: Nick Bolton Date: Sat, 14 Jul 2012 00:15:07 +0000 Subject: [PATCH] fixed: on windows xp daemon deadlocks and synergys crashes on startup. also fixed uninitialized ipc program args value (always turning ipc on). moved the event queue further up the stack for (client, server and daemon) so that it's always available (not just in the main loop). --- src/lib/arch/CArchPluginWindows.cpp | 3 +-- src/lib/ipc/CIpcLogOutputter.cpp | 2 ++ src/lib/synergy/CApp.cpp | 2 ++ src/lib/synergy/CArgsBase.cpp | 3 ++- src/lib/synergy/CClientApp.cpp | 3 --- src/lib/synergy/CDaemonApp.cpp | 12 +++++++----- src/lib/synergy/CServerApp.cpp | 3 --- 7 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/lib/arch/CArchPluginWindows.cpp b/src/lib/arch/CArchPluginWindows.cpp index 62b4da71..89e62528 100644 --- a/src/lib/arch/CArchPluginWindows.cpp +++ b/src/lib/arch/CArchPluginWindows.cpp @@ -73,8 +73,7 @@ CString CArchPluginWindows::getModuleDir() { TCHAR c_modulePath[MAX_PATH]; - GetModuleFileName(NULL, c_modulePath, MAX_PATH); - if (GetLastError() != ERROR_SUCCESS) { + if (GetModuleFileName(NULL, c_modulePath, MAX_PATH) == 0) { throw XArch(new XArchEvalWindows); } diff --git a/src/lib/ipc/CIpcLogOutputter.cpp b/src/lib/ipc/CIpcLogOutputter.cpp index 477d1e72..51920eb2 100644 --- a/src/lib/ipc/CIpcLogOutputter.cpp +++ b/src/lib/ipc/CIpcLogOutputter.cpp @@ -111,7 +111,9 @@ CIpcLogOutputter::appendBuffer(const CString& text) void CIpcLogOutputter::bufferThread(void*) { + CArchMutexLock lock(m_notifyMutex); m_bufferThreadId = m_bufferThread->getID(); + try { while (m_running) { diff --git a/src/lib/synergy/CApp.cpp b/src/lib/synergy/CApp.cpp index 0d42f1b8..5f1ae5ed 100644 --- a/src/lib/synergy/CApp.cpp +++ b/src/lib/synergy/CApp.cpp @@ -29,6 +29,7 @@ #include "TMethodEventJob.h" #include "CIpcMessage.h" #include "Ipc.h" +#include "CEventQueue.h" #if SYSAPI_WIN32 #include "CArchMiscWindows.h" @@ -252,6 +253,7 @@ CApp::run(int argc, char** argv) arch.init(); CLog log; + CEventQueue events; #if MAC_OS_X_VERSION_10_7 // dock hide only supported on lion :( diff --git a/src/lib/synergy/CArgsBase.cpp b/src/lib/synergy/CArgsBase.cpp index 5d6f60c8..b856af50 100644 --- a/src/lib/synergy/CArgsBase.cpp +++ b/src/lib/synergy/CArgsBase.cpp @@ -36,7 +36,8 @@ m_pname(NULL), m_logFilter(NULL), m_logFile(NULL), m_display(NULL), -m_enableVnc(false) +m_enableVnc(false), +m_enableIpc(false) { } diff --git a/src/lib/synergy/CClientApp.cpp b/src/lib/synergy/CClientApp.cpp index 1f787485..e2152397 100644 --- a/src/lib/synergy/CClientApp.cpp +++ b/src/lib/synergy/CClientApp.cpp @@ -526,9 +526,6 @@ CClientApp::mainLoop() // on unix because threads evaporate across a fork(). CSocketMultiplexer multiplexer; - // create the event queue - CEventQueue eventQueue; - // start client, etc appUtil().startNode(); diff --git a/src/lib/synergy/CDaemonApp.cpp b/src/lib/synergy/CDaemonApp.cpp index 53dfdbbb..fb1dab39 100644 --- a/src/lib/synergy/CDaemonApp.cpp +++ b/src/lib/synergy/CDaemonApp.cpp @@ -101,6 +101,7 @@ CDaemonApp::run(int argc, char** argv) arch.init(); CLog log; + CEventQueue events; bool uninstall = false; try @@ -187,12 +188,13 @@ CDaemonApp::mainLoop(bool logToFile) try { DAEMON_RUNNING(true); + /*while (true) + { + }*/ if (logToFile) CLOG->insert(new CFileLogOutputter(logPath().c_str())); - CEventQueue eventQueue; - // create socket multiplexer. this must happen after daemonization // on unix because threads evaporate across a fork(). CSocketMultiplexer multiplexer; @@ -208,7 +210,7 @@ CDaemonApp::mainLoop(bool logToFile) m_relauncher = new CMSWindowsRelauncher(false, *m_ipcServer, *m_ipcLogOutputter); #endif - eventQueue.adoptHandler( + EVENTQUEUE->adoptHandler( CIpcServer::getMessageReceivedEvent(), m_ipcServer, new TMethodEventJob(this, &CDaemonApp::handleIpcMessage)); @@ -230,14 +232,14 @@ CDaemonApp::mainLoop(bool logToFile) m_relauncher->startAsync(); #endif - eventQueue.loop(); + EVENTQUEUE->loop(); #if SYSAPI_WIN32 m_relauncher->stop(); delete m_relauncher; #endif - eventQueue.removeHandler( + EVENTQUEUE->removeHandler( CIpcServer::getMessageReceivedEvent(), m_ipcServer); CLOG->remove(m_ipcLogOutputter); diff --git a/src/lib/synergy/CServerApp.cpp b/src/lib/synergy/CServerApp.cpp index 3a42a665..dacfd3f8 100644 --- a/src/lib/synergy/CServerApp.cpp +++ b/src/lib/synergy/CServerApp.cpp @@ -758,9 +758,6 @@ CServerApp::mainLoop() // on unix because threads evaporate across a fork(). CSocketMultiplexer multiplexer; - // create the event queue - CEventQueue eventQueue; - // if configuration has no screens then add this system // as the default if (args().m_config->begin() == args().m_config->end()) {