From bae32a5affd514e5a78ba3af6cc644cd5cd6814a Mon Sep 17 00:00:00 2001 From: Emmanuel Dreyfus Date: Tue, 30 Apr 2013 02:41:09 +0200 Subject: Fix spurious brick disconnects Spurious disconnect were caused by a race condition inside rpc_transport_ref()/rpc_transport_unref() that allowed the refcount to drop to zero while the transport was still in use. The race condition is made possible because of an uninitiaized mutex produced when socket_server_event_handler() copies the transport This is a backport of I34fe097a0ac21b0dbf58f5eed84880e3fd9814f2 BUG: 764655 Change-Id: Ib6a7c736f28ccc67d05be45629cddc18a642c11f Signed-off-by: Emmanuel Dreyfus Reviewed-on: http://review.gluster.org/4908 Tested-by: Gluster Build System Reviewed-by: Kaleb KEITHLEY Reviewed-by: Anand Avati --- rpc/rpc-transport/socket/src/socket.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'rpc') diff --git a/rpc/rpc-transport/socket/src/socket.c b/rpc/rpc-transport/socket/src/socket.c index 3f189e3b9..d6ae84552 100644 --- a/rpc/rpc-transport/socket/src/socket.c +++ b/rpc/rpc-transport/socket/src/socket.c @@ -2472,6 +2472,15 @@ socket_server_event_handler (int fd, int idx, void *data, if (!new_trans) goto unlock; + ret = pthread_mutex_init(&new_trans->lock, NULL); + if (ret == -1) { + gf_log (this->name, GF_LOG_WARNING, + "pthread_mutex_init() failed: %s", + strerror (errno)); + close (new_sock); + goto unlock; + } + new_trans->name = gf_strdup (this->name); memcpy (&new_trans->peerinfo.sockaddr, &new_sockaddr, -- cgit