You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@apr.apache.org by bn...@apache.org on 2002/03/05 23:08:40 UTC
cvs commit: apr/file_io/netware filestat.c
bnicholes 02/03/05 14:08:40
Modified: file_io/netware filestat.c
Log:
Moved the memcpy() ahead of the hash table set to avoid a race condition.
This makes sure that there is valid data in the entry when it is set in the hash
table.
Revision Changes Path
1.3 +6 -2 apr/file_io/netware/filestat.c
Index: filestat.c
===================================================================
RCS file: /home/cvs/apr/file_io/netware/filestat.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- filestat.c 25 Feb 2002 22:36:28 -0000 1.2
+++ filestat.c 5 Mar 2002 22:08:39 -0000 1.3
@@ -255,6 +255,8 @@
if (!stat_entry) {
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
@@ -263,8 +265,10 @@
apr_thread_mutex_unlock(statcache_mutex);
#endif
}
- memcpy (&(stat_entry->info), buf, sizeof(struct stat));
- stat_entry->expire = now;
+ else {
+ memcpy (&(stat_entry->info), buf, sizeof(struct stat));
+ stat_entry->expire = now;
+ }
}
else
return ret;