Commit cf75c536 authored by Vincent Povirk's avatar Vincent Povirk Committed by Alexandre Julliard

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

parent 45dd716e
...@@ -356,6 +356,25 @@ static HRESULT WINAPI FileLockBytesImpl_LockRegion(ILockBytes* iface, ...@@ -356,6 +356,25 @@ static HRESULT WINAPI FileLockBytesImpl_LockRegion(ILockBytes* iface,
return STG_E_ACCESSDENIED; 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, static HRESULT WINAPI FileLockBytesImpl_UnlockRegion(ILockBytes* iface,
ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType) ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType)
{ {
......
...@@ -2831,8 +2831,11 @@ static HRESULT StorageImpl_LockRegionSync(StorageImpl *This, ULARGE_INTEGER offs ...@@ -2831,8 +2831,11 @@ static HRESULT StorageImpl_LockRegionSync(StorageImpl *This, ULARGE_INTEGER offs
{ {
HRESULT hr; 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 do
{ {
int delay=0; int delay=0;
......
...@@ -157,6 +157,8 @@ struct DirEntry ...@@ -157,6 +157,8 @@ struct DirEntry
HRESULT FileLockBytesImpl_Construct(HANDLE hFile, DWORD openFlags, LPCWSTR pwcsName, ILockBytes **pLockBytes) DECLSPEC_HIDDEN; 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 * Ole Convert support
*/ */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment