bnicholes 02/05/03 10:00:18
Modified: file_io/netware filestat.c
Log:
Turned on the mutex locking around the hash table manipulation calls. This
prevents a fault under high load on a multiprocessor machine.
Revision Changes Path
1.9 +12 -11 apr/file_io/netware/filestat.c
Index: filestat.c
===================================================================
RCS file: /home/cvs/apr/file_io/netware/filestat.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- filestat.c 22 Apr 2002 21:22:21 -0000 1.8
+++ filestat.c 3 May 2002 17:00:18 -0000 1.9
@@ -59,6 +59,7 @@
#include "apr_strings.h"
#include "apr_errno.h"
#include "apr_hash.h"
+#define USE_CSTAT_MUTEX
#ifdef USE_CSTAT_MUTEX
#include "apr_thread_mutex.h"
#endif
@@ -246,7 +247,13 @@
if (!gPool)
return stat(path, buf);
- if (!statCacheData) {
+ if (statCacheData) {
+ statCache = statCacheData->statCache;
+#ifdef USE_CSTAT_MUTEX
+ statcache_mutex = statCacheData->statcache_mutex;
+#endif
+ }
+ else {
statCacheData = (apr_stat_cache_t *)apr_palloc (gPool,
sizeof(apr_stat_cache_t));
statCache = apr_hash_make(gPool);
#ifdef USE_CSTAT_MUTEX
@@ -256,12 +263,6 @@
statCacheData->statCache = statCache;
setStatCache((void*)statCacheData);
}
- else {
- statCache = statCacheData->statCache;
-#ifdef USE_CSTAT_MUTEX
- statcache_mutex = statCacheData->statcache_mutex;
-#endif
- }
if (statCache) {
#ifdef USE_CSTAT_MUTEX
@@ -282,16 +283,16 @@
ret = stat(path, buf);
if (ret == 0) {
if (!stat_entry) {
+#ifdef USE_CSTAT_MUTEX
+ apr_thread_mutex_lock(statcache_mutex);
+#endif
key = apr_pstrdup (gPool, path);
stat_entry = apr_palloc (gPool,
sizeof(apr_stat_entry_t));
memcpy (&(stat_entry->info), buf, sizeof(struct stat));
stat_entry->expire = now;
-#ifdef USE_CSTAT_MUTEX
- apr_thread_mutex_lock(statcache_mutex);
-#endif
apr_hash_set(statCache, key, APR_HASH_KEY_STRING,
stat_entry);
#ifdef USE_CSTAT_MUTEX
- apr_thread_mutex_unlock(statcache_mutex);
+
apr_thread_mutex_unlock(statcache_mutex);
#endif
}
else {