From fa5b0347193f8d1a4b917a2edb338423cb175e66 Mon Sep 17 00:00:00 2001 From: Pranith Kumar K Date: Sat, 10 Mar 2012 00:54:12 +0530 Subject: protocol/server: Remove connection from conf->conns w.o. race 1) Adding the connection to conf->conns used to happen in conf->mutex, but removing happened under conn->lock. Fixed that as below. When the connection object is created conn's ref, bind_ref count is set to '1'. For bind_ref ref/unref happens under conf->mutex whenever server_connection_get, put is called. When bind_ref goes to '0' connection object is removed from conf->conns under conf->mutex. After it is removed from the list, conn_unref is called outside the conf->mutex. conn_ref/unref still happens under conn->lock. 2) Fixed races in server_connection_cleaup in grace_timer_handler and server_setvolume. Change-Id: Ie7b63b10f658af909a11c3327066667f5b7bd114 BUG: 801675 Signed-off-by: Pranith Kumar K Reviewed-on: http://review.gluster.com/2911 Tested-by: Gluster Build System Reviewed-by: Amar Tumballi Reviewed-by: Vijay Bellur --- xlators/protocol/server/src/server-handshake.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'xlators/protocol/server/src/server-handshake.c') diff --git a/xlators/protocol/server/src/server-handshake.c b/xlators/protocol/server/src/server-handshake.c index d1e3659ab..ba80185fe 100644 --- a/xlators/protocol/server/src/server-handshake.c +++ b/xlators/protocol/server/src/server-handshake.c @@ -432,8 +432,8 @@ server_setvolume (rpcsvc_request_t *req) } cancelled = server_cancel_conn_timer (this, conn); - if (cancelled) - server_conn_unref (conn); + if (cancelled)//Do connection_put on behalf of grace-timer-handler. + server_connection_put (this, conn, NULL); if (conn->lk_version != 0 && conn->lk_version != lk_version) { (void) server_connection_cleanup (this, conn); @@ -723,7 +723,7 @@ server_set_lk_version (rpcsvc_request_t *req) conn = server_connection_get (this, args.uid); conn->lk_version = args.lk_ver; - server_conn_unref (conn); + server_connection_put (this, conn, NULL); rsp.lk_ver = args.lk_ver; -- cgit