Blame SOURCES/0094-FO-Add-an-API-to-reset-all-servers-in-a-single-servi.patch

6cf099
From 3551dd5c2c2c75ce68ef95b91fc2420f17c92b92 Mon Sep 17 00:00:00 2001
6cf099
From: Jakub Hrozek <jhrozek@redhat.com>
6cf099
Date: Mon, 21 Sep 2015 12:31:18 +0200
6cf099
Subject: [PATCH 94/96] FO: Add an API to reset all servers in a single service
6cf099
6cf099
Required for:
6cf099
    https://fedorahosted.org/sssd/ticket/2639
6cf099
6cf099
Previously, we had a function that allowed the caller to reset the
6cf099
status of all services in the global fail over context. This patch adds
6cf099
a new function that allows the caller to reset a single service instead.
6cf099
6cf099
The main user would be IPA subdomain provider that might need to reset
6cf099
the status of an AD trusted domain on demand.
6cf099
6cf099
Reviewed-by: Sumit Bose <sbose@redhat.com>
6cf099
(cherry picked from commit 3ac3b5746f08970c109664b95340c556057e3c6a)
6cf099
---
6cf099
 src/providers/data_provider_fo.c | 19 +++++++++++++++++++
6cf099
 src/providers/dp_backend.h       |  1 +
6cf099
 src/providers/fail_over.c        | 30 ++++++++++++++++++++----------
6cf099
 src/providers/fail_over.h        |  2 ++
6cf099
 4 files changed, 42 insertions(+), 10 deletions(-)
6cf099
6cf099
diff --git a/src/providers/data_provider_fo.c b/src/providers/data_provider_fo.c
6cf099
index 41d70de065260f31dcea4c2b664a1f436823ccc1..cd57340a0ba0ac7e474dc502bf1f1b4de0e1f778 100644
6cf099
--- a/src/providers/data_provider_fo.c
6cf099
+++ b/src/providers/data_provider_fo.c
6cf099
@@ -743,6 +743,25 @@ void reset_fo(struct be_ctx *be_ctx)
6cf099
     fo_reset_services(be_ctx->be_fo->fo_ctx);
6cf099
 }
6cf099
 
6cf099
+void be_fo_reset_svc(struct be_ctx *be_ctx,
6cf099
+                     const char *svc_name)
6cf099
+{
6cf099
+    struct fo_service *service;
6cf099
+    int ret;
6cf099
+
6cf099
+    DEBUG(SSSDBG_TRACE_LIBS,
6cf099
+          "Resetting all servers in service %s\n", svc_name);
6cf099
+
6cf099
+    ret = fo_get_service(be_ctx->be_fo->fo_ctx, svc_name, &service);
6cf099
+    if (ret != EOK) {
6cf099
+        DEBUG(SSSDBG_MINOR_FAILURE,
6cf099
+              "Cannot retrieve service [%s]\n", svc_name);
6cf099
+        return;
6cf099
+    }
6cf099
+
6cf099
+    fo_reset_servers(service);
6cf099
+}
6cf099
+
6cf099
 void _be_fo_set_port_status(struct be_ctx *ctx,
6cf099
                             const char *service_name,
6cf099
                             struct fo_server *server,
6cf099
diff --git a/src/providers/dp_backend.h b/src/providers/dp_backend.h
6cf099
index 4bffcee9e8739302343b7813d3540eb43e966581..0ced851be8468ce21a9d283e26461fc47194557e 100644
6cf099
--- a/src/providers/dp_backend.h
6cf099
+++ b/src/providers/dp_backend.h
6cf099
@@ -283,6 +283,7 @@ int be_fo_run_callbacks_at_next_request(struct be_ctx *ctx,
6cf099
                                         const char *service_name);
6cf099
 
6cf099
 void reset_fo(struct be_ctx *be_ctx);
6cf099
+void be_fo_reset_svc(struct be_ctx *be_ctx, const char *svc_name);
6cf099
 
6cf099
 errno_t be_res_init(struct be_ctx *ctx);
6cf099
 
6cf099
diff --git a/src/providers/fail_over.c b/src/providers/fail_over.c
6cf099
index 6d835ae0efdfdf96532e8458e12238ba17910a4f..562f0b3fd7870387a80c889b245cda0d39dea509 100644
6cf099
--- a/src/providers/fail_over.c
6cf099
+++ b/src/providers/fail_over.c
6cf099
@@ -1547,21 +1547,31 @@ time_t fo_get_service_retry_timeout(struct fo_service *svc)
6cf099
     return svc->ctx->opts->retry_timeout;
6cf099
 }
6cf099
 
6cf099
+void fo_reset_servers(struct fo_service *service)
6cf099
+{
6cf099
+    struct fo_server *server;
6cf099
+
6cf099
+    DLIST_FOR_EACH(server, service->server_list) {
6cf099
+        if (server->srv_data != NULL) {
6cf099
+            set_srv_data_status(server->srv_data, SRV_NEUTRAL);
6cf099
+        } else {
6cf099
+            fo_set_server_status(server, SERVER_NAME_NOT_RESOLVED);
6cf099
+        }
6cf099
+
6cf099
+        fo_set_port_status(server, PORT_NEUTRAL);
6cf099
+    }
6cf099
+}
6cf099
+
6cf099
+
6cf099
 void fo_reset_services(struct fo_ctx *fo_ctx)
6cf099
 {
6cf099
     struct fo_service *service;
6cf099
-    struct fo_server *server;
6cf099
+
6cf099
+    DEBUG(SSSDBG_TRACE_LIBS,
6cf099
+          "Resetting all servers in all services\n");
6cf099
 
6cf099
     DLIST_FOR_EACH(service, fo_ctx->service_list) {
6cf099
-        DLIST_FOR_EACH(server, service->server_list) {
6cf099
-            if (server->srv_data != NULL) {
6cf099
-                set_srv_data_status(server->srv_data, SRV_NEUTRAL);
6cf099
-            } else {
6cf099
-                fo_set_server_status(server, SERVER_NAME_NOT_RESOLVED);
6cf099
-            }
6cf099
-
6cf099
-            fo_set_port_status(server, PORT_NEUTRAL);
6cf099
-        }
6cf099
+        fo_reset_servers(service);
6cf099
     }
6cf099
 }
6cf099
 
6cf099
diff --git a/src/providers/fail_over.h b/src/providers/fail_over.h
6cf099
index d44ad2ff145dc6b3617e6f2ea665c7d82d923ddb..e49c6414a14eb6ca2cad333f8efbb58576811345 100644
6cf099
--- a/src/providers/fail_over.h
6cf099
+++ b/src/providers/fail_over.h
6cf099
@@ -198,6 +198,8 @@ time_t fo_get_service_retry_timeout(struct fo_service *svc);
6cf099
 
6cf099
 void fo_reset_services(struct fo_ctx *fo_ctx);
6cf099
 
6cf099
+void fo_reset_servers(struct fo_service *svc);
6cf099
+
6cf099
 bool fo_svc_has_server(struct fo_service *service, struct fo_server *server);
6cf099
 
6cf099
 /*
6cf099
-- 
6cf099
2.4.3
6cf099