summaryrefslogtreecommitdiffstats
path: root/xlators/protocol/server
diff options
context:
space:
mode:
authorZhou Zhengping <johnzzpcrystal@gmail.com>2017-05-09 20:57:34 +0800
committerRaghavendra G <rgowdapp@redhat.com>2017-05-12 04:47:44 +0000
commit333474e0d6efe1a2b3a9ecffc9bdff3e49325910 (patch)
tree176005ae869f739d6e209472d21e87fc7f98d3c0 /xlators/protocol/server
parentccfa06767f1282d9a3783e37555515a63cc62e69 (diff)
libglusterfs: fix race condition in client_ctx_set
follow procedures: 1.thread1 client_ctx_get return NULL 2.thread 2 client_ctx_set ctx1 ok 3.thread1 client_ctx_set ctx2 ok thread1 use ctx1, thread2 use ctx2 and ctx1 will leak Change-Id: I990b02905edd1b3179323ada56888f852d20f538 BUG: 1449232 Signed-off-by: Zhou Zhengping <johnzzpcrystal@gmail.com> Reviewed-on: https://review.gluster.org/17219 NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org> CentOS-regression: Gluster Build System <jenkins@build.gluster.org> Reviewed-by: Raghavendra G <rgowdapp@redhat.com> Smoke: Gluster Build System <jenkins@build.gluster.org> Reviewed-by: Jeff Darcy <jeff@pl.atyp.us>
Diffstat (limited to 'xlators/protocol/server')
-rw-r--r--xlators/protocol/server/src/server-helpers.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/xlators/protocol/server/src/server-helpers.c b/xlators/protocol/server/src/server-helpers.c
index 290038a9e6e..37f7bca47f0 100644
--- a/xlators/protocol/server/src/server-helpers.c
+++ b/xlators/protocol/server/src/server-helpers.c
@@ -1170,6 +1170,7 @@ server_ctx_get (client_t *client, xlator_t *xlator)
{
void *tmp = NULL;
server_ctx_t *ctx = NULL;
+ server_ctx_t *setted_ctx = NULL;
client_ctx_get (client, xlator, &tmp);
@@ -1194,11 +1195,12 @@ server_ctx_get (client_t *client, xlator_t *xlator)
LOCK_INIT (&ctx->fdtable_lock);
- if (client_ctx_set (client, xlator, ctx) != 0) {
- LOCK_DESTROY (&ctx->fdtable_lock);
- GF_FREE (ctx->fdtable);
- GF_FREE (ctx);
- ctx = NULL;
+ setted_ctx = client_ctx_set (client, xlator, ctx);
+ if (ctx != setted_ctx) {
+ LOCK_DESTROY (&ctx->fdtable_lock);
+ GF_FREE (ctx->fdtable);
+ GF_FREE (ctx);
+ ctx = setted_ctx;
}
out: