]> git.sur5r.net Git - bacula/bacula/commitdiff
Cleanup dlists in VSSClient class at end of each job
authorKern Sibbald <kern@sibbald.com>
Mon, 12 Jul 2010 16:39:02 +0000 (18:39 +0200)
committerEric Bollengier <eric@eb.homelinux.org>
Fri, 12 Nov 2010 08:19:57 +0000 (09:19 +0100)
bacula/src/filed/job.c
bacula/src/win32/filed/vss.cpp

index 769beb62679324f6803818cba09cf493bffcb60d..cab2be070c5289586bc76ef24653ab56c1cfc369 100644 (file)
@@ -1907,6 +1907,7 @@ cleanup:
 #if defined(WIN32_VSS)
    if (jcr->VSS) {
       Win32ConvCleanupCache();
+      g_pVSSClient->DestroyWriterInfo();
       V(vss_mutex);
    }
 #endif
index 6ab1baa6d1d63a29e10767b1b5db2d21de133a40..376a8eb3f6d12b240c48c11b50cad1032558c1a2 100644 (file)
@@ -56,28 +56,34 @@ VSSCleanup()
 {
    if (g_pVSSClient) {
       delete (g_pVSSClient);
+      g_pVSSClient = NULL;
    }
 }
 
+/*
+ * May be called multiple times 
+ */
 void VSSInit()
 {
+   if (g_pVSSClient) {
+      return;                   /* already initialized */
+   }
    /* decide which vss class to initialize */
    if (g_MajorVersion == 5) {
       switch (g_MinorVersion) {
       case 1: 
          g_pVSSClient = new VSSClientXP();
-         atexit(VSSCleanup);
-         return;
+         break;
       case 2: 
          g_pVSSClient = new VSSClient2003();
-         atexit(VSSCleanup);
-         return;
+         break;
       }
    /* Vista or Longhorn or later */
    } else if (g_MajorVersion >= 6) {
       g_pVSSClient = new VSSClientVista();
+   }
+   if (g_pVSSClient) {
       atexit(VSSCleanup);
-      return;
    }
 }
 
@@ -206,21 +212,19 @@ bool VSSClient::GetShadowPathW(const wchar_t *szFilePath, wchar_t *szShadowPath,
 
 const size_t VSSClient::GetWriterCount()
 {
-   alist* pV = m_pAlistWriterInfoText;
-   return pV->size();
+   return m_pAlistWriterInfoText->size();
 }
 
 const char* VSSClient::GetWriterInfo(int nIndex)
 {
-   alist* pV = m_pAlistWriterInfoText;
-   return (char*)pV->get(nIndex);
+   return (char*)m_pAlistWriterInfoText->get(nIndex);
 }
 
 
 const int VSSClient::GetWriterState(int nIndex)
 {
-   alist* pV = m_pAlistWriterState;   
-   void *item = pV->get(nIndex);
+   void *item = m_pAlistWriterState->get(nIndex);
+
 /* Eliminate compiler warnings */
 #ifdef HAVE_VSS64
    return (int64_t)(char *)item;
@@ -231,23 +235,23 @@ const int VSSClient::GetWriterState(int nIndex)
 
 void VSSClient::AppendWriterInfo(int nState, const char* pszInfo)
 {
-   alist* pT = m_pAlistWriterInfoText;
-   alist* pS = m_pAlistWriterState;
-
-   pT->push(bstrdup(pszInfo));
-   pS->push((void*)nState);   
+   m_pAlistWriterInfoText->push(bstrdup(pszInfo));
+   m_pAlistWriterState->push((void*)nState);   
 }
 
+/*
+ * Note, this is called at the end of every job, so release all
+ *  the items in the alists, but do not delete the alist.
+ */
 void VSSClient::DestroyWriterInfo()
 {
-   alist* pT = m_pAlistWriterInfoText;
-   alist* pS = m_pAlistWriterState;
-
-   while (!pT->empty())
-      free(pT->pop());
+   while (!m_pAlistWriterInfoText->empty()) {
+      free(m_pAlistWriterInfoText->pop());
+   }
 
-   while (!pS->empty())
-      pS->pop();      
+   while (!m_pAlistWriterState->empty()) {
+      m_pAlistWriterState->pop();      
+   }
 }
 
 #endif