Blob Blame History Raw
From 1e9abd508ea5627465d528788645d4dbe53d7d31 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Pawe=C5=82=20Po=C5=82awski?= <ppolawsk@redhat.com>
Date: Wed, 2 Dec 2020 03:00:26 +0100
Subject: [PATCH 17/18] data_provider_be: Add random offset default

Replace hardcoded default value of 30 with more meaningful
OFFLINE_TIMEOUT_RANDOM_OFFSET define.

This value is used to calculate task timeout during offline
status checking by formula (from SSSD MAN page):

new_interval = (old_interval * 2) + random_offset

As it is explicite mentioned in documentation it should
be expressed in the code similar way.

Reviewed-by: Iker Pedrosa <ipedrosa@redhat.com>
---
 src/providers/data_provider_be.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/src/providers/data_provider_be.c b/src/providers/data_provider_be.c
index 4c10d6b48..10421c6b4 100644
--- a/src/providers/data_provider_be.c
+++ b/src/providers/data_provider_be.c
@@ -51,6 +51,7 @@
 #define ONLINE_CB_RETRY 3
 #define ONLINE_CB_RETRY_MAX_DELAY 4
 
+#define OFFLINE_TIMEOUT_RANDOM_OFFSET 30
 #define OFFLINE_TIMEOUT_DEFAULT 60
 #define OFFLINE_TIMEOUT_MAX_DEFAULT 3600
 
@@ -152,9 +153,13 @@ void be_mark_offline(struct be_ctx *ctx)
         offline_timeout = get_offline_timeout(ctx);
         offline_timeout_max = get_offline_timeout_max(ctx);
 
-        ret = be_ptask_create_sync(ctx, ctx,
-                                   offline_timeout, offline_timeout,
-                                   offline_timeout, 30, offline_timeout,
+        ret = be_ptask_create_sync(ctx,
+                                   ctx,
+                                   offline_timeout,
+                                   offline_timeout,
+                                   offline_timeout,
+                                   OFFLINE_TIMEOUT_RANDOM_OFFSET,
+                                   offline_timeout,
                                    offline_timeout_max,
                                    try_to_go_online,
                                    ctx, "Check if online (periodic)",
-- 
2.21.3