sssd/0055-DYNDNS-Move-the-retry-logic-into-a-separate-function.patch
2018-05-14 09:54:10 +02:00

64 lines
2.3 KiB
Diff

From 4452b5e6adb03378ccb8e581e60e73c2237644cf Mon Sep 17 00:00:00 2001
From: Jakub Hrozek <jhrozek@redhat.com>
Date: Mon, 30 Apr 2018 11:16:25 +0200
Subject: [PATCH] DYNDNS: Move the retry logic into a separate function
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Let's not repeat ourselves
Related to:
https://pagure.io/SSSD/sssd/issue/3725
Reviewed-by: Fabiano Fidêncio <fidencio@redhat.com>
(cherry picked from commit 65034a715e5071ad944bf37b414c6a36bf60cf29)
---
src/providers/ldap/sdap_dyndns.c | 16 ++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)
diff --git a/src/providers/ldap/sdap_dyndns.c b/src/providers/ldap/sdap_dyndns.c
index 9d28b5758..f791ba9f3 100644
--- a/src/providers/ldap/sdap_dyndns.c
+++ b/src/providers/ldap/sdap_dyndns.c
@@ -79,6 +79,16 @@ static struct sss_iface_addr*
sdap_get_address_to_delete(struct sss_iface_addr *address_it,
uint8_t remove_af);
+static bool should_retry(int child_status)
+{
+ if (WIFEXITED(child_status)
+ && WEXITSTATUS(child_status) != 0) {
+ return true;
+ }
+
+ return false;
+}
+
struct tevent_req *
sdap_dyndns_update_send(TALLOC_CTX *mem_ctx,
struct tevent_context *ev,
@@ -371,8 +381,7 @@ sdap_dyndns_update_done(struct tevent_req *subreq)
if (ret != EOK) {
/* If the update didn't succeed, we can retry using the server name */
if (state->fallback_mode == false
- && WIFEXITED(child_status)
- && WEXITSTATUS(child_status) != 0) {
+ && should_retry(child_status)) {
state->fallback_mode = true;
DEBUG(SSSDBG_MINOR_FAILURE,
"nsupdate failed, retrying.\n");
@@ -514,8 +523,7 @@ sdap_dyndns_update_ptr_done(struct tevent_req *subreq)
if (ret != EOK) {
/* If the update didn't succeed, we can retry using the server name */
if (state->fallback_mode == false
- && WIFEXITED(child_status)
- && WEXITSTATUS(child_status) != 0) {
+ && should_retry(child_status)) {
state->fallback_mode = true;
DEBUG(SSSDBG_MINOR_FAILURE, "nsupdate failed, retrying\n");
ret = sdap_dyndns_update_ptr_step(req);
--
2.17.0