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

View File

@ -1691,8 +1691,13 @@ COSXScreen::watchSystemPowerThread(void*)
return;
}
// start the run loop
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();
// cleanup

View File

@ -385,5 +385,12 @@ CApp::handleIpcMessage(const CEvent& e, void*)
if (m->type() == kIpcShutdown) {
LOG((CLOG_INFO "got ipc shutdown message"));
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);
void initIpcClient();
void cleanupIpcClient();
void runEventsLoop(void*);
IArchTaskBarReceiver* m_taskBarReceiver;
bool m_suspended;
IEventQueue* m_events;
private:
CArgsBase* m_args;
@ -123,7 +125,6 @@ private:
CreateTaskBarReceiverFunc m_createTaskBarReceiver;
ARCH_APP_UTIL m_appUtil;
CIpcClient* m_ipcClient;
IEventQueue* m_events;
CSocketMultiplexer* m_socketMultiplexer;
CString m_fileTransferSrc;
CString m_fileTransferDes;

View File

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

View File

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

View File

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

View File

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