When working on the GC lookups I found out that the recent dyndns patches were scheduling the periodic updates even if dyndns_update was set to false. The attached patch fixes that. Sorry for the breakage.
>From 8e95eab5b31925f5d2549fa4d78305ed2f175379 Mon Sep 17 00:00:00 2001 From: Jakub Hrozek <jhro...@redhat.com> Date: Sun, 19 May 2013 17:36:54 +0200 Subject: [PATCH] Fix dyndns timer initialization
The dyndns init function was starting the timer even if the updates were set to False. This patch splits the init of dynamic updates and the timer into two functions so that the back end can start the updates separately from reading the options. --- src/providers/ad/ad_common.c | 4 ++-- src/providers/ad/ad_dyndns.c | 7 +++++++ src/providers/dp_dyndns.c | 16 ++++++++++++---- src/providers/dp_dyndns.h | 7 +++++-- src/providers/ipa/ipa_common.c | 3 +-- src/providers/ipa/ipa_dyndns.c | 7 +++++++ src/tests/cmocka/test_dyndns.c | 6 +++++- 7 files changed, 39 insertions(+), 11 deletions(-) diff --git a/src/providers/ad/ad_common.c b/src/providers/ad/ad_common.c index e0a55c6dcd5a738ca5a40ec30c448c4b167dc980..e34199959cb7ca3cd21f7d188a624e03fb12162e 100644 --- a/src/providers/ad/ad_common.c +++ b/src/providers/ad/ad_common.c @@ -705,8 +705,8 @@ errno_t ad_get_dyndns_options(struct be_ctx *be_ctx, { errno_t ret; - ret = be_nsupdate_init(ad_opts, be_ctx, ad_dyndns_opts, ad_dyndns_timer, - ad_opts, &ad_opts->dyndns_ctx); + ret = be_nsupdate_init(ad_opts, be_ctx, ad_dyndns_opts, + &ad_opts->dyndns_ctx); if (ret != EOK) { DEBUG(SSSDBG_OP_FAILURE, ("Cannot initialize AD dyndns opts [%d]: %s\n", diff --git a/src/providers/ad/ad_dyndns.c b/src/providers/ad/ad_dyndns.c index 2b2d246251791a290db8a7fda47520b21b8a6d6f..4e9ed852f91b8f99a0363b0f31af857ef98e8130 100644 --- a/src/providers/ad/ad_dyndns.c +++ b/src/providers/ad/ad_dyndns.c @@ -70,6 +70,13 @@ errno_t ad_dyndns_init(struct be_ctx *be_ctx, return EINVAL; } + ret = be_nsupdate_init_timer(ad_opts->dyndns_ctx, be_ctx->ev, + ad_dyndns_timer, ad_opts); + if (ret != EOK) { + DEBUG(SSSDBG_CRIT_FAILURE, ("Could not set up periodic update\n")); + return ret; + } + ret = be_add_online_cb(be_ctx, be_ctx, ad_dyndns_update, ad_opts, NULL); diff --git a/src/providers/dp_dyndns.c b/src/providers/dp_dyndns.c index 8cf42443a9f50cee3a58724dc612dcc83cbdf860..1b710b554ac666c5929517375bff6f8ec2fc2abf 100644 --- a/src/providers/dp_dyndns.c +++ b/src/providers/dp_dyndns.c @@ -1181,8 +1181,6 @@ static struct dp_option default_dyndns_opts[] = { errno_t be_nsupdate_init(TALLOC_CTX *mem_ctx, struct be_ctx *be_ctx, struct dp_option *defopts, - nsupdate_timer_fn_t timer_callback, - void *timer_pvt, struct be_nsupdate_ctx **_ctx) { errno_t ret; @@ -1212,10 +1210,20 @@ be_nsupdate_init(TALLOC_CTX *mem_ctx, struct be_ctx *be_ctx, return EINVAL; } + *_ctx = ctx; + return ERR_OK; +} + +errno_t be_nsupdate_init_timer(struct be_nsupdate_ctx *ctx, + struct tevent_context *ev, + nsupdate_timer_fn_t timer_callback, + void *timer_pvt) +{ + if (ctx == NULL) return EINVAL; + ctx->timer_callback = timer_callback; ctx->timer_pvt = timer_pvt; - be_nsupdate_timer_schedule(be_ctx->ev, ctx); + be_nsupdate_timer_schedule(ev, ctx); - *_ctx = ctx; return ERR_OK; } diff --git a/src/providers/dp_dyndns.h b/src/providers/dp_dyndns.h index 14b2dd08b03a422b2c0bc5bc5b184baf54491bca..1e81c9b91df9f6cbc03b261341aa79c03b6372f1 100644 --- a/src/providers/dp_dyndns.h +++ b/src/providers/dp_dyndns.h @@ -67,10 +67,13 @@ errno_t be_nsupdate_check(void); errno_t be_nsupdate_init(TALLOC_CTX *mem_ctx, struct be_ctx *be_ctx, struct dp_option *defopts, - nsupdate_timer_fn_t timer_callback, - void *timer_pvt, struct be_nsupdate_ctx **_ctx); +errno_t be_nsupdate_init_timer(struct be_nsupdate_ctx *ctx, + struct tevent_context *ev, + nsupdate_timer_fn_t timer_callback, + void *timer_pvt); + void be_nsupdate_timer_schedule(struct tevent_context *ev, struct be_nsupdate_ctx *ctx); diff --git a/src/providers/ipa/ipa_common.c b/src/providers/ipa/ipa_common.c index baece274ed48b9446806bf1103789b2ace9c0d95..509b2abd0b9b2ff1af04b353e0a44df573e3790a 100644 --- a/src/providers/ipa/ipa_common.c +++ b/src/providers/ipa/ipa_common.c @@ -1019,8 +1019,7 @@ errno_t ipa_get_dyndns_options(struct be_ctx *be_ctx, bool update; int ttl; - ret = be_nsupdate_init(ctx, be_ctx, ipa_dyndns_opts, ipa_dyndns_timer, - ctx, &ctx->dyndns_ctx); + ret = be_nsupdate_init(ctx, be_ctx, ipa_dyndns_opts, &ctx->dyndns_ctx); if (ret != EOK) { DEBUG(SSSDBG_OP_FAILURE, ("Cannot initialize IPA dyndns opts [%d]: %s\n", diff --git a/src/providers/ipa/ipa_dyndns.c b/src/providers/ipa/ipa_dyndns.c index 81dae94a5029be39501ff321db07cd18439395f5..4e75a197a293110a8949809030c95567734fece5 100644 --- a/src/providers/ipa/ipa_dyndns.c +++ b/src/providers/ipa/ipa_dyndns.c @@ -44,6 +44,13 @@ errno_t ipa_dyndns_init(struct be_ctx *be_ctx, return EINVAL; } + ret = be_nsupdate_init_timer(ctx->dyndns_ctx, be_ctx->ev, + ipa_dyndns_timer, ctx); + if (ret != EOK) { + DEBUG(SSSDBG_CRIT_FAILURE, ("Could not set up periodic update\n")); + return ret; + } + ret = be_add_online_cb(be_ctx, be_ctx, ipa_dyndns_update, ctx, NULL); diff --git a/src/tests/cmocka/test_dyndns.c b/src/tests/cmocka/test_dyndns.c index 6d5219d71b65612fc290c19e2fbb663ee077c119..f804d792669d9e1546355fbb449c48fe975efcba 100644 --- a/src/tests/cmocka/test_dyndns.c +++ b/src/tests/cmocka/test_dyndns.c @@ -311,10 +311,14 @@ void dyndns_test_interval(void **state) check_leaks_push(tmp_ctx); ret = be_nsupdate_init(tmp_ctx, dyndns_test_ctx->be_ctx, NULL, - dyndns_test_timer, dyndns_test_ctx, &dyndns_test_ctx->update_ctx); assert_int_equal(ret, EOK); + ret = be_nsupdate_init_timer(dyndns_test_ctx->update_ctx, + dyndns_test_ctx->be_ctx->ev, + dyndns_test_timer, dyndns_test_ctx); + assert_int_equal(ret, EOK); + /* Wait until the timer hits */ ret = test_ev_loop(dyndns_test_ctx->tctx); DEBUG(SSSDBG_TRACE_LIBS, -- 1.8.2.1
_______________________________________________ sssd-devel mailing list sssd-devel@lists.fedorahosted.org https://lists.fedorahosted.org/mailman/listinfo/sssd-devel