[3/5] qmgr: Add critical sections for BackgroundCopyFiles.
Dan Hipschman
dsh at linux.ucla.edu
Mon Mar 10 18:32:42 CDT 2008
This adds critical sections around BackgroundCopyFile internals.
---
dlls/qmgr/file.c | 7 +++++++
dlls/qmgr/qmgr.h | 1 +
2 files changed, 8 insertions(+), 0 deletions(-)
diff --git a/dlls/qmgr/file.c b/dlls/qmgr/file.c
index 93ffba4..3e0e115 100644
--- a/dlls/qmgr/file.c
+++ b/dlls/qmgr/file.c
@@ -25,6 +25,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(qmgr);
static void BackgroundCopyFileDestructor(BackgroundCopyFileImpl *This)
{
+ DeleteCriticalSection(&This->cs);
HeapFree(GetProcessHeap(), 0, This->info.LocalName);
HeapFree(GetProcessHeap(), 0, This->info.RemoteName);
HeapFree(GetProcessHeap(), 0, This);
@@ -105,9 +106,11 @@ static HRESULT WINAPI BITS_IBackgroundCopyFile_GetProgress(
{
BackgroundCopyFileImpl *This = (BackgroundCopyFileImpl *) iface;
+ EnterCriticalSection(&This->cs);
pVal->BytesTotal = This->fileProgress.BytesTotal;
pVal->BytesTransferred = This->fileProgress.BytesTransferred;
pVal->Completed = This->fileProgress.Completed;
+ LeaveCriticalSection(&This->cs);
return S_OK;
}
@@ -135,10 +138,13 @@ HRESULT BackgroundCopyFileConstructor(LPCWSTR remoteName,
if (!This)
return E_OUTOFMEMORY;
+ InitializeCriticalSection(&This->cs);
+
n = (lstrlenW(remoteName) + 1) * sizeof(WCHAR);
This->info.RemoteName = HeapAlloc(GetProcessHeap(), 0, n);
if (!This->info.RemoteName)
{
+ DeleteCriticalSection(&This->cs);
HeapFree(GetProcessHeap(), 0, This);
return E_OUTOFMEMORY;
}
@@ -148,6 +154,7 @@ HRESULT BackgroundCopyFileConstructor(LPCWSTR remoteName,
This->info.LocalName = HeapAlloc(GetProcessHeap(), 0, n);
if (!This->info.LocalName)
{
+ DeleteCriticalSection(&This->cs);
HeapFree(GetProcessHeap(), 0, This->info.RemoteName);
HeapFree(GetProcessHeap(), 0, This);
return E_OUTOFMEMORY;
diff --git a/dlls/qmgr/qmgr.h b/dlls/qmgr/qmgr.h
index 8fef08b..cb6ea1b 100644
--- a/dlls/qmgr/qmgr.h
+++ b/dlls/qmgr/qmgr.h
@@ -72,6 +72,7 @@ typedef struct
LONG ref;
BG_FILE_INFO info;
BG_FILE_PROGRESS fileProgress;
+ CRITICAL_SECTION cs;
struct list entryFromJob;
} BackgroundCopyFileImpl;
More information about the wine-patches
mailing list