diff options
author | Rajesh Joseph <rjoseph@redhat.com> | 2016-11-14 15:40:32 +0530 |
---|---|---|
committer | Niels de Vos <ndevos@redhat.com> | 2016-11-28 03:56:50 -0800 |
commit | 261f845ab8997c91ba51eb8b1ac94664989e38f0 (patch) | |
tree | 5f2640423ece8446db4d172ca1452d50ab12c8eb /libglusterfs/src/mem-pool.c | |
parent | 1acb99bc78e827a34592dd1c41f3fd4cea11b14f (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: 1397662
Reviewed-on: http://review.gluster.org/15910
NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
Smoke: Gluster Build System <jenkins@build.gluster.org>
Reviewed-by: Poornima G <pgurusid@redhat.com>
Reviewed-by: Niels de Vos <ndevos@redhat.com>
Diffstat (limited to 'libglusterfs/src/mem-pool.c')
-rw-r--r-- | libglusterfs/src/mem-pool.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/libglusterfs/src/mem-pool.c b/libglusterfs/src/mem-pool.c index 7674913bbdc..91e663c1617 100644 --- a/libglusterfs/src/mem-pool.c +++ b/libglusterfs/src/mem-pool.c @@ -421,7 +421,11 @@ mem_pool_new_fn (unsigned long sizeof_type, if (!ctx) goto out; - list_add (&mem_pool->global_list, &ctx->mempool_list); + pthread_mutex_lock (&ctx->lock); + { + list_add (&mem_pool->global_list, &ctx->mempool_list); + } + pthread_mutex_unlock (&ctx->lock); out: return mem_pool; |