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