[Gluster-devel] [FIXED] Question on rpc_transport_unref
Emmanuel Dreyfus
manu at netbsd.org
Mon Apr 29 15:00:05 UTC 2013
On Sun, Apr 28, 2013 at 03:24:38PM +0200, Emmanuel Dreyfus wrote:
> This explains the reference dropping to 0, but it is odd, I just don't get
> it, it makes no sense:
> 1367153818.291115 server_alloc_frame 0x7f7ff73b6000 7 -> 6
I found the problem: a race condition caused by an unitialized mutex
Here is a patch. I note that in case of failure, there are also memory
leaks in that same function (the data copied by gf_strdup if goto unlock,
for instance)
--- rpc/rpc-transport/socket/src/socket.c.orig
+++ rpc/rpc-transport/socket/src/socket.c
@@ -2471,8 +2471,17 @@
gf_common_mt_rpc_trans_t);
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,
addrlen);
--
Emmanuel Dreyfus
manu at netbsd.org
More information about the Gluster-devel
mailing list