summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorshishir gowda <shishirng@gluster.com>2010-09-14 23:43:39 +0000
committerVijay Bellur <vijay@dev.gluster.com>2010-09-15 00:06:33 -0700
commitcfbbf68f8af83521b41b40c07db48897b976b626 (patch)
tree090cb41f97028e7fc67036fcd18169bbcd2ad38c
parent92cd5175b42d291314a2ede95b05ad10cb91b988 (diff)
Cleaning up mem_get0.
mem_get0 is exactly the same as mem_get, but with the addition of a call to memset(0). hence, making mem_get0 to call mem_get Signed-off-by: shishir gowda <shishirng@gluster.com> Signed-off-by: Vijay Bellur <vijay@dev.gluster.com> BUG: 1520 (gnfs crashes on start-up in mem_get0) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=1520
-rw-r--r--libglusterfs/src/mem-pool.c28
1 files changed, 3 insertions, 25 deletions
diff --git a/libglusterfs/src/mem-pool.c b/libglusterfs/src/mem-pool.c
index d11bcbcae7c..3df317a5ca6 100644
--- a/libglusterfs/src/mem-pool.c
+++ b/libglusterfs/src/mem-pool.c
@@ -341,39 +341,17 @@ mem_pool_new_fn (unsigned long sizeof_type,
void*
mem_get0 (struct mem_pool *mem_pool)
{
- struct list_head *list = NULL;
void *ptr = NULL;
- int *in_use = NULL;
if (!mem_pool) {
gf_log ("mem-pool", GF_LOG_ERROR, "invalid argument");
return NULL;
}
- LOCK (&mem_pool->lock);
- {
- if (mem_pool->cold_count) {
- list = mem_pool->list.next;
- list_del (list);
-
- mem_pool->hot_count++;
- mem_pool->cold_count--;
+ ptr = mem_get(mem_pool);
- ptr = list;
- in_use = (ptr + GF_MEM_POOL_LIST_BOUNDARY);
- *in_use = 1;
-
- goto fwd_addr_out;
- }
- ptr = MALLOC (mem_pool->real_sizeof_type);
- goto unlocked_out;
- }
-fwd_addr_out:
- ptr = mem_pool_chunkhead2ptr (ptr);
-unlocked_out:
-
- memset(ptr, 0, mem_pool->real_sizeof_type);
- UNLOCK (&mem_pool->lock);
+ if (ptr)
+ memset(ptr, 0, mem_pool->real_sizeof_type);
return ptr;
}