Vincent Povirk : ole32: Use real blocking operations for storage locking when possible.

Alexandre Julliard julliard at winehq.org
Fri May 9 13:32:35 CDT 2014


Module: wine
Branch: master
Commit: cf75c5368be45fc9f208f790e2929e9669170c24
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=cf75c5368be45fc9f208f790e2929e9669170c24

Author: Vincent Povirk <vincent at codeweavers.com>
Date:   Thu May  8 13:56:02 2014 -0500

ole32: Use real blocking operations for storage locking when possible.

---

 dlls/ole32/filelockbytes.c |   19 +++++++++++++++++++
 dlls/ole32/storage32.c     |    5 ++++-
 dlls/ole32/storage32.h     |    2 ++
 3 files changed, 25 insertions(+), 1 deletion(-)

diff --git a/dlls/ole32/filelockbytes.c b/dlls/ole32/filelockbytes.c
index 1f4ac55..9bd1163 100644
--- a/dlls/ole32/filelockbytes.c
+++ b/dlls/ole32/filelockbytes.c
@@ -356,6 +356,25 @@ static HRESULT WINAPI FileLockBytesImpl_LockRegion(ILockBytes* iface,
         return STG_E_ACCESSDENIED;
 }
 
+HRESULT FileLockBytesImpl_LockRegionSync(ILockBytes* iface,
+    ULARGE_INTEGER libOffset, ULARGE_INTEGER cb)
+{
+    FileLockBytesImpl* This = impl_from_ILockBytes(iface);
+    OVERLAPPED ol;
+
+    if (iface->lpVtbl != &FileLockBytesImpl_Vtbl)
+        return E_NOTIMPL;
+
+    ol.hEvent = 0;
+    ol.u.s.Offset = libOffset.u.LowPart;
+    ol.u.s.OffsetHigh = libOffset.u.HighPart;
+
+    if (LockFileEx(This->hfile, LOCKFILE_EXCLUSIVE_LOCK, 0, cb.u.LowPart, cb.u.HighPart, &ol))
+        return S_OK;
+    else
+        return STG_E_ACCESSDENIED;
+}
+
 static HRESULT WINAPI FileLockBytesImpl_UnlockRegion(ILockBytes* iface,
     ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType)
 {
diff --git a/dlls/ole32/storage32.c b/dlls/ole32/storage32.c
index a71ec41..56d3229 100644
--- a/dlls/ole32/storage32.c
+++ b/dlls/ole32/storage32.c
@@ -2831,8 +2831,11 @@ static HRESULT StorageImpl_LockRegionSync(StorageImpl *This, ULARGE_INTEGER offs
 {
     HRESULT hr;
 
-    /* potential optimization: if we have an HFILE use LockFileEx in blocking mode directly */
+    /* if it's a FileLockBytesImpl use LockFileEx in blocking mode */
+    if (SUCCEEDED(FileLockBytesImpl_LockRegionSync(This->lockBytes, offset, cb)))
+        return S_OK;
 
+    /* otherwise we have to fake it based on an async lock */
     do
     {
         int delay=0;
diff --git a/dlls/ole32/storage32.h b/dlls/ole32/storage32.h
index d5041d1..0b8bcc8 100644
--- a/dlls/ole32/storage32.h
+++ b/dlls/ole32/storage32.h
@@ -157,6 +157,8 @@ struct DirEntry
 
 HRESULT FileLockBytesImpl_Construct(HANDLE hFile, DWORD openFlags, LPCWSTR pwcsName, ILockBytes **pLockBytes) DECLSPEC_HIDDEN;
 
+HRESULT FileLockBytesImpl_LockRegionSync(ILockBytes* iface, ULARGE_INTEGER libOffset, ULARGE_INTEGER cb) DECLSPEC_HIDDEN;
+
 /*************************************************************************
  * Ole Convert support
  */




More information about the wine-cvs mailing list