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