diff options
Diffstat (limited to 'win/rfb_win32')
-rw-r--r-- | win/rfb_win32/RegConfig.cxx | 10 | ||||
-rw-r--r-- | win/rfb_win32/RegConfig.h | 7 | ||||
-rw-r--r-- | win/rfb_win32/SecurityPage.cxx | 3 | ||||
-rw-r--r-- | win/rfb_win32/WMHooks.cxx | 30 |
4 files changed, 27 insertions, 23 deletions
diff --git a/win/rfb_win32/RegConfig.cxx b/win/rfb_win32/RegConfig.cxx index 7d80871f..057882b9 100644 --- a/win/rfb_win32/RegConfig.cxx +++ b/win/rfb_win32/RegConfig.cxx @@ -93,17 +93,21 @@ void RegConfig::processEvent(HANDLE /*event*/) { } -RegConfigThread::RegConfigThread() : config(&eventMgr), thread_id(-1) { +RegConfigThread::RegConfigThread() : config(&eventMgr), thread(nullptr), + thread_id(-1) { } RegConfigThread::~RegConfigThread() { PostThreadMessage(thread_id, WM_QUIT, 0, 0); - wait(); + if (thread != nullptr) { + thread->join(); + delete thread; + } } bool RegConfigThread::start(const HKEY rootKey, const char* keyname) { if (config.setKey(rootKey, keyname)) { - Thread::start(); + thread = new std::thread(&RegConfigThread::worker, this); while (thread_id == (DWORD)-1) Sleep(0); return true; diff --git a/win/rfb_win32/RegConfig.h b/win/rfb_win32/RegConfig.h index 89e724f8..4a2f8ca8 100644 --- a/win/rfb_win32/RegConfig.h +++ b/win/rfb_win32/RegConfig.h @@ -24,7 +24,7 @@ #ifndef __RFB_WIN32_REG_CONFIG_H__ #define __RFB_WIN32_REG_CONFIG_H__ -#include <core/Thread.h> +#include <thread> #include <rfb_win32/Registry.h> #include <rfb_win32/EventManager.h> @@ -63,7 +63,7 @@ namespace rfb { RegKey key; }; - class RegConfigThread : core::Thread { + class RegConfigThread { public: RegConfigThread(); ~RegConfigThread(); @@ -71,9 +71,10 @@ namespace rfb { // Start the thread, reading from the specified key bool start(const HKEY rootkey, const char* keyname); protected: - void worker() override; + void worker(); EventManager eventMgr; RegConfig config; + std::thread* thread; DWORD thread_id; }; diff --git a/win/rfb_win32/SecurityPage.cxx b/win/rfb_win32/SecurityPage.cxx index f9321160..94a88492 100644 --- a/win/rfb_win32/SecurityPage.cxx +++ b/win/rfb_win32/SecurityPage.cxx @@ -123,9 +123,6 @@ SecurityPage::onOk() { bool vnc_loaded = false; list<uint32_t> secTypes; - /* Keep same priorities as in common/rfb/SecurityClient::secTypes */ - secTypes.push_back(secTypeVeNCrypt); - #ifdef HAVE_GNUTLS /* X509Plain */ if (authMethodEnabled(IDC_ENC_X509, IDC_AUTH_PLAIN)) { diff --git a/win/rfb_win32/WMHooks.cxx b/win/rfb_win32/WMHooks.cxx index 6b444166..e3285948 100644 --- a/win/rfb_win32/WMHooks.cxx +++ b/win/rfb_win32/WMHooks.cxx @@ -22,9 +22,10 @@ #include <config.h> #endif +#include <mutex> +#include <thread> + #include <core/LogWriter.h> -#include <core/Mutex.h> -#include <core/Thread.h> #include <rfb_win32/WMHooks.h> #include <rfb_win32/Service.h> @@ -115,21 +116,23 @@ error: } -class WMHooksThread : public Thread { +class WMHooksThread { public: - WMHooksThread() : active(true), thread_id(-1) { } + WMHooksThread() : active(true), thread(WMHooksThread::worker, this), + thread_id(-1) { } void stop(); DWORD getThreadId() { return thread_id; } protected: - void worker() override; + void worker(); protected: bool active; + std::thread thread; DWORD thread_id; }; static WMHooksThread* hook_mgr = nullptr; static std::list<WMHooks*> hooks; -static Mutex hook_mgr_lock; +static std::mutex hook_mgr_lock; static bool StartHookThread() { @@ -139,7 +142,6 @@ static bool StartHookThread() { return false; vlog.debug("Creating thread"); hook_mgr = new WMHooksThread(); - hook_mgr->start(); while (hook_mgr->getThreadId() == (DWORD)-1) Sleep(0); vlog.debug("Installing hooks"); @@ -167,7 +169,7 @@ static void StopHookThread() { static bool AddHook(WMHooks* hook) { vlog.debug("Adding hook"); - AutoMutex a(&hook_mgr_lock); + const std::lock_guard<std::mutex> lock(hook_mgr_lock); if (!StartHookThread()) return false; hooks.push_back(hook); @@ -177,7 +179,7 @@ static bool AddHook(WMHooks* hook) { static bool RemHook(WMHooks* hook) { { vlog.debug("Removing hook"); - AutoMutex a(&hook_mgr_lock); + const std::lock_guard<std::mutex> lock(hook_mgr_lock); hooks.remove(hook); } StopHookThread(); @@ -185,7 +187,7 @@ static bool RemHook(WMHooks* hook) { } static void NotifyHooksRegion(const Region& r) { - AutoMutex a(&hook_mgr_lock); + const std::lock_guard<std::mutex> lock(hook_mgr_lock); std::list<WMHooks*>::iterator i; for (i=hooks.begin(); i!=hooks.end(); i++) (*i)->NotifyHooksRegion(r); @@ -302,7 +304,7 @@ WMHooksThread::stop() { active = false; PostThreadMessage(thread_id, WM_QUIT, 0, 0); vlog.debug("Waiting for WMHooks thread"); - wait(); + thread.join(); } // -=- WMHooks class @@ -324,7 +326,7 @@ bool rfb::win32::WMHooks::setEvent(HANDLE ue) { bool rfb::win32::WMHooks::getUpdates(UpdateTracker* ut) { if (!updatesReady) return false; - AutoMutex a(&hook_mgr_lock); + const std::lock_guard<std::mutex> lock(hook_mgr_lock); updates.copyTo(ut); updates.clear(); updatesReady = false; @@ -376,12 +378,12 @@ static bool blockRealInputs(bool block_) { return block_ == blocking; } -static Mutex blockMutex; +static std::mutex blockMutex; static int blockCount = 0; bool rfb::win32::WMBlockInput::blockInputs(bool on) { if (active == on) return true; - AutoMutex a(&blockMutex); + const std::lock_guard<std::mutex> lock(blockMutex); int newCount = on ? blockCount+1 : blockCount-1; if (!blockRealInputs(newCount > 0)) return false; |