d84cf8
From 73cef29731c0d7b8b4f3b880c032dc232b8fcc31 Mon Sep 17 00:00:00 2001
d84cf8
From: Mohit Agrawal <moagrawa@redhat.com>
d84cf8
Date: Thu, 4 Jun 2020 16:06:44 +0530
d84cf8
Subject: [PATCH 397/449] mgmt/brick-mux: Avoid sending two response when
d84cf8
 attach is failed.
d84cf8
d84cf8
We were sending two response back to glusterd when an attach is
d84cf8
failed. One from the handler function glusterfs_handle_attach and
d84cf8
another from rpcsvc_check_and_reply_error. It was causing problems
d84cf8
like ref leaks, transport disconnect etc.
d84cf8
d84cf8
> Change-Id: I3bb5b59959530760b568d52becb519499b3dcd2b
d84cf8
> updates: bz#1785143
d84cf8
> Signed-off-by: Mohammed Rafi KC <rkavunga@redhat.com>
d84cf8
> (Cherry pick from commit 42f484dcecd9942611396d9bd2ad3a39019b0e1f)
d84cf8
> (Reviewed on upstream link https://review.gluster.org/#/c/glusterfs/+/23906/)
d84cf8
d84cf8
Change-Id: I3bb5b59959530760b568d52becb519499b3dcd2b
d84cf8
BUG: 1776901
d84cf8
Signed-off-by: Mohit Agrawal <moagrawa@redhat.com>
d84cf8
Reviewed-on: https://code.engineering.redhat.com/gerrit/202346
d84cf8
Reviewed-by: Sanju Rakonde <srakonde@redhat.com>
d84cf8
Tested-by: RHGS Build Bot <nigelb@redhat.com>
d84cf8
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
d84cf8
---
d84cf8
 glusterfsd/src/glusterfsd-mgmt.c | 10 +++++++++-
d84cf8
 1 file changed, 9 insertions(+), 1 deletion(-)
d84cf8
d84cf8
diff --git a/glusterfsd/src/glusterfsd-mgmt.c b/glusterfsd/src/glusterfsd-mgmt.c
d84cf8
index 15acc10..61d1b21 100644
d84cf8
--- a/glusterfsd/src/glusterfsd-mgmt.c
d84cf8
+++ b/glusterfsd/src/glusterfsd-mgmt.c
d84cf8
@@ -954,7 +954,15 @@ glusterfs_handle_attach(rpcsvc_request_t *req)
d84cf8
             ret = -1;
d84cf8
         }
d84cf8
 
d84cf8
-        glusterfs_translator_info_response_send(req, ret, NULL, NULL);
d84cf8
+        ret = glusterfs_translator_info_response_send(req, ret, NULL, NULL);
d84cf8
+        if (ret) {
d84cf8
+            /* Response sent back to glusterd, req is already destroyed. So
d84cf8
+             * resetting the ret to 0. Otherwise another response will be
d84cf8
+             * send from rpcsvc_check_and_reply_error. Which will lead to
d84cf8
+             * double resource leak.
d84cf8
+             */
d84cf8
+            ret = 0;
d84cf8
+        }
d84cf8
 
d84cf8
     out:
d84cf8
         UNLOCK(&ctx->volfile_lock);
d84cf8
-- 
d84cf8
1.8.3.1
d84cf8