Blame SOURCES/0048-BE-Make-be_refresh_ctx_init-set-up-the-periodical-ta.patch

5fca41
From 739910de98cfc6c1c8764855703a6a8315bb09c6 Mon Sep 17 00:00:00 2001
5fca41
From: Jakub Hrozek <jhrozek@redhat.com>
5fca41
Date: Mon, 20 May 2019 22:32:13 +0200
5fca41
Subject: [PATCH 48/64] BE: Make be_refresh_ctx_init set up the periodical
5fca41
 task, too
5fca41
5fca41
This is mostly a preparatory patch that rolls in setting up the ptask
5fca41
into be_refresh_ctx_init. Since in later patches we will call
5fca41
be_refresh_ctx_init from several different places, this will prevent
5fca41
code duplication.
5fca41
5fca41
Related:
5fca41
https://pagure.io/SSSD/sssd/issue/4012
5fca41
5fca41
Reviewed-by: Sumit Bose <sbose@redhat.com>
5fca41
(cherry picked from commit bb0bd61ac54dca429b6562e808755152d4c90ce7)
5fca41
5fca41
Reviewed-by: Sumit Bose <sbose@redhat.com>
5fca41
---
5fca41
 src/providers/be_refresh.c       | 21 +++++++++++++++++++--
5fca41
 src/providers/be_refresh.h       |  2 +-
5fca41
 src/providers/data_provider_be.c | 14 --------------
5fca41
 3 files changed, 20 insertions(+), 17 deletions(-)
5fca41
5fca41
diff --git a/src/providers/be_refresh.c b/src/providers/be_refresh.c
5fca41
index 02e478c95..c7b048a95 100644
5fca41
--- a/src/providers/be_refresh.c
5fca41
+++ b/src/providers/be_refresh.c
5fca41
@@ -134,11 +134,13 @@ struct be_refresh_ctx {
5fca41
     struct be_refresh_cb callbacks[BE_REFRESH_TYPE_SENTINEL];
5fca41
 };
5fca41
 
5fca41
-struct be_refresh_ctx *be_refresh_ctx_init(TALLOC_CTX *mem_ctx)
5fca41
+struct be_refresh_ctx *be_refresh_ctx_init(struct be_ctx *be_ctx)
5fca41
 {
5fca41
     struct be_refresh_ctx *ctx = NULL;
5fca41
+    uint32_t refresh_interval;
5fca41
+    errno_t ret;
5fca41
 
5fca41
-    ctx = talloc_zero(mem_ctx, struct be_refresh_ctx);
5fca41
+    ctx = talloc_zero(be_ctx, struct be_refresh_ctx);
5fca41
     if (ctx == NULL) {
5fca41
         return NULL;
5fca41
     }
5fca41
@@ -147,6 +149,21 @@ struct be_refresh_ctx *be_refresh_ctx_init(TALLOC_CTX *mem_ctx)
5fca41
     ctx->callbacks[BE_REFRESH_TYPE_GROUPS].name = "groups";
5fca41
     ctx->callbacks[BE_REFRESH_TYPE_NETGROUPS].name = "netgroups";
5fca41
 
5fca41
+    refresh_interval = be_ctx->domain->refresh_expired_interval;
5fca41
+    if (refresh_interval > 0) {
5fca41
+        ret = be_ptask_create(be_ctx, be_ctx, refresh_interval, 30, 5, 0,
5fca41
+                              refresh_interval, BE_PTASK_OFFLINE_SKIP, 0,
5fca41
+                              be_refresh_send, be_refresh_recv,
5fca41
+                              be_ctx->refresh_ctx, "Refresh Records", NULL);
5fca41
+        if (ret != EOK) {
5fca41
+            DEBUG(SSSDBG_FATAL_FAILURE,
5fca41
+                  "Unable to initialize refresh periodic task [%d]: %s\n",
5fca41
+                  ret, sss_strerror(ret));
5fca41
+            talloc_free(ctx);
5fca41
+            return NULL;
5fca41
+        }
5fca41
+    }
5fca41
+
5fca41
     return ctx;
5fca41
 }
5fca41
 
5fca41
diff --git a/src/providers/be_refresh.h b/src/providers/be_refresh.h
5fca41
index 927fa4a33..664f01816 100644
5fca41
--- a/src/providers/be_refresh.h
5fca41
+++ b/src/providers/be_refresh.h
5fca41
@@ -52,7 +52,7 @@ enum be_refresh_type {
5fca41
 
5fca41
 struct be_refresh_ctx;
5fca41
 
5fca41
-struct be_refresh_ctx *be_refresh_ctx_init(TALLOC_CTX *mem_ctx);
5fca41
+struct be_refresh_ctx *be_refresh_ctx_init(struct be_ctx *be_ctx);
5fca41
 
5fca41
 errno_t be_refresh_add_cb(struct be_refresh_ctx *ctx,
5fca41
                           enum be_refresh_type type,
5fca41
diff --git a/src/providers/data_provider_be.c b/src/providers/data_provider_be.c
5fca41
index 17513111c..8dbddbb5f 100644
5fca41
--- a/src/providers/data_provider_be.c
5fca41
+++ b/src/providers/data_provider_be.c
5fca41
@@ -431,7 +431,6 @@ errno_t be_process_init(TALLOC_CTX *mem_ctx,
5fca41
                         struct tevent_context *ev,
5fca41
                         struct confdb_ctx *cdb)
5fca41
 {
5fca41
-    uint32_t refresh_interval;
5fca41
     struct tevent_signal *tes;
5fca41
     struct be_ctx *be_ctx;
5fca41
     char *str = NULL;
5fca41
@@ -531,19 +530,6 @@ errno_t be_process_init(TALLOC_CTX *mem_ctx,
5fca41
         goto done;
5fca41
     }
5fca41
 
5fca41
-    refresh_interval = be_ctx->domain->refresh_expired_interval;
5fca41
-    if (refresh_interval > 0) {
5fca41
-        ret = be_ptask_create(be_ctx, be_ctx, refresh_interval, 30, 5, 0,
5fca41
-                              refresh_interval, BE_PTASK_OFFLINE_SKIP, 0,
5fca41
-                              be_refresh_send, be_refresh_recv,
5fca41
-                              be_ctx->refresh_ctx, "Refresh Records", NULL);
5fca41
-        if (ret != EOK) {
5fca41
-            DEBUG(SSSDBG_FATAL_FAILURE,
5fca41
-                  "Unable to initialize refresh periodic task\n");
5fca41
-            goto done;
5fca41
-        }
5fca41
-    }
5fca41
-
5fca41
     ret = dp_init(be_ctx->ev, be_ctx, be_ctx->uid, be_ctx->gid);
5fca41
     if (ret != EOK) {
5fca41
         DEBUG(SSSDBG_FATAL_FAILURE, "Unable to setup data provider "
5fca41
-- 
5fca41
2.20.1
5fca41