summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/providers/data_provider_callbacks.c35
-rw-r--r--src/providers/dp_backend.h8
2 files changed, 43 insertions, 0 deletions
diff --git a/src/providers/data_provider_callbacks.c b/src/providers/data_provider_callbacks.c
index 9d8946a8..0f8fca0b 100644
--- a/src/providers/data_provider_callbacks.c
+++ b/src/providers/data_provider_callbacks.c
@@ -141,6 +141,41 @@ static errno_t be_run_cb(struct be_ctx *be, struct be_cb *cb_list) {
return EOK;
}
+int be_add_reconnect_cb(TALLOC_CTX *mem_ctx, struct be_ctx *ctx, be_callback_t cb,
+ void *pvt, struct be_cb **reconnect_cb)
+{
+ int ret;
+
+ ret = be_add_cb(mem_ctx, ctx, cb, pvt, &ctx->reconnect_cb_list, reconnect_cb);
+ if (ret != EOK) {
+ DEBUG(SSSDBG_CRIT_FAILURE, ("be_add_cb failed.\n"));
+ return ret;
+ }
+
+ return EOK;
+}
+
+void be_run_reconnect_cb(struct be_ctx *be)
+{
+ struct be_cb *callback = be->reconnect_cb_list;
+
+ if (callback) {
+ DEBUG(SSSDBG_TRACE_FUNC, ("Reconnecting. Running callbacks.\n"));
+
+ /**
+ * Call the callback: we have to call this right away
+ * so the provider doesn't go into offline even for
+ * a little while
+ */
+ do {
+ callback->cb(callback->pvt);
+ callback = callback->next;
+ } while(callback != NULL);
+ } else {
+ DEBUG(SSSDBG_TRACE_INTERNAL, ("Reconnect call back list is empty, nothing to do.\n"));
+ }
+}
+
int be_add_online_cb(TALLOC_CTX *mem_ctx, struct be_ctx *ctx, be_callback_t cb,
void *pvt, struct be_cb **online_cb)
{
diff --git a/src/providers/dp_backend.h b/src/providers/dp_backend.h
index 6496697d..41dd3f6d 100644
--- a/src/providers/dp_backend.h
+++ b/src/providers/dp_backend.h
@@ -107,6 +107,7 @@ struct be_ctx {
struct be_cb *online_cb_list;
bool run_online_cb;
struct be_cb *offline_cb_list;
+ struct be_cb *reconnect_cb_list;
struct be_offline_status offstat;
@@ -186,6 +187,13 @@ struct be_host_req {
bool be_is_offline(struct be_ctx *ctx);
void be_mark_offline(struct be_ctx *ctx);
+int be_add_reconnect_cb(TALLOC_CTX *mem_ctx,
+ struct be_ctx *ctx,
+ be_callback_t cb,
+ void *pvt,
+ struct be_cb **reconnect_cb);
+void be_run_reconnect_cb(struct be_ctx *be);
+
int be_add_online_cb(TALLOC_CTX *mem_ctx,
struct be_ctx *ctx,
be_callback_t cb,