qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From astitc...@apache.org
Subject svn commit: r891061 - /qpid/trunk/qpid/cpp/src/qpid/sys/windows/LockFile.cpp
Date Tue, 15 Dec 2009 23:02:29 GMT
Author: astitcher
Date: Tue Dec 15 23:02:29 2009
New Revision: 891061

URL: http://svn.apache.org/viewvc?rev=891061&view=rev
Log:
QPID-2281: LockFile class now actually locks the file!
[before it just opened the file without locking it]

Modified:
    qpid/trunk/qpid/cpp/src/qpid/sys/windows/LockFile.cpp

Modified: qpid/trunk/qpid/cpp/src/qpid/sys/windows/LockFile.cpp
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/sys/windows/LockFile.cpp?rev=891061&r1=891060&r2=891061&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/sys/windows/LockFile.cpp (original)
+++ qpid/trunk/qpid/cpp/src/qpid/sys/windows/LockFile.cpp Tue Dec 15 23:02:29 2009
@@ -36,7 +36,7 @@
 LockFile::LockFile(const std::string& path_, bool create)
   : path(path_), created(create) {
 
-    HANDLE h = CreateFile(path.c_str(),
+    HANDLE h = ::CreateFile(path.c_str(),
                           create ? (GENERIC_READ|GENERIC_WRITE) : GENERIC_READ,
                           FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE,
                           0, /* Default security */
@@ -44,14 +44,19 @@
                           FILE_FLAG_DELETE_ON_CLOSE, /* Delete file when closed */
                           NULL);
     if (h == INVALID_HANDLE_VALUE)
-        throw qpid::Exception(path + qpid::sys::strError(GetLastError()));
+        throw qpid::Exception(path + ": " + qpid::sys::strError(GetLastError()));
+
+    // Lock up to 4Gb
+    if (!::LockFile(h, 0, 0, 0xffffffff, 0))
+        throw qpid::Exception(path + ": " + qpid::sys::strError(GetLastError()));
     impl.reset(new LockFilePrivate(h));
 }
 
 LockFile::~LockFile() {
     if (impl) {
         if (impl->fd != INVALID_HANDLE_VALUE) {
-            CloseHandle(impl->fd);
+            ::UnlockFile(impl->fd, 0, 0, 0xffffffff, 0);
+            ::CloseHandle(impl->fd);
         }
     }
 }



---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:commits-subscribe@qpid.apache.org


Mime
View raw message