mirror of
https://github.com/debauchee/barrier.git
synced 2026-11-26 05:42:24 +08:00
Refactored some platform dependent code into a new library,
lib/arch. This should make porting easier. Will probably continue to refactor a little more, moving platform dependent event handling stuff into lib/platform.
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
#include "OptionTypes.h"
|
||||
#include "ProtocolTypes.h"
|
||||
#include "CNetworkAddress.h"
|
||||
#include "CStringUtil.h"
|
||||
#include "XBase.h"
|
||||
#include "stdmap.h"
|
||||
#include "stdset.h"
|
||||
|
||||
@@ -15,9 +15,9 @@
|
||||
#include "CMSWindowsPrimaryScreen.h"
|
||||
#include "CMSWindowsScreen.h"
|
||||
#include "IPrimaryScreenReceiver.h"
|
||||
#include "CPlatform.h"
|
||||
#include "XScreen.h"
|
||||
#include "CLog.h"
|
||||
#include "CArchMiscWindows.h"
|
||||
#include <cstring>
|
||||
|
||||
//
|
||||
@@ -29,7 +29,7 @@ CMSWindowsPrimaryScreen::CMSWindowsPrimaryScreen(
|
||||
IPrimaryScreenReceiver* primaryReceiver) :
|
||||
CPrimaryScreen(receiver),
|
||||
m_receiver(primaryReceiver),
|
||||
m_is95Family(CPlatform::isWindows95Family()),
|
||||
m_is95Family(CArchMiscWindows::isWindows95Family()),
|
||||
m_threadID(0),
|
||||
m_window(NULL),
|
||||
m_mark(0),
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
#include "CLog.h"
|
||||
#include "CStopwatch.h"
|
||||
#include "TMethodJob.h"
|
||||
#include "CArch.h"
|
||||
|
||||
//
|
||||
// CServer
|
||||
@@ -1074,7 +1075,7 @@ CServer::closeClients(const CConfig& config)
|
||||
// wait a moment to allow each client to close its connection
|
||||
// before we close it (to avoid having our socket enter TIME_WAIT).
|
||||
if (threads.size() > 0) {
|
||||
CThread::sleep(1.0);
|
||||
ARCH->sleep(1.0);
|
||||
}
|
||||
|
||||
// cancel the old client threads
|
||||
@@ -1103,10 +1104,10 @@ CServer::startThread(IJob* job)
|
||||
// reap completed threads
|
||||
doReapThreads(m_threads);
|
||||
|
||||
// add new thread to list. use the job as user data for logging.
|
||||
CThread thread(job, job);
|
||||
// add new thread to list
|
||||
CThread thread(job);
|
||||
m_threads.push_back(thread);
|
||||
LOG((CLOG_DEBUG1 "started thread %p", thread.getUserData()));
|
||||
LOG((CLOG_DEBUG1 "started thread 0x%08x", thread.getID()));
|
||||
return thread;
|
||||
}
|
||||
|
||||
@@ -1152,13 +1153,13 @@ CServer::stopThreads(double timeout)
|
||||
CStopwatch timer(true);
|
||||
while (threads.size() > 0 && (timeout < 0.0 || timer.getTime() < timeout)) {
|
||||
doReapThreads(threads);
|
||||
CThread::sleep(0.01);
|
||||
ARCH->sleep(0.01);
|
||||
}
|
||||
|
||||
// delete remaining threads
|
||||
for (CThreadList::iterator index = threads.begin();
|
||||
index != threads.end(); ++index) {
|
||||
LOG((CLOG_DEBUG1 "reaped running thread %p", index->getUserData()));
|
||||
LOG((CLOG_DEBUG1 "reaped running thread 0x%08x", index->getID()));
|
||||
}
|
||||
|
||||
LOG((CLOG_DEBUG1 "stopped threads"));
|
||||
@@ -1178,7 +1179,7 @@ CServer::doReapThreads(CThreadList& threads)
|
||||
index != threads.end(); ) {
|
||||
if (index->wait(0.0)) {
|
||||
// thread terminated
|
||||
LOG((CLOG_DEBUG1 "reaped thread %p", index->getUserData()));
|
||||
LOG((CLOG_DEBUG1 "reaped thread 0x%08x", index->getID()));
|
||||
index = threads.erase(index);
|
||||
}
|
||||
else {
|
||||
@@ -1211,7 +1212,7 @@ CServer::acceptClients(void*)
|
||||
break;
|
||||
}
|
||||
catch (XSocketAddressInUse& e) {
|
||||
LOG((CLOG_WARN "bind failed: %s", e.getErrstr()));
|
||||
LOG((CLOG_WARN "bind failed: %s", e.what()));
|
||||
|
||||
// give up if we've waited too long
|
||||
if (timer.getTime() >= m_bindTimeout) {
|
||||
@@ -1220,7 +1221,7 @@ CServer::acceptClients(void*)
|
||||
}
|
||||
|
||||
// wait a bit before retrying
|
||||
CThread::sleep(5.0);
|
||||
ARCH->sleep(5.0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1489,7 +1490,7 @@ CServer::acceptHTTPClients(void*)
|
||||
break;
|
||||
}
|
||||
catch (XSocketBind& e) {
|
||||
LOG((CLOG_DEBUG1 "bind HTTP failed: %s", e.getErrstr()));
|
||||
LOG((CLOG_DEBUG1 "bind HTTP failed: %s", e.what()));
|
||||
|
||||
// give up if we've waited too long
|
||||
if (timer.getTime() >= m_bindTimeout) {
|
||||
@@ -1498,7 +1499,7 @@ CServer::acceptHTTPClients(void*)
|
||||
}
|
||||
|
||||
// wait a bit before retrying
|
||||
CThread::sleep(5.0);
|
||||
ARCH->sleep(5.0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1550,7 +1551,7 @@ CServer::processHTTPRequest(void* vsocket)
|
||||
socket->getOutputStream()->flush();
|
||||
|
||||
// wait a moment to give the client a chance to hangup first
|
||||
CThread::sleep(3.0);
|
||||
ARCH->sleep(3.0);
|
||||
|
||||
// clean up
|
||||
socket->close();
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
# define XK_XKB_KEYS
|
||||
# include <X11/keysymdef.h>
|
||||
#endif
|
||||
#include "CArch.h"
|
||||
|
||||
//
|
||||
// CXWindowsPrimaryScreen
|
||||
@@ -517,7 +518,7 @@ CXWindowsPrimaryScreen::showWindow()
|
||||
assert(result != GrabNotViewable);
|
||||
if (result != GrabSuccess) {
|
||||
LOG((CLOG_DEBUG2 "waiting to grab keyboard"));
|
||||
CThread::sleep(0.05);
|
||||
ARCH->sleep(0.05);
|
||||
if (timer.getTime() >= s_timeout) {
|
||||
LOG((CLOG_DEBUG2 "grab keyboard timed out"));
|
||||
XUnmapWindow(display, m_window);
|
||||
@@ -536,7 +537,7 @@ CXWindowsPrimaryScreen::showWindow()
|
||||
// back off to avoid grab deadlock
|
||||
XUngrabKeyboard(display, CurrentTime);
|
||||
LOG((CLOG_DEBUG2 "ungrabbed keyboard, waiting to grab pointer"));
|
||||
CThread::sleep(0.05);
|
||||
ARCH->sleep(0.05);
|
||||
if (timer.getTime() >= s_timeout) {
|
||||
LOG((CLOG_DEBUG2 "grab pointer timed out"));
|
||||
XUnmapWindow(display, m_window);
|
||||
|
||||
@@ -46,6 +46,8 @@ libserver_a_SOURCES = \
|
||||
IPrimaryScreenFactory.h \
|
||||
$(NULL)
|
||||
INCLUDES = \
|
||||
-I$(VDEPTH)/lib/common \
|
||||
-I$(VDEPTH)/lib/arch \
|
||||
-I$(VDEPTH)/lib/base \
|
||||
-I$(VDEPTH)/lib/mt \
|
||||
-I$(VDEPTH)/lib/io \
|
||||
|
||||
@@ -41,7 +41,7 @@ RSC=rc.exe
|
||||
# PROP Intermediate_Dir "Release"
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c
|
||||
# ADD CPP /nologo /MT /W4 /GX /O2 /I "..\base" /I "..\mt" /I "..\io" /I "..\http" /I "..\net" /I "..\synergy" /I "..\platform" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /FD /c
|
||||
# ADD CPP /nologo /MT /W4 /GX /O2 /I "..\common" /I "..\arch" /I "..\base" /I "..\mt" /I "..\io" /I "..\http" /I "..\net" /I "..\synergy" /I "..\platform" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /FD /c
|
||||
# SUBTRACT CPP /YX
|
||||
# ADD BASE RSC /l 0x409 /d "NDEBUG"
|
||||
# ADD RSC /l 0x409 /d "NDEBUG"
|
||||
@@ -65,7 +65,7 @@ LIB32=link.exe -lib
|
||||
# PROP Intermediate_Dir "Debug"
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /MTd /W4 /Gm /GX /ZI /Od /I "..\base" /I "..\mt" /I "..\io" /I "..\http" /I "..\net" /I "..\synergy" /I "..\platform" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /FD /GZ /c
|
||||
# ADD CPP /nologo /MTd /W4 /Gm /GX /ZI /Od /I "..\common" /I "..\arch" /I "..\base" /I "..\mt" /I "..\io" /I "..\http" /I "..\net" /I "..\synergy" /I "..\platform" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /FD /GZ /c
|
||||
# SUBTRACT CPP /YX
|
||||
# ADD BASE RSC /l 0x409 /d "_DEBUG"
|
||||
# ADD RSC /l 0x409 /d "_DEBUG"
|
||||
|
||||
Reference in New Issue
Block a user