added some hacky sleeps to temporarily fix some thread timing issues (causing access violations). the best fix would be to use wait cond vars, but first we need to really understand the bug.

This commit is contained in:
Nick Bolton 2013-09-16 15:21:36 +00:00
parent 6f982a501a
commit 760e38eeba
8 changed files with 34 additions and 25 deletions

View File

@ -26,9 +26,14 @@ COSXDragView* g_dragView = NULL;
void void
runCocoaApp() runCocoaApp()
{ {
// HACK: sleep, carbon loop should start first.
usleep(1000000);
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
NSApplication* app = [[NSApplication alloc] init]; NSApplication* app = [[NSApplication alloc] init];
NSWindow* window = [[NSWindow alloc] NSWindow* window = [[NSWindow alloc]
initWithContentRect: NSMakeRect(0, 0, 100, 4) initWithContentRect: NSMakeRect(0, 0, 100, 4)
styleMask: NSBorderlessWindowMask styleMask: NSBorderlessWindowMask
@ -44,8 +49,10 @@ runCocoaApp()
g_dragView = dragView; g_dragView = dragView;
[window setContentView: dragView]; [window setContentView: dragView];
NSLog(@"starting cocoa loop");
[app run]; [app run];
NSLog(@"cocoa: release");
[pool release]; [pool release];
} }

View File

@ -1691,8 +1691,13 @@ COSXScreen::watchSystemPowerThread(void*)
return; return;
} }
// start the run loop
LOG((CLOG_DEBUG "started watchSystemPowerThread")); LOG((CLOG_DEBUG "started watchSystemPowerThread"));
// HACK: sleep, this seem to stop synergy from freezing.
ARCH->sleep(1);
// start the run loop
LOG((CLOG_DEBUG "starting carbon loop"));
CFRunLoopRun(); CFRunLoopRun();
// cleanup // cleanup

View File

@ -387,3 +387,10 @@ CApp::handleIpcMessage(const CEvent& e, void*)
m_events->addEvent(CEvent(CEvent::kQuit)); m_events->addEvent(CEvent(CEvent::kQuit));
} }
} }
void
CApp::runEventsLoop(void*)
{
m_events->cacheCurrentEventQueueRef();
m_events->loop();
}

View File

@ -112,9 +112,11 @@ protected:
virtual bool parseArg(const int& argc, const char* const* argv, int& i); virtual bool parseArg(const int& argc, const char* const* argv, int& i);
void initIpcClient(); void initIpcClient();
void cleanupIpcClient(); void cleanupIpcClient();
void runEventsLoop(void*);
IArchTaskBarReceiver* m_taskBarReceiver; IArchTaskBarReceiver* m_taskBarReceiver;
bool m_suspended; bool m_suspended;
IEventQueue* m_events;
private: private:
CArgsBase* m_args; CArgsBase* m_args;
@ -123,7 +125,6 @@ private:
CreateTaskBarReceiverFunc m_createTaskBarReceiver; CreateTaskBarReceiverFunc m_createTaskBarReceiver;
ARCH_APP_UTIL m_appUtil; ARCH_APP_UTIL m_appUtil;
CIpcClient* m_ipcClient; CIpcClient* m_ipcClient;
IEventQueue* m_events;
CSocketMultiplexer* m_socketMultiplexer; CSocketMultiplexer* m_socketMultiplexer;
CString m_fileTransferSrc; CString m_fileTransferSrc;
CString m_fileTransferDes; CString m_fileTransferDes;

View File

@ -61,7 +61,6 @@
CClientApp::CClientApp(IEventQueue* events, CreateTaskBarReceiverFunc createTaskBarReceiver) : CClientApp::CClientApp(IEventQueue* events, CreateTaskBarReceiverFunc createTaskBarReceiver) :
CApp(events, createTaskBarReceiver, new CArgs()), CApp(events, createTaskBarReceiver, new CArgs()),
m_events(events),
s_client(NULL), s_client(NULL),
s_clientScreen(NULL) s_clientScreen(NULL)
{ {
@ -537,10 +536,15 @@ CClientApp::mainLoop()
DAEMON_RUNNING(true); DAEMON_RUNNING(true);
#if defined(MAC_OS_X_VERSION_10_7) #if defined(MAC_OS_X_VERSION_10_7)
CThread thread( CThread thread(
new TMethodJob<CClientApp>( new TMethodJob<CClientApp>(
this, &CClientApp::runEventsLoop, this, &CClientApp::runEventsLoop,
NULL)); NULL));
// HACK: sleep, allow queue to start.
ARCH->sleep(1);
runCocoaApp(); runCocoaApp();
#else #else
m_events->loop(); m_events->loop();
@ -626,10 +630,3 @@ CClientApp::startNode()
m_bye(kExitFailed); m_bye(kExitFailed);
} }
} }
void
CClientApp::runEventsLoop(void*)
{
m_events->cacheCurrentEventQueueRef();
m_events->loop();
}

View File

@ -87,10 +87,8 @@ public:
private: private:
virtual bool parseArg(const int& argc, const char* const* argv, int& i); virtual bool parseArg(const int& argc, const char* const* argv, int& i);
void runEventsLoop(void*);
private: private:
CClient* s_client; CClient* s_client;
CScreen* s_clientScreen; CScreen* s_clientScreen;
IEventQueue* m_events;
}; };

View File

@ -63,7 +63,6 @@
CServerApp::CServerApp(IEventQueue* events, CreateTaskBarReceiverFunc createTaskBarReceiver) : CServerApp::CServerApp(IEventQueue* events, CreateTaskBarReceiverFunc createTaskBarReceiver) :
CApp(events, createTaskBarReceiver, new CArgs()), CApp(events, createTaskBarReceiver, new CArgs()),
m_events(events),
s_server(NULL), s_server(NULL),
s_serverState(kUninitialized), s_serverState(kUninitialized),
s_serverScreen(NULL), s_serverScreen(NULL),
@ -788,10 +787,15 @@ CServerApp::mainLoop()
DAEMON_RUNNING(true); DAEMON_RUNNING(true);
#if defined(MAC_OS_X_VERSION_10_7) #if defined(MAC_OS_X_VERSION_10_7)
CThread thread( CThread thread(
new TMethodJob<CServerApp>( new TMethodJob<CServerApp>(
this, &CServerApp::runEventsLoop, this, &CServerApp::runEventsLoop,
NULL)); NULL));
// HACK: sleep, allow queue to start.
ARCH->sleep(1);
runCocoaApp(); runCocoaApp();
#else #else
m_events->loop(); m_events->loop();
@ -915,10 +919,3 @@ CServerApp::startNode()
m_bye(kExitFailed); m_bye(kExitFailed);
} }
} }
void
CServerApp::runEventsLoop(void*)
{
m_events->cacheCurrentEventQueueRef();
m_events->loop();
}

View File

@ -121,12 +121,9 @@ public:
CClientListener* s_listener; CClientListener* s_listener;
CEventQueueTimer* s_timer; CEventQueueTimer* s_timer;
IEventQueue* m_events;
private: private:
virtual bool parseArg(const int& argc, const char* const* argv, int& i); virtual bool parseArg(const int& argc, const char* const* argv, int& i);
void handleScreenSwitched(const CEvent&, void* data); void handleScreenSwitched(const CEvent&, void* data);
void runEventsLoop(void*);
}; };
// configuration file name // configuration file name