From 5e902432797dad1ee4c8e5d1de1f8a5df50cba79 Mon Sep 17 00:00:00 2001 From: Jeffrey Altman Date: Mon, 31 Jan 2005 03:53:21 +0000 Subject: [PATCH] STABLE14-windows-virtual-memory-20041224 * The variable used to determine whether a file or virtual memory mapped cache is used was not properly initialized to a default value. If the registry setting "NonPersistentCaching" was not set, the choice would be random. Properly initialized to be "file". * The memory mapped view was never unmapped before closing the file at service shutdown. This is now properly cleaned up. * Default location of Cache file is now %TEMP%\AFSCache (cherry picked from commit d3d4af7795dd7371750bfdb9612b6419561cf32b) --- doc/txt/winnotes/afs-changes-since-1.2.txt | 12 ++++++++++++ doc/txt/winnotes/afs-install-notes.txt | 13 ++++++++++++- src/WINNT/afsd/afsd_init.c | 11 +++++++---- src/WINNT/afsd/afsd_service.c | 1 + src/WINNT/afsd/cm_buf.c | 22 +++++++++++++++++----- src/WINNT/afsd/cm_buf.h | 2 ++ src/WINNT/afsd/cm_scache.c | 4 ++-- src/WINNT/install/wix/config.wxi | 2 +- src/config/NTMakefile.i386_nt40 | 2 +- 9 files changed, 55 insertions(+), 14 deletions(-) diff --git a/doc/txt/winnotes/afs-changes-since-1.2.txt b/doc/txt/winnotes/afs-changes-since-1.2.txt index 7c76048318..800abd98e5 100644 --- a/doc/txt/winnotes/afs-changes-since-1.2.txt +++ b/doc/txt/winnotes/afs-changes-since-1.2.txt @@ -1,3 +1,15 @@ +Since 1.3.77: + * The variable used to determine whether a file or virtual memory + mapped cache is used was not properly initialized to a default + value. If the registry setting "NonPersistentCaching" was not + set, the choice would be random. Properly initialized to be + "file". + + * The memory mapped view was never unmapped before closing the file + at service shutdown. This is now properly cleaned up. + + * Default location of Cache file is now %TEMP%\AFSCache + Since 1.3.76: * A bug affecting new installations of 1.3.75/76 would result in diff --git a/doc/txt/winnotes/afs-install-notes.txt b/doc/txt/winnotes/afs-install-notes.txt index 91eaae6766..bcce7bf6c2 100644 --- a/doc/txt/winnotes/afs-install-notes.txt +++ b/doc/txt/winnotes/afs-install-notes.txt @@ -463,7 +463,18 @@ As of 1.3.75, a new registry value, HKLM\SOFTWARE\OpenAFS\Client filenames using the ANSI Code Page instead of the OEM Code Page. The ANSI Code Page is a compatible superset of Latin-1. This setting is not the default setting because making this change would prevent OpenAFS for Windows -from being able to access filenames containing the above characters. +from being able to access filenames containing the above characters which +were created without this setting. + + +30. There is a known issue with storing Windows Roaming Profiles when +the profile contains either directories or files with names which cannot +be represented in the local OEM character set. In this case, attempts +to write the profile back to AFS will fail. OpenAFS for Windows does +not currently support UNICODE. To avoid this problem some sites run +logoff scripts (assigned by group policy) which rename all files to use +only the supported characters for the locale. + ------------------------------------------------------------------------ diff --git a/src/WINNT/afsd/afsd_init.c b/src/WINNT/afsd/afsd_init.c index ae625b85e8..9f241a992d 100644 --- a/src/WINNT/afsd/afsd_init.c +++ b/src/WINNT/afsd/afsd_init.c @@ -388,7 +388,7 @@ int afsd_InitCM(char **reasonP) long maxcpus; long ltt, ltto; long rx_mtu, rx_nojumbo; - long virtualCache; + long virtualCache = 0; char rootCellName[256]; struct rx_service *serverp; static struct rx_securityClass *nullServerSecurityClassp; @@ -622,9 +622,12 @@ int afsd_InitCM(char **reasonP) } afsi_log("Cache path %s", cm_CachePath); } else { - GetWindowsDirectory(cm_CachePath, sizeof(cm_CachePath)); - cm_CachePath[2] = 0; /* get drive letter only */ - StringCbCatA(cm_CachePath, sizeof(cm_CachePath), "\\AFSCache"); + dummyLen = ExpandEnvironmentStrings("%TEMP%\AFSCache", cm_CachePath, sizeof(cm_CachePath)); + if (dummyLen > sizeof(cm_CachePath)) { + afsi_log("Cache path [%%TEMP%%\\AFSCache] longer than %d after expanding env strings", + sizeof(cm_CachePath)); + osi_panic("CachePath too long", __FILE__, __LINE__); + } afsi_log("Default cache path %s", cm_CachePath); } diff --git a/src/WINNT/afsd/afsd_service.c b/src/WINNT/afsd/afsd_service.c index 0df35f782a..5903ac4da7 100644 --- a/src/WINNT/afsd/afsd_service.c +++ b/src/WINNT/afsd/afsd_service.c @@ -1181,6 +1181,7 @@ void afsd_Main(DWORD argc, LPTSTR *argv) DismountGlobalDrives(); smb_Shutdown(); rx_Finalize(); + buf_Shutdown(); #ifdef REGISTER_POWER_NOTIFICATIONS /* terminate thread used to flush cache */ diff --git a/src/WINNT/afsd/cm_buf.c b/src/WINNT/afsd/cm_buf.c index 8abbf431fa..ed31f3733f 100644 --- a/src/WINNT/afsd/cm_buf.c +++ b/src/WINNT/afsd/cm_buf.c @@ -86,6 +86,9 @@ int buf_cacheType = CM_BUF_CACHETYPE_FILE; static HANDLE CacheHandle; +static +VOID * ViewOfFile; + static SYSTEM_INFO sysInfo; #endif /* !DJGPP */ @@ -334,11 +337,11 @@ long buf_Init(cm_buf_ops_t *opsp) } return CM_ERROR_INVAL; } - data = MapViewOfFile(hm, - FILE_MAP_ALL_ACCESS, - 0, 0, - buf_nbuffers * buf_bufferSize); - if (data == NULL) { + ViewOfFile = MapViewOfFile(hm, + FILE_MAP_ALL_ACCESS, + 0, 0, + buf_nbuffers * buf_bufferSize); + if (ViewOfFile == NULL) { afsi_log("Error mapping view of file: 0x%X", GetLastError()); if (hf != INVALID_HANDLE_VALUE) CloseHandle(hf); @@ -346,6 +349,8 @@ long buf_Init(cm_buf_ops_t *opsp) return CM_ERROR_INVAL; } CloseHandle(hm); + + data = ViewOfFile; #else /* djgpp doesn't support memory mapped files */ data = malloc(buf_nbuffers * buf_bufferSize); @@ -406,6 +411,13 @@ long buf_Init(cm_buf_ops_t *opsp) return 0; } +void +buf_Shutdown(void) +{ + UnmapViewOfFile(ViewOfFile); + CloseHandle(CacheHandle); +} + /* add nbuffers to the buffer pool, if possible. * Called with no locks held. */ diff --git a/src/WINNT/afsd/cm_buf.h b/src/WINNT/afsd/cm_buf.h index 1f1bc42acc..c7f59fcac1 100644 --- a/src/WINNT/afsd/cm_buf.h +++ b/src/WINNT/afsd/cm_buf.h @@ -142,6 +142,8 @@ extern cm_buf_t **buf_fileHashTablepp; extern long buf_Init(cm_buf_ops_t *); +extern void buf_Shutdown(void); + extern long buf_CountFreeList(void); extern void buf_Release(cm_buf_t *); diff --git a/src/WINNT/afsd/cm_scache.c b/src/WINNT/afsd/cm_scache.c index 41577dcc83..2c15aa16b7 100644 --- a/src/WINNT/afsd/cm_scache.c +++ b/src/WINNT/afsd/cm_scache.c @@ -982,7 +982,7 @@ void cm_AFSFidFromFid(AFSFid *afsFidp, cm_fid_t *fidp) void cm_HoldSCacheNoLock(cm_scache_t *scp) { #ifdef NOLOCK_ASSERT - osi_assert(scp->refCount > 0); + osi_assert(scp->refCount >= 0); #endif scp->refCount++; } @@ -990,7 +990,7 @@ void cm_HoldSCacheNoLock(cm_scache_t *scp) void cm_HoldSCache(cm_scache_t *scp) { lock_ObtainWrite(&cm_scacheLock); - osi_assert(scp->refCount > 0); + osi_assert(scp->refCount >= 0); scp->refCount++; lock_ReleaseWrite(&cm_scacheLock); } diff --git a/src/WINNT/install/wix/config.wxi b/src/WINNT/install/wix/config.wxi index bd7af64ed7..aa4bfbcfa2 100644 --- a/src/WINNT/install/wix/config.wxi +++ b/src/WINNT/install/wix/config.wxi @@ -101,7 +101,7 @@ - + diff --git a/src/config/NTMakefile.i386_nt40 b/src/config/NTMakefile.i386_nt40 index 5b23feee59..3cc52e9a0e 100644 --- a/src/config/NTMakefile.i386_nt40 +++ b/src/config/NTMakefile.i386_nt40 @@ -80,7 +80,7 @@ LIB = $(AFSDEV_LIB) #define used in WinNT/2000 installation and program version display AFSPRODUCT_VER_MAJOR=1 AFSPRODUCT_VER_MINOR=3 -AFSPRODUCT_VER_PATCH=7700 +AFSPRODUCT_VER_PATCH=7701 AFSPRODUCT_VER_BUILD=0 # For MSI installer, each major release should have a different GUID