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