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