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