7f4c2a
From 08f9a81283ca783513b11c4a0b99519671f489d8 Mon Sep 17 00:00:00 2001
7f4c2a
From: vmallika <vmallika@redhat.com>
7f4c2a
Date: Mon, 6 Jul 2015 16:18:45 +0530
7f4c2a
Subject: [PATCH 218/234] quotad: create sock listener only after graph init is complete
7f4c2a
7f4c2a
This is a backport of http://review.gluster.org/#/c/11552/
7f4c2a
7f4c2a
If FOPs are received before completing graph initialization,
7f4c2a
FOP path can crash while accessing uninitialized variables
7f4c2a
7f4c2a
This patch fixes issue by not creating listener until
7f4c2a
graph initialization is complete and hence not receiving
7f4c2a
FOP request
7f4c2a
7f4c2a
> Change-Id: I4771e376410843dff44bfe819329a4632523d266
7f4c2a
> BUG: 1240254
7f4c2a
> Signed-off-by: vmallika <vmallika@redhat.com>
7f4c2a
7f4c2a
Change-Id: I2158684bee24f6e653c9e4f7652b048c2a99564b
7f4c2a
BUG: 1239317
7f4c2a
Signed-off-by: vmallika <vmallika@redhat.com>
7f4c2a
Reviewed-on: https://code.engineering.redhat.com/gerrit/52532
7f4c2a
Reviewed-by: Raghavendra Gowdappa <rgowdapp@redhat.com>
7f4c2a
Tested-by: Raghavendra Gowdappa <rgowdapp@redhat.com>
7f4c2a
---
7f4c2a
 xlators/features/quota/src/quotad-aggregator.c |   10 +++++++
7f4c2a
 xlators/features/quota/src/quotad.c            |   32 +++++++++++++++++++++---
7f4c2a
 2 files changed, 38 insertions(+), 4 deletions(-)
7f4c2a
7f4c2a
diff --git a/xlators/features/quota/src/quotad-aggregator.c b/xlators/features/quota/src/quotad-aggregator.c
7f4c2a
index 6c9c40a..8a7cfdc 100644
7f4c2a
--- a/xlators/features/quota/src/quotad-aggregator.c
7f4c2a
+++ b/xlators/features/quota/src/quotad-aggregator.c
7f4c2a
@@ -374,6 +374,11 @@ quotad_aggregator_init (xlator_t *this)
7f4c2a
 
7f4c2a
         priv = this->private;
7f4c2a
 
7f4c2a
+        if (priv->rpcsvc) {
7f4c2a
+                /* Listener already created */
7f4c2a
+                return 0;
7f4c2a
+        }
7f4c2a
+
7f4c2a
         ret = dict_set_str (this->options, "transport.address-family", "unix");
7f4c2a
         if (ret)
7f4c2a
                 goto out;
7f4c2a
@@ -423,6 +428,11 @@ quotad_aggregator_init (xlator_t *this)
7f4c2a
 
7f4c2a
         ret = 0;
7f4c2a
 out:
7f4c2a
+        if (ret && priv->rpcsvc) {
7f4c2a
+                GF_FREE (priv->rpcsvc);
7f4c2a
+                priv->rpcsvc = NULL;
7f4c2a
+        }
7f4c2a
+
7f4c2a
         return ret;
7f4c2a
 }
7f4c2a
 
7f4c2a
diff --git a/xlators/features/quota/src/quotad.c b/xlators/features/quota/src/quotad.c
7f4c2a
index 243b943..028c804 100644
7f4c2a
--- a/xlators/features/quota/src/quotad.c
7f4c2a
+++ b/xlators/features/quota/src/quotad.c
7f4c2a
@@ -11,6 +11,18 @@
7f4c2a
 #include "quotad-aggregator.h"
7f4c2a
 #include "common-utils.h"
7f4c2a
 
7f4c2a
+int
7f4c2a
+qd_notify (xlator_t *this, int32_t event, void *data, ...)
7f4c2a
+{
7f4c2a
+        switch (event) {
7f4c2a
+        case GF_EVENT_PARENT_UP:
7f4c2a
+                quotad_aggregator_init (this);
7f4c2a
+        }
7f4c2a
+
7f4c2a
+        default_notify (this, event, data);
7f4c2a
+        return 0;
7f4c2a
+}
7f4c2a
+
7f4c2a
 int32_t
7f4c2a
 mem_acct_init (xlator_t *this)
7f4c2a
 {
7f4c2a
@@ -147,6 +159,21 @@ qd_reconfigure (xlator_t *this, dict_t *options)
7f4c2a
 void
7f4c2a
 qd_fini (xlator_t *this)
7f4c2a
 {
7f4c2a
+        quota_priv_t    *priv           = NULL;
7f4c2a
+
7f4c2a
+        if (this == NULL || this->private == NULL)
7f4c2a
+                goto out;
7f4c2a
+
7f4c2a
+        priv = this->private;
7f4c2a
+
7f4c2a
+        if (priv->rpcsvc) {
7f4c2a
+                GF_FREE (priv->rpcsvc);
7f4c2a
+                priv->rpcsvc = NULL;
7f4c2a
+        }
7f4c2a
+
7f4c2a
+        GF_FREE (priv);
7f4c2a
+
7f4c2a
+out:
7f4c2a
         return;
7f4c2a
 }
7f4c2a
 
7f4c2a
@@ -169,10 +196,6 @@ qd_init (xlator_t *this)
7f4c2a
 
7f4c2a
         this->private = priv;
7f4c2a
 
7f4c2a
-        ret = quotad_aggregator_init (this);
7f4c2a
-        if (ret < 0)
7f4c2a
-                goto err;
7f4c2a
-
7f4c2a
         ret = 0;
7f4c2a
 err:
7f4c2a
         if (ret) {
7f4c2a
@@ -185,6 +208,7 @@ class_methods_t class_methods = {
7f4c2a
         .init           = qd_init,
7f4c2a
         .fini           = qd_fini,
7f4c2a
         .reconfigure    = qd_reconfigure,
7f4c2a
+        .notify         = qd_notify
7f4c2a
 };
7f4c2a
 
7f4c2a
 struct xlator_fops fops = {
7f4c2a
-- 
7f4c2a
1.7.1
7f4c2a