[FIXED] Question on rpc_transport_unref

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx



[Index of Archives]     [Gluster Users]     [Ceph Users]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux