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