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