From 6f5472ad13a013bacd66d2f32a5addfe535239f3 Mon Sep 17 00:00:00 2001 From: Sumit Bose Date: Tue, 18 May 2010 11:11:52 +0200 Subject: Add run_callbacks flag --- src/providers/data_provider_fo.c | 25 +++++++++++++++++++++++-- src/providers/dp_backend.h | 2 ++ 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/src/providers/data_provider_fo.c b/src/providers/data_provider_fo.c index 14ebbdb5..56a072ae 100644 --- a/src/providers/data_provider_fo.c +++ b/src/providers/data_provider_fo.c @@ -42,6 +42,7 @@ struct be_svc_data { struct fo_service *fo_service; struct fo_server *last_good_srv; + bool run_callbacks; struct be_svc_callback *callbacks; }; @@ -414,9 +415,11 @@ static void be_resolve_server_done(struct tevent_req *subreq) fo_get_server_name(state->srv), ipaddr)); } - /* now call all svc callbacks if server changed */ - if (state->srv != state->svc->last_good_srv) { + /* now call all svc callbacks if server changed or if it is explicitly + * requested */ + if (state->srv != state->svc->last_good_srv || state->svc->run_callbacks) { state->svc->last_good_srv = state->srv; + state->svc->run_callbacks = false; DLIST_FOR_EACH(callback, state->svc->callbacks) { callback->fn(callback->private_data, state->srv); @@ -440,3 +443,21 @@ int be_resolve_server_recv(struct tevent_req *req, struct fo_server **srv) return EOK; } +int be_fo_run_callbacks_at_next_request(struct be_ctx *ctx, + const char *service_name) +{ + struct be_svc_data *svc; + + DLIST_FOR_EACH(svc, ctx->be_fo->svcs) { + if (strcmp(svc->name, service_name) == 0) { + break; + } + } + if (NULL == svc) { + return ENOENT; + } + + svc->run_callbacks = true; + + return EOK; +} diff --git a/src/providers/dp_backend.h b/src/providers/dp_backend.h index fc5e558c..0668859b 100644 --- a/src/providers/dp_backend.h +++ b/src/providers/dp_backend.h @@ -177,4 +177,6 @@ struct tevent_req *be_resolve_server_send(TALLOC_CTX *memctx, const char *service_name); int be_resolve_server_recv(struct tevent_req *req, struct fo_server **srv); +int be_fo_run_callbacks_at_next_request(struct be_ctx *ctx, + const char *service_name); #endif /* __DP_BACKEND_H___ */ -- cgit