[Pkg-owncloud-commits] [owncloud-client] 82/211: Windows Shell Integration: fixeWindows Shell Integration: fixe

Sandro Knauß hefee-guest at moszumanska.debian.org
Sat Oct 25 09:10:29 UTC 2014


This is an automated email from the git hooks/post-receive script.

hefee-guest pushed a commit to branch master
in repository owncloud-client.

commit aa0f2c64ff21316ec8157e07261bf6eb1b2ea70c
Author: Olivier Goffart <ogoffart at woboq.com>
Date:   Wed Oct 15 15:57:15 2014 +0200

    Windows Shell Integration: fixeWindows Shell Integration: fixe
---
 .../OCUtil/CommunicationSocket.cpp                 |  8 +++--
 .../OCShellExtensions/OCUtil/RemotePathChecker.cpp | 39 +++++++++++-----------
 .../OCShellExtensions/OCUtil/RemotePathChecker.h   |  2 +-
 3 files changed, 26 insertions(+), 23 deletions(-)

diff --git a/shell_integration/windows/OCShellExtensions/OCUtil/CommunicationSocket.cpp b/shell_integration/windows/OCShellExtensions/OCUtil/CommunicationSocket.cpp
index 82ad7ce..dec2970 100644
--- a/shell_integration/windows/OCShellExtensions/OCUtil/CommunicationSocket.cpp
+++ b/shell_integration/windows/OCShellExtensions/OCUtil/CommunicationSocket.cpp
@@ -104,12 +104,16 @@ bool CommunicationSocket::ReadLine(wstring* response)
         std::array<char, 128> resp_utf8;
         DWORD numBytesRead = 0;
 		DWORD totalBytesAvailable = 0;
-		PeekNamedPipe(_pipe, NULL, 0, 0, &totalBytesAvailable, 0);
+		auto result = PeekNamedPipe(_pipe, NULL, 0, 0, &totalBytesAvailable, 0);
+		if (!result) {
+			Close();
+			return false;
+		}
 		if (totalBytesAvailable == 0) {
 			return false;
 		}
 
-        auto result = ReadFile(_pipe, resp_utf8.data(), DWORD(resp_utf8.size()), &numBytesRead, NULL);
+        result = ReadFile(_pipe, resp_utf8.data(), DWORD(resp_utf8.size()), &numBytesRead, NULL);
         if (!result) {
             Close();
             return false;
diff --git a/shell_integration/windows/OCShellExtensions/OCUtil/RemotePathChecker.cpp b/shell_integration/windows/OCShellExtensions/OCUtil/RemotePathChecker.cpp
index 668cf66..14a7d2c 100644
--- a/shell_integration/windows/OCShellExtensions/OCUtil/RemotePathChecker.cpp
+++ b/shell_integration/windows/OCShellExtensions/OCUtil/RemotePathChecker.cpp
@@ -39,10 +39,11 @@ void RemotePathChecker::workerThreadLoop()
     std::unordered_set<std::wstring> asked;
 
     while(!_stop) {
+		Sleep(50);
 
         if (!connected) {
             asked.clear();
-            if (!WaitNamedPipe(pipename, 5 * 1000)) {
+            if (!WaitNamedPipe(pipename.data(), 5 * 1000)) {
                 continue;
             }
             if (!socket.Connect(pipename)) {
@@ -70,14 +71,14 @@ void RemotePathChecker::workerThreadLoop()
 
         std::wstring response;
         while (!_stop && socket.ReadLine(&response)) {
-            if (StringUtil::begins_with(response, wstring(L"REGISTER_PATH:"))) {
-                wstring responsePath = response.substr(14); // length of REGISTER_PATH:
-
-                {   std::unique_lock<std::mutex> lock(_mutex);
-                    _watchedDirectories.push_back(responsePath);
-                }
-                SHChangeNotify(SHCNE_MKDIR, SHCNF_PATH, responsePath.data(), NULL);
-            if (StringUtil::begins_with(response, wstring(L"UNREGISTER_PATH:"))) {
+			if (StringUtil::begins_with(response, wstring(L"REGISTER_PATH:"))) {
+				wstring responsePath = response.substr(14); // length of REGISTER_PATH:
+
+				{   std::unique_lock<std::mutex> lock(_mutex);
+					_watchedDirectories.push_back(responsePath);
+				}
+				SHChangeNotify(SHCNE_MKDIR, SHCNF_PATH, responsePath.data(), NULL);
+			} else if (StringUtil::begins_with(response, wstring(L"UNREGISTER_PATH:"))) {
                 wstring responsePath = response.substr(16); // length of UNREGISTER_PATH:
 
                 {   std::unique_lock<std::mutex> lock(_mutex);
@@ -87,7 +88,7 @@ void RemotePathChecker::workerThreadLoop()
 
                     // Remove any item from the cache
                     for (auto it = _cache.begin(); it != _cache.end() ; ) {
-                        if (StringUtil::begins_with(it.first, responsePath)) {
+                        if (StringUtil::begins_with(it->first, responsePath)) {
                             it = _cache.erase(it);
                         } else {
                             ++it;
@@ -119,23 +120,21 @@ void RemotePathChecker::workerThreadLoop()
             }
         }
 
-        if (socket.Event() == INVALID_HANDLE_VALUE) {
-            std::unique_lock<std::mutex> lock(_mutex);
-            _cache.clear();
-            _watchedDirectories.clear();
-            _connected = connected = false;
-        }
-
-        Sleep(50);
+		if (socket.Event() == INVALID_HANDLE_VALUE) {
+			std::unique_lock<std::mutex> lock(_mutex);
+			_cache.clear();
+			_watchedDirectories.clear();
+			_connected = connected = false;
+		}
     }
 }
 
 
 
 RemotePathChecker::RemotePathChecker()
-    : _thread([this]{ this->workerThreadLoop(); } )
-    , _connected(false)
+    : _connected(false)
     , _newQueries(CreateEvent(NULL, true, true, NULL))
+	, _thread([this]{ this->workerThreadLoop(); })
 {
 }
 
diff --git a/shell_integration/windows/OCShellExtensions/OCUtil/RemotePathChecker.h b/shell_integration/windows/OCShellExtensions/OCUtil/RemotePathChecker.h
index 0aa05fd..7d7decd 100644
--- a/shell_integration/windows/OCShellExtensions/OCUtil/RemotePathChecker.h
+++ b/shell_integration/windows/OCShellExtensions/OCUtil/RemotePathChecker.h
@@ -43,7 +43,6 @@ public:
 private:
 	FileState _StrToFileState(const std::wstring &str);
     std::mutex _mutex;
-    std::thread _thread;
     std::atomic<bool> _stop;
 
     // Everything here is protected by the _mutex
@@ -61,6 +60,7 @@ private:
     //std::condition_variable _newQueries;
     HANDLE _newQueries;
 
+	std::thread _thread;
     void workerThreadLoop();
 };
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud-client.git



More information about the Pkg-owncloud-commits mailing list