summaryrefslogtreecommitdiffstats
path: root/libglusterfs/src/gidcache.c
diff options
context:
space:
mode:
authorYaniv Kaul <ykaul@redhat.com>2018-12-27 18:56:16 +0200
committerAmar Tumballi <amarts@redhat.com>2019-01-29 09:27:22 +0000
commitc7d1aee76d5713d1f337ab1c831c0ed74e4676e1 (patch)
treedac0618f33a560ae1bfbd5c92c5762d42d26797b /libglusterfs/src/gidcache.c
parentf747d55a7fd364e2b9a74fe40360ab3cb7b11537 (diff)
Multiple files: reduce work while under lock.
Mostly, unlock before logging. In some cases, moved different code that was not needed to be under lock (for example, taking time, or malloc'ing) to be executed before taking the lock. Note: logging might be slightly less accurate in order, since it may not be done now under the lock, so order of logs is racy. I think it's a reasonable compromise. Compile-tested only! updates: bz#1193929 Signed-off-by: Yaniv Kaul <ykaul@redhat.com> Change-Id: I2438710016afc9f4f62a176ef1a0d3ed793b4f89
Diffstat (limited to 'libglusterfs/src/gidcache.c')
-rw-r--r--libglusterfs/src/gidcache.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/libglusterfs/src/gidcache.c b/libglusterfs/src/gidcache.c
index 87147163e9e..40fcffbb35e 100644
--- a/libglusterfs/src/gidcache.c
+++ b/libglusterfs/src/gidcache.c
@@ -64,8 +64,8 @@ gid_cache_lookup(gid_cache_t *cache, uint64_t id, uint64_t uid, uint64_t gid)
time_t now;
const gid_list_t *agl;
- LOCK(&cache->gc_lock);
now = time(NULL);
+ LOCK(&cache->gc_lock);
bucket = id % cache->gc_nbuckets;
agl = BUCKET_START(cache->gc_cache, bucket);
for (i = 0; i < AUX_GID_CACHE_ASSOC; i++, agl++) {
@@ -132,8 +132,8 @@ gid_cache_add(gid_cache_t *cache, gid_list_t *gl)
if (!cache->gc_max_age)
return 0;
- LOCK(&cache->gc_lock);
now = time(NULL);
+ LOCK(&cache->gc_lock);
/*
* Scan for the first free entry or one that matches this id. The id