summaryrefslogtreecommitdiffstats
path: root/libglusterfs/src
diff options
context:
space:
mode:
authorRajesh Joseph <rjoseph@redhat.com>2016-11-14 15:40:32 +0530
committerRaghavendra Talur <rtalur@redhat.com>2016-11-28 01:10:12 -0800
commit8f60396bc8ce91dff57d64ae7ce56afb7f7626b1 (patch)
treebefc8df6a15992626414e83e171fa8a511e92052 /libglusterfs/src
parentd557d097851d335effe0a2e810ca3f664c30e93f (diff)
libglusterfs:Now mempool is added to ctx pool list under a lock
mempool is added to ctx pool list without any lock. This can cause undefined behaviour in case of multithreaded environment. Fix: modify the list only under ctx->lock > Reviewed-on: http://review.gluster.org/15842 > NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org> > Smoke: Gluster Build System <jenkins@build.gluster.org> > CentOS-regression: Gluster Build System <jenkins@build.gluster.org> > Reviewed-by: Raghavendra Talur <rtalur@redhat.com> > Reviewed-by: Shyamsundar Ranganathan <srangana@redhat.com> > Reviewed-by: Poornima G <pgurusid@redhat.com> > Reviewed-by: Niels de Vos <ndevos@redhat.com> (cherry picked from commit 277008a3a8583ef10cec9e4182960792e56c5c10) Change-Id: I7bdbb3db48a899bb0e41427e149b13c0facaedba Signed-off-by: Rajesh Joseph <rjoseph@redhat.com> BUG: 1397663 Reviewed-on: http://review.gluster.org/15909 Smoke: Gluster Build System <jenkins@build.gluster.org> Reviewed-by: Poornima G <pgurusid@redhat.com> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org> Reviewed-by: Manikandan Selvaganesh <manikandancs333@gmail.com> CentOS-regression: Gluster Build System <jenkins@build.gluster.org> Reviewed-by: Raghavendra Talur <rtalur@redhat.com>
Diffstat (limited to 'libglusterfs/src')
-rw-r--r--libglusterfs/src/mem-pool.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/libglusterfs/src/mem-pool.c b/libglusterfs/src/mem-pool.c
index 78fecec4b0f..88fbdf58319 100644
--- a/libglusterfs/src/mem-pool.c
+++ b/libglusterfs/src/mem-pool.c
@@ -422,7 +422,11 @@ mem_pool_new_fn (unsigned long sizeof_type,
if (!ctx)
goto out;
- list_add (&mem_pool->global_list, &ctx->mempool_list);
+ LOCK (&ctx->lock);
+ {
+ list_add (&mem_pool->global_list, &ctx->mempool_list);
+ }
+ UNLOCK (&ctx->lock);
out:
return mem_pool;