Blame SOURCES/0077-DP-Initialize-D-Bus-as-soon-as-possible.patch

b2d430
From 178e61b6dc5b547bd77998f586f118bfa9b06d30 Mon Sep 17 00:00:00 2001
b2d430
From: =?UTF-8?q?Pavel=20B=C5=99ezina?= <pbrezina@redhat.com>
b2d430
Date: Fri, 5 Aug 2016 11:32:43 +0200
b2d430
Subject: [PATCH 77/82] DP: Initialize D-Bus as soon as possible
b2d430
b2d430
Resolves:
b2d430
https://fedorahosted.org/sssd/ticket/3111
b2d430
b2d430
Reviewed-by: Petr Cech <pcech@redhat.com>
b2d430
---
b2d430
 src/providers/data_provider/dp.c         | 34 +++++++++++++++++++-------------
b2d430
 src/providers/data_provider/dp_methods.c |  6 ++++++
b2d430
 2 files changed, 26 insertions(+), 14 deletions(-)
b2d430
b2d430
diff --git a/src/providers/data_provider/dp.c b/src/providers/data_provider/dp.c
b2d430
index c4590e3152126fe166d0bc9e3be2a14978f90168..b672370aa153c9cd2031399a8d61c95fb16cd641 100644
b2d430
--- a/src/providers/data_provider/dp.c
b2d430
+++ b/src/providers/data_provider/dp.c
b2d430
@@ -86,6 +86,7 @@ errno_t dp_init(struct tevent_context *ev,
b2d430
     provider->gid = gid;
b2d430
     provider->be_ctx = be_ctx;
b2d430
 
b2d430
+    /* Initialize request table. */
b2d430
     ret = dp_req_table_init(provider, &provider->requests.reply_table);
b2d430
     if (ret != EOK) {
b2d430
         DEBUG(SSSDBG_CRIT_FAILURE, "Unable to initialize request table "
b2d430
@@ -93,20 +94,11 @@ errno_t dp_init(struct tevent_context *ev,
b2d430
         goto done;
b2d430
     }
b2d430
 
b2d430
-    ret = dp_init_modules(provider, &provider->modules);
b2d430
-    if (ret != EOK) {
b2d430
-        DEBUG(SSSDBG_CRIT_FAILURE, "Unable to initialize DP modules "
b2d430
-              "[%d]: %s\n", ret, sss_strerror(ret));
b2d430
-        goto done;
b2d430
-    }
b2d430
-
b2d430
-    ret = dp_init_targets(provider, be_ctx, provider, provider->modules);
b2d430
-    if (ret != EOK) {
b2d430
-        DEBUG(SSSDBG_CRIT_FAILURE, "Unable to initialize DP targets "
b2d430
-              "[%d]: %s\n", ret, sss_strerror(ret));
b2d430
-        goto done;
b2d430
-    }
b2d430
-
b2d430
+    /* Initialize data provider bus. Data provider can receive client
b2d430
+     * registration and other D-Bus methods. However no data provider
b2d430
+     * request will be executed as long as the modules and targets
b2d430
+     * are not initialized.
b2d430
+     */
b2d430
     talloc_set_destructor(provider, dp_destructor);
b2d430
 
b2d430
     ret = dp_init_dbus_server(provider);
b2d430
@@ -118,6 +110,20 @@ errno_t dp_init(struct tevent_context *ev,
b2d430
 
b2d430
     be_ctx->provider = provider;
b2d430
 
b2d430
+    ret = dp_init_modules(provider, &provider->modules);
b2d430
+    if (ret != EOK) {
b2d430
+        DEBUG(SSSDBG_CRIT_FAILURE, "Unable to initialize DP modules "
b2d430
+              "[%d]: %s\n", ret, sss_strerror(ret));
b2d430
+        goto done;
b2d430
+    }
b2d430
+
b2d430
+    ret = dp_init_targets(provider, be_ctx, provider, provider->modules);
b2d430
+    if (ret != EOK) {
b2d430
+        DEBUG(SSSDBG_CRIT_FAILURE, "Unable to initialize DP targets "
b2d430
+              "[%d]: %s\n", ret, sss_strerror(ret));
b2d430
+        goto done;
b2d430
+    }
b2d430
+
b2d430
     ret = EOK;
b2d430
 
b2d430
 done:
b2d430
diff --git a/src/providers/data_provider/dp_methods.c b/src/providers/data_provider/dp_methods.c
b2d430
index e4290beeeef3c0c4d156271ad88f891d3245af08..498676d1bec2da300ca4b33f7110debcbf0aac00 100644
b2d430
--- a/src/providers/data_provider/dp_methods.c
b2d430
+++ b/src/providers/data_provider/dp_methods.c
b2d430
@@ -76,6 +76,12 @@ bool dp_method_enabled(struct data_provider *provider,
b2d430
         return false;
b2d430
     }
b2d430
 
b2d430
+    if (provider == NULL || provider->targets == NULL) {
b2d430
+        DEBUG(SSSDBG_TRACE_FUNC, "Target %s is not yet initialized\n",
b2d430
+              dp_target_to_string(target));
b2d430
+        return false;
b2d430
+    }
b2d430
+
b2d430
     dp_target = provider->targets[target];
b2d430
     if (dp_target == NULL || dp_target->initialized == false) {
b2d430
         DEBUG(SSSDBG_TRACE_FUNC, "Target %s is not configured\n",
b2d430
-- 
b2d430
2.4.11
b2d430