2 This patch is fixes Fix bug #1246 Sometimes access with
3 VSS enabled. UCS conversion cache was not properly flushed
6 Apply it to version 2.4.4 with:
9 patch -p0 <2.4.4-winvss.patch
10 ./configure <your options>
16 Index: src/filed/job.c
17 ===================================================================
18 --- src/filed/job.c (revision 8733)
19 +++ src/filed/job.c (working copy)
22 Bacula® - The Network Backup Solution
24 - Copyright (C) 2000-2007 Free Software Foundation Europe e.V.
25 + Copyright (C) 2000-2009 Free Software Foundation Europe e.V.
27 The main author of Bacula is Kern Sibbald, with contributions from
28 many others, a complete list can be found in the file AUTHORS.
32 static pthread_mutex_t vss_mutex = PTHREAD_MUTEX_INITIALIZER;
33 -static int enable_vss;
34 +static int enable_vss = 0;
37 extern CLIENT *me; /* our client resource */
39 /* inform user about writer states */
40 for (i=0; i < (int)g_pVSSClient->GetWriterCount(); i++)
41 if (g_pVSSClient->GetWriterState(i) < 1) {
42 - Jmsg(jcr, M_WARNING, 0, _("VSS Writer (PrepareForBackup): %s\n"), g_pVSSClient->GetWriterInfo(i));
43 + Jmsg(jcr, M_WARNING, 0, _("VSS Writer (PrepareForBackup): %s\n"), g_pVSSClient->GetWriterInfo(i));
48 Jmsg(jcr, msg_type, 0, _("VSS Writer (BackupComplete): %s\n"), g_pVSSClient->GetWriterInfo(i));
51 + Win32ConvCleanupCache();
55 Index: src/win32/Makefile
56 ===================================================================
57 --- src/win32/Makefile (revision 8733)
58 +++ src/win32/Makefile (working copy)
60 Makefile.inc: Makefile.inc.in
62 $(ECHO_CMD)TOPDIR=`(cd ../../..;pwd)`; \
63 - if test -e ../../../cross-tools/mingw32/bin/mingw32-gcc; then \
64 + if test -e $${TOPDIR}/cross-tools/mingw32/bin/mingw32-gcc; then \
65 BINDIR=$${TOPDIR}/cross-tools/mingw32/bin; \
66 INCDIR=$${TOPDIR}/cross-tools/mingw32/mingw32/include; \
67 DLLDIR=$${TOPDIR}/cross-tools/mingw32/mingw32/bin; \
69 echo "You must run build-win32-cross-tools and build-dependencies first.\n"; \
72 - $(ECHO_CMD)BUILDDIR=`(pwd)`; \
75 -e "s^@BUILDDIR@^$${BUILDDIR}^" \
76 -e "s^@TOPDIR@^$${TOPDIR}^" \
77 Index: src/win32/compat/compat.cpp
78 ===================================================================
79 --- src/win32/compat/compat.cpp (revision 8733)
80 +++ src/win32/compat/compat.cpp (working copy)
83 Bacula® - The Network Backup Solution
85 - Copyright (C) 2004-2008 Free Software Foundation Europe e.V.
86 + Copyright (C) 2004-2009 Free Software Foundation Europe e.V.
88 The main author of Bacula is Kern Sibbald, with contributions from
89 many others, a complete list can be found in the file AUTHORS.
91 conversion is called 3 times (lstat, attribs, open),
92 by using the cache this is reduced to 1 time */
94 -static POOLMEM *g_pWin32ConvUTF8Cache = get_pool_memory(PM_FNAME);
95 -static POOLMEM *g_pWin32ConvUCS2Cache = get_pool_memory(PM_FNAME);
96 +static POOLMEM *g_pWin32ConvUTF8Cache = NULL;
97 +static POOLMEM *g_pWin32ConvUCS2Cache = NULL;
98 static DWORD g_dwWin32ConvUTF8strlen = 0;
99 static pthread_mutex_t Win32Convmutex = PTHREAD_MUTEX_INITIALIZER;
102 g_pVSSPathConvertW = pPathConvertW;
105 +static void Win32ConvInitCache()
107 + if (g_pWin32ConvUTF8Cache) {
110 + g_pWin32ConvUTF8Cache = get_pool_memory(PM_FNAME);
111 + g_pWin32ConvUCS2Cache = get_pool_memory(PM_FNAME);
115 void Win32ConvCleanupCache()
118 if (g_pWin32ConvUTF8Cache) {
119 free_pool_memory(g_pWin32ConvUTF8Cache);
120 g_pWin32ConvUTF8Cache = NULL;
124 g_dwWin32ConvUTF8strlen = 0;
129 @@ -451,11 +463,14 @@
130 /* if we find the utf8 string in cache, we use the cached ucs2 version.
131 we compare the stringlength first (quick check) and then compare the content.
133 - if (g_dwWin32ConvUTF8strlen == strlen(pszUTF)) {
134 + if (!g_pWin32ConvUTF8Cache) {
135 + Win32ConvInitCache();
136 + } else if (g_dwWin32ConvUTF8strlen == strlen(pszUTF)) {
137 if (bstrcmp(pszUTF, g_pWin32ConvUTF8Cache)) {
138 + /* Return cached value */
139 int32_t nBufSize = sizeof_pool_memory(g_pWin32ConvUCS2Cache);
140 *pszUCS = check_pool_memory_size(*pszUCS, nBufSize);
141 - wcscpy((LPWSTR) *pszUCS, (LPWSTR) g_pWin32ConvUCS2Cache);
142 + wcscpy((LPWSTR) *pszUCS, (LPWSTR)g_pWin32ConvUCS2Cache);
144 return nBufSize / sizeof (WCHAR);
147 wcscpy((LPWSTR) g_pWin32ConvUCS2Cache, (LPWSTR) *pszUCS);
149 g_dwWin32ConvUTF8strlen = strlen(pszUTF);
150 - g_pWin32ConvUTF8Cache = check_pool_memory_size(g_pWin32ConvUTF8Cache, g_dwWin32ConvUTF8strlen+1);
151 + g_pWin32ConvUTF8Cache = check_pool_memory_size(g_pWin32ConvUTF8Cache, g_dwWin32ConvUTF8strlen+2);
152 bstrncpy(g_pWin32ConvUTF8Cache, pszUTF, g_dwWin32ConvUTF8strlen+1);
155 Index: src/win32/Makefile.inc.in
156 ===================================================================
157 --- src/win32/Makefile.inc.in (revision 8733)
158 +++ src/win32/Makefile.inc.in (working copy)
161 BUILDDIR := @BUILDDIR@
163 -DEPKGS := $(TOPDIR)/depkgs-mingw32
164 +DEPKGS := @TOPDIR@/depkgs-mingw32
166 -DOCDIR := $(TOPDIR)/docs
167 +DOCDIR := @TOPDIR@/docs