git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@2295
91ce42f0-d328-0410-95d8-
f526ca767f89
VSSClient::VSSClient()
{
m_bCoInitializeCalled = false;
VSSClient::VSSClient()
{
m_bCoInitializeCalled = false;
+ m_bCoInitializeSecurityCalled = false;
m_dwContext = 0; // VSS_CTX_BACKUP;
m_bDuringRestore = false;
m_bBackupIsInitialized = false;
m_dwContext = 0; // VSS_CTX_BACKUP;
m_bDuringRestore = false;
m_bBackupIsInitialized = false;
HMODULE m_hLib;
BOOL m_bCoInitializeCalled;
HMODULE m_hLib;
BOOL m_bCoInitializeCalled;
+ BOOL m_bCoInitializeSecurityCalled;
DWORD m_dwContext;
IUnknown* m_pVssObject;
DWORD m_dwContext;
IUnknown* m_pVssObject;
errno = b_errno_win32;
return FALSE;
}
errno = b_errno_win32;
return FALSE;
}
m_bCoInitializeCalled = true;
m_bCoInitializeCalled = true;
- // Initialize COM security
+ // Initialize COM security
+ if (!m_bCoInitializeSecurityCalled) {
hr =
CoInitializeSecurity(
NULL, // Allow *all* VSS writers to communicate back!
hr =
CoInitializeSecurity(
NULL, // Allow *all* VSS writers to communicate back!
errno = b_errno_win32;
return FALSE;
}
errno = b_errno_win32;
return FALSE;
}
+ m_bCoInitializeSecurityCalled = true;
}
// Release the IVssBackupComponents interface
}
// Release the IVssBackupComponents interface
BOOL VSSClientGeneric::CloseBackup()
{
BOOL VSSClientGeneric::CloseBackup()
{
+ BOOL bRet = FALSE;
+ if (!m_pVssObject)
+ else {
+ IVssBackupComponents* pVss = (IVssBackupComponents*) m_pVssObject;
+ CComPtr<IVssAsync> pAsync;
+
+ m_bBackupIsInitialized = false;
- BOOL bRet = FALSE;
- IVssBackupComponents* pVss = (IVssBackupComponents*) m_pVssObject;
- CComPtr<IVssAsync> pAsync;
-
- m_bBackupIsInitialized = false;
+ if (SUCCEEDED(pVss->BackupComplete(&pAsync))) {
+ // Waits for the async operation to finish and checks the result
+ WaitAndCheckForAsyncOperation(pAsync);
+ bRet = TRUE;
+ } else {
+ errno = b_errno_win32;
+ pVss->AbortBackup();
+ }
- if (SUCCEEDED(pVss->BackupComplete(&pAsync))) {
- // Waits for the async operation to finish and checks the result
- WaitAndCheckForAsyncOperation(pAsync);
- bRet = TRUE;
- } else {
- errno = b_errno_win32;
- pVss->AbortBackup();
- }
+ if (m_uidCurrentSnapshotSet != GUID_NULL) {
+ VSS_ID idNonDeletedSnapshotID = GUID_NULL;
+ LONG lSnapshots;
- if (m_uidCurrentSnapshotSet != GUID_NULL) {
- VSS_ID idNonDeletedSnapshotID = GUID_NULL;
- LONG lSnapshots;
+ pVss->DeleteSnapshots(
+ m_uidCurrentSnapshotSet,
+ VSS_OBJECT_SNAPSHOT_SET,
+ FALSE,
+ &lSnapshots,
+ &idNonDeletedSnapshotID);
- pVss->DeleteSnapshots(
- m_uidCurrentSnapshotSet,
- VSS_OBJECT_SNAPSHOT_SET,
- FALSE,
- &lSnapshots,
- &idNonDeletedSnapshotID);
+ m_uidCurrentSnapshotSet = GUID_NULL;
+ }
- m_uidCurrentSnapshotSet = GUID_NULL;
+ pVss->Release();
+ m_pVssObject = NULL;
-
- pVss->Release();
- m_pVssObject = NULL;
+ // Call CoUninitialize if the CoInitialize was performed sucesfully
+ if (m_bCoInitializeCalled) {
+ CoUninitialize();
+ m_bCoInitializeCalled = false;
+ }