Blame SOURCES/0055-BE-Extend-be_ptask_create-with-control-when-to-sched.patch

5cd47f
From 70d477efb1a43b3e1750b4aca868dadc2ed435d5 Mon Sep 17 00:00:00 2001
5cd47f
From: Jakub Hrozek <jhrozek@redhat.com>
5cd47f
Date: Tue, 18 Jun 2019 20:49:00 +0200
5cd47f
Subject: [PATCH 55/64] BE: Extend be_ptask_create() with control when to
5cd47f
 schedule next run after success
5cd47f
5cd47f
Related: https://pagure.io/SSSD/sssd/issue/4012
5cd47f
5cd47f
be_ptask_create() used to always schedule the next periodical run
5cd47f
"period" seconds after the previous run started. This is great for tasks
5cd47f
that are short-lived like DNS updates because we know they will be
5cd47f
executed really with the configured period.
5cd47f
5cd47f
But the background refresh task can potentially take a very long time in
5cd47f
which case the next run could have been scheduled almost immediately and
5cd47f
as a result sssd_be would always be quite busy. It is better to have the
5cd47f
option to schedule the next task period seconds after the last run has
5cd47f
finished. This can lead to some inconsistency, but we can warn the
5cd47f
admin about that.
5cd47f
5cd47f
This patch so far does not change any of the existing calls to
5cd47f
be_ptask_create(), just adds BE_PTASK_SCHEDULE_FROM_LAST as an
5cd47f
additional parameter.
5cd47f
5cd47f
Reviewed-by: Sumit Bose <sbose@redhat.com>
5cd47f
(cherry picked from commit 0fbc317ac7f1fe13cd41364c67db7d7a19d7d546)
5cd47f
5cd47f
Reviewed-by: Sumit Bose <sbose@redhat.com>
5cd47f
---
5cd47f
 src/providers/ad/ad_machine_pw_renewal.c |  4 +-
5cd47f
 src/providers/ad/ad_subdomains.c         |  4 +-
5cd47f
 src/providers/be_ptask.c                 | 10 ++--
5cd47f
 src/providers/be_ptask.h                 | 24 ++++++++-
5cd47f
 src/providers/be_ptask_private.h         |  1 +
5cd47f
 src/providers/be_refresh.c               |  4 +-
5cd47f
 src/providers/ipa/ipa_subdomains.c       |  4 +-
5cd47f
 src/providers/ldap/ldap_id_enum.c        |  1 +
5cd47f
 src/providers/ldap/sdap_sudo_shared.c    |  8 ++-
5cd47f
 src/tests/cmocka/test_be_ptask.c         | 62 ++++++++++++++++--------
5cd47f
 10 files changed, 89 insertions(+), 33 deletions(-)
5cd47f
5cd47f
diff --git a/src/providers/ad/ad_machine_pw_renewal.c b/src/providers/ad/ad_machine_pw_renewal.c
5cd47f
index 5b6ba26b7..47941dfbf 100644
5cd47f
--- a/src/providers/ad/ad_machine_pw_renewal.c
5cd47f
+++ b/src/providers/ad/ad_machine_pw_renewal.c
5cd47f
@@ -382,7 +382,9 @@ errno_t ad_machine_account_password_renewal_init(struct be_ctx *be_ctx,
5cd47f
     }
5cd47f
 
5cd47f
     ret = be_ptask_create(be_ctx, be_ctx, period, initial_delay, 0, 0, 60,
5cd47f
-                          BE_PTASK_OFFLINE_DISABLE, 0,
5cd47f
+                          BE_PTASK_OFFLINE_DISABLE,
5cd47f
+                          BE_PTASK_SCHEDULE_FROM_LAST,
5cd47f
+                          0,
5cd47f
                           ad_machine_account_password_renewal_send,
5cd47f
                           ad_machine_account_password_renewal_recv,
5cd47f
                           renewal_data,
5cd47f
diff --git a/src/providers/ad/ad_subdomains.c b/src/providers/ad/ad_subdomains.c
5cd47f
index e3e3d3ece..45a8fe0fc 100644
5cd47f
--- a/src/providers/ad/ad_subdomains.c
5cd47f
+++ b/src/providers/ad/ad_subdomains.c
5cd47f
@@ -2111,7 +2111,9 @@ errno_t ad_subdomains_init(TALLOC_CTX *mem_ctx,
5cd47f
 
5cd47f
     period = be_ctx->domain->subdomain_refresh_interval;
5cd47f
     ret = be_ptask_create(sd_ctx, be_ctx, period, 0, 0, 0, period,
5cd47f
-                          BE_PTASK_OFFLINE_DISABLE, 0,
5cd47f
+                          BE_PTASK_OFFLINE_DISABLE,
5cd47f
+                          BE_PTASK_SCHEDULE_FROM_LAST,
5cd47f
+                          0,
5cd47f
                           ad_subdomains_ptask_send, ad_subdomains_ptask_recv, sd_ctx,
5cd47f
                           "Subdomains Refresh", NULL);
5cd47f
     if (ret != EOK) {
5cd47f
diff --git a/src/providers/be_ptask.c b/src/providers/be_ptask.c
5cd47f
index c43351755..32d9a03ce 100644
5cd47f
--- a/src/providers/be_ptask.c
5cd47f
+++ b/src/providers/be_ptask.c
5cd47f
@@ -30,11 +30,6 @@
5cd47f
 
5cd47f
 #define backoff_allowed(ptask) (ptask->max_backoff != 0)
5cd47f
 
5cd47f
-enum be_ptask_schedule {
5cd47f
-    BE_PTASK_SCHEDULE_FROM_NOW,
5cd47f
-    BE_PTASK_SCHEDULE_FROM_LAST
5cd47f
-};
5cd47f
-
5cd47f
 enum be_ptask_delay {
5cd47f
     BE_PTASK_FIRST_DELAY,
5cd47f
     BE_PTASK_ENABLED_DELAY,
5cd47f
@@ -182,7 +177,7 @@ static void be_ptask_done(struct tevent_req *req)
5cd47f
         DEBUG(SSSDBG_TRACE_FUNC, "Task [%s]: finished successfully\n",
5cd47f
                                   task->name);
5cd47f
 
5cd47f
-        be_ptask_schedule(task, BE_PTASK_PERIOD, BE_PTASK_SCHEDULE_FROM_LAST);
5cd47f
+        be_ptask_schedule(task, BE_PTASK_PERIOD, task->success_schedule_type);
5cd47f
         break;
5cd47f
     default:
5cd47f
         DEBUG(SSSDBG_OP_FAILURE, "Task [%s]: failed with [%d]: %s\n",
5cd47f
@@ -268,6 +263,7 @@ errno_t be_ptask_create(TALLOC_CTX *mem_ctx,
5cd47f
                         time_t random_offset,
5cd47f
                         time_t timeout,
5cd47f
                         enum be_ptask_offline offline,
5cd47f
+                        enum be_ptask_schedule success_schedule_type,
5cd47f
                         time_t max_backoff,
5cd47f
                         be_ptask_send_t send_fn,
5cd47f
                         be_ptask_recv_t recv_fn,
5cd47f
@@ -300,6 +296,7 @@ errno_t be_ptask_create(TALLOC_CTX *mem_ctx,
5cd47f
     task->max_backoff = max_backoff;
5cd47f
     task->timeout = timeout;
5cd47f
     task->offline = offline;
5cd47f
+    task->success_schedule_type = success_schedule_type;
5cd47f
     task->send_fn = send_fn;
5cd47f
     task->recv_fn = recv_fn;
5cd47f
     task->pvt = pvt;
5cd47f
@@ -470,6 +467,7 @@ errno_t be_ptask_create_sync(TALLOC_CTX *mem_ctx,
5cd47f
 
5cd47f
     ret = be_ptask_create(mem_ctx, be_ctx, period, first_delay,
5cd47f
                           enabled_delay, random_offset, timeout, offline,
5cd47f
+                          BE_PTASK_SCHEDULE_FROM_LAST,
5cd47f
                           max_backoff, be_ptask_sync_send, be_ptask_sync_recv,
5cd47f
                           ctx, name, _task);
5cd47f
     if (ret != EOK) {
5cd47f
diff --git a/src/providers/be_ptask.h b/src/providers/be_ptask.h
5cd47f
index 3b9755361..c23278e88 100644
5cd47f
--- a/src/providers/be_ptask.h
5cd47f
+++ b/src/providers/be_ptask.h
5cd47f
@@ -46,6 +46,19 @@ enum be_ptask_offline {
5cd47f
     BE_PTASK_OFFLINE_EXECUTE
5cd47f
 };
5cd47f
 
5cd47f
+/**
5cd47f
+ * Defines the starting point for scheduling a task
5cd47f
+ */
5cd47f
+enum be_ptask_schedule {
5cd47f
+    /* Schedule starting from now, typically this is used when scheduling
5cd47f
+     * relative to the finish time
5cd47f
+     */
5cd47f
+    BE_PTASK_SCHEDULE_FROM_NOW,
5cd47f
+    /* Schedule relative to the start time of the task
5cd47f
+     */
5cd47f
+    BE_PTASK_SCHEDULE_FROM_LAST
5cd47f
+};
5cd47f
+
5cd47f
 typedef struct tevent_req *
5cd47f
 (*be_ptask_send_t)(TALLOC_CTX *mem_ctx,
5cd47f
                    struct tevent_context *ev,
5cd47f
@@ -75,6 +88,14 @@ typedef errno_t
5cd47f
  * The first execution is scheduled first_delay seconds after the task is
5cd47f
  * created.
5cd47f
  *
5cd47f
+ * Subsequent runs will be scheduled depending on the value of the
5cd47f
+ * success_schedule_type parameter:
5cd47f
+ *  - BE_PTASK_SCHEDULE_FROM_NOW: period seconds from the finish time
5cd47f
+ *  - BE_PTASK_SCHEDULE_FROM_LAST: period seconds from the last start time
5cd47f
+ *
5cd47f
+ * If the test fails, another run is always scheduled period seconds
5cd47f
+ * from the finish time.
5cd47f
+ *
5cd47f
  * If request does not complete in timeout seconds, it will be
5cd47f
  * cancelled and rescheduled to 'now + period'.
5cd47f
  *
5cd47f
@@ -83,7 +104,7 @@ typedef errno_t
5cd47f
  *
5cd47f
  * The random_offset is maximum number of seconds added to the
5cd47f
  * expected delay. Set to 0 if no randomization is needed.
5cd47f
-
5cd47f
+ *
5cd47f
  * If max_backoff is not 0 then the period is doubled
5cd47f
  * every time the task is scheduled. The maximum value of
5cd47f
  * period is max_backoff. The value of period will be reset to
5cd47f
@@ -100,6 +121,7 @@ errno_t be_ptask_create(TALLOC_CTX *mem_ctx,
5cd47f
                         time_t random_offset,
5cd47f
                         time_t timeout,
5cd47f
                         enum be_ptask_offline offline,
5cd47f
+                        enum be_ptask_schedule success_schedule_type,
5cd47f
                         time_t max_backoff,
5cd47f
                         be_ptask_send_t send_fn,
5cd47f
                         be_ptask_recv_t recv_fn,
5cd47f
diff --git a/src/providers/be_ptask_private.h b/src/providers/be_ptask_private.h
5cd47f
index 4144a3938..e89105f95 100644
5cd47f
--- a/src/providers/be_ptask_private.h
5cd47f
+++ b/src/providers/be_ptask_private.h
5cd47f
@@ -32,6 +32,7 @@ struct be_ptask {
5cd47f
     time_t timeout;
5cd47f
     time_t max_backoff;
5cd47f
     enum be_ptask_offline offline;
5cd47f
+    enum be_ptask_schedule success_schedule_type;
5cd47f
     be_ptask_send_t send_fn;
5cd47f
     be_ptask_recv_t recv_fn;
5cd47f
     void *pvt;
5cd47f
diff --git a/src/providers/be_refresh.c b/src/providers/be_refresh.c
5cd47f
index 5d86509bb..50b023c3d 100644
5cd47f
--- a/src/providers/be_refresh.c
5cd47f
+++ b/src/providers/be_refresh.c
5cd47f
@@ -156,7 +156,9 @@ errno_t be_refresh_ctx_init(struct be_ctx *be_ctx,
5cd47f
     refresh_interval = be_ctx->domain->refresh_expired_interval;
5cd47f
     if (refresh_interval > 0) {
5cd47f
         ret = be_ptask_create(be_ctx, be_ctx, refresh_interval, 30, 5, 0,
5cd47f
-                              refresh_interval, BE_PTASK_OFFLINE_SKIP, 0,
5cd47f
+                              refresh_interval, BE_PTASK_OFFLINE_SKIP,
5cd47f
+                              BE_PTASK_SCHEDULE_FROM_LAST,
5cd47f
+                              0,
5cd47f
                               be_refresh_send, be_refresh_recv,
5cd47f
                               ctx, "Refresh Records", NULL);
5cd47f
         if (ret != EOK) {
5cd47f
diff --git a/src/providers/ipa/ipa_subdomains.c b/src/providers/ipa/ipa_subdomains.c
5cd47f
index 94365aaca..3a17c851d 100644
5cd47f
--- a/src/providers/ipa/ipa_subdomains.c
5cd47f
+++ b/src/providers/ipa/ipa_subdomains.c
5cd47f
@@ -3134,7 +3134,9 @@ errno_t ipa_subdomains_init(TALLOC_CTX *mem_ctx,
5cd47f
 
5cd47f
     period = be_ctx->domain->subdomain_refresh_interval;
5cd47f
     ret = be_ptask_create(sd_ctx, be_ctx, period, ptask_first_delay, 0, 0, period,
5cd47f
-                          BE_PTASK_OFFLINE_DISABLE, 0,
5cd47f
+                          BE_PTASK_OFFLINE_DISABLE,
5cd47f
+                          BE_PTASK_SCHEDULE_FROM_LAST,
5cd47f
+                          0,
5cd47f
                           ipa_subdomains_ptask_send, ipa_subdomains_ptask_recv, sd_ctx,
5cd47f
                           "Subdomains Refresh", NULL);
5cd47f
     if (ret != EOK) {
5cd47f
diff --git a/src/providers/ldap/ldap_id_enum.c b/src/providers/ldap/ldap_id_enum.c
5cd47f
index 8832eb558..062185c55 100644
5cd47f
--- a/src/providers/ldap/ldap_id_enum.c
5cd47f
+++ b/src/providers/ldap/ldap_id_enum.c
5cd47f
@@ -99,6 +99,7 @@ errno_t ldap_setup_enumeration(struct be_ctx *be_ctx,
5cd47f
                           0,                        /* random offset */
5cd47f
                           period,                   /* timeout */
5cd47f
                           BE_PTASK_OFFLINE_SKIP,
5cd47f
+                          BE_PTASK_SCHEDULE_FROM_LAST,
5cd47f
                           0,                        /* max_backoff */
5cd47f
                           send_fn, recv_fn,
5cd47f
                           ectx, "enumeration", &sdom->enum_task);
5cd47f
diff --git a/src/providers/ldap/sdap_sudo_shared.c b/src/providers/ldap/sdap_sudo_shared.c
5cd47f
index 66b788702..982fdbf7f 100644
5cd47f
--- a/src/providers/ldap/sdap_sudo_shared.c
5cd47f
+++ b/src/providers/ldap/sdap_sudo_shared.c
5cd47f
@@ -90,7 +90,9 @@ sdap_sudo_ptask_setup_generic(struct be_ctx *be_ctx,
5cd47f
      * when offline. */
5cd47f
     if (full > 0) {
5cd47f
         ret = be_ptask_create(be_ctx, be_ctx, full, delay, 0, 0, full,
5cd47f
-                              BE_PTASK_OFFLINE_DISABLE, 0,
5cd47f
+                              BE_PTASK_OFFLINE_DISABLE,
5cd47f
+                              BE_PTASK_SCHEDULE_FROM_LAST,
5cd47f
+                              0,
5cd47f
                               full_send_fn, full_recv_fn, pvt,
5cd47f
                               "SUDO Full Refresh", NULL);
5cd47f
         if (ret != EOK) {
5cd47f
@@ -107,7 +109,9 @@ sdap_sudo_ptask_setup_generic(struct be_ctx *be_ctx,
5cd47f
      * when offline. */
5cd47f
     if (smart > 0) {
5cd47f
         ret = be_ptask_create(be_ctx, be_ctx, smart, delay + smart, smart, 0,
5cd47f
-                              smart, BE_PTASK_OFFLINE_DISABLE, 0,
5cd47f
+                              smart, BE_PTASK_OFFLINE_DISABLE,
5cd47f
+                              BE_PTASK_SCHEDULE_FROM_LAST,
5cd47f
+                              0,
5cd47f
                               smart_send_fn, smart_recv_fn, pvt,
5cd47f
                               "SUDO Smart Refresh", NULL);
5cd47f
         if (ret != EOK) {
5cd47f
diff --git a/src/tests/cmocka/test_be_ptask.c b/src/tests/cmocka/test_be_ptask.c
5cd47f
index ca80b5442..45c41ed58 100644
5cd47f
--- a/src/tests/cmocka/test_be_ptask.c
5cd47f
+++ b/src/tests/cmocka/test_be_ptask.c
5cd47f
@@ -306,7 +306,8 @@ void test_be_ptask_create_einval_be(void **state)
5cd47f
     errno_t ret;
5cd47f
 
5cd47f
     ret = be_ptask_create(test_ctx, NULL, PERIOD, 0, 0, 0, 0,
5cd47f
-                          BE_PTASK_OFFLINE_SKIP, 0, test_be_ptask_send,
5cd47f
+                          BE_PTASK_OFFLINE_SKIP, BE_PTASK_SCHEDULE_FROM_LAST,
5cd47f
+                          0, test_be_ptask_send,
5cd47f
                           test_be_ptask_recv, NULL, "Test ptask", &ptask);
5cd47f
     assert_int_equal(ret, EINVAL);
5cd47f
     assert_null(ptask);
5cd47f
@@ -319,7 +320,8 @@ void test_be_ptask_create_einval_period(void **state)
5cd47f
     errno_t ret;
5cd47f
 
5cd47f
     ret = be_ptask_create(test_ctx, test_ctx->be_ctx, 0, 0, 0, 0, 0,
5cd47f
-                          BE_PTASK_OFFLINE_SKIP, 0, test_be_ptask_send,
5cd47f
+                          BE_PTASK_OFFLINE_SKIP, BE_PTASK_SCHEDULE_FROM_LAST,
5cd47f
+                          0, test_be_ptask_send,
5cd47f
                           test_be_ptask_recv, NULL, "Test ptask", &ptask);
5cd47f
     assert_int_equal(ret, EINVAL);
5cd47f
     assert_null(ptask);
5cd47f
@@ -332,7 +334,8 @@ void test_be_ptask_create_einval_send(void **state)
5cd47f
     errno_t ret;
5cd47f
 
5cd47f
     ret = be_ptask_create(test_ctx, test_ctx->be_ctx, PERIOD, 0, 0, 0, 0,
5cd47f
-                          BE_PTASK_OFFLINE_SKIP, 0, NULL,
5cd47f
+                          BE_PTASK_OFFLINE_SKIP, BE_PTASK_SCHEDULE_FROM_LAST,
5cd47f
+                          0, NULL,
5cd47f
                           test_be_ptask_recv, NULL, "Test ptask", &ptask);
5cd47f
     assert_int_equal(ret, EINVAL);
5cd47f
     assert_null(ptask);
5cd47f
@@ -345,7 +348,8 @@ void test_be_ptask_create_einval_recv(void **state)
5cd47f
     errno_t ret;
5cd47f
 
5cd47f
     ret = be_ptask_create(test_ctx, test_ctx->be_ctx, PERIOD, 0, 0, 0, 0,
5cd47f
-                          BE_PTASK_OFFLINE_SKIP, 0, test_be_ptask_send,
5cd47f
+                          BE_PTASK_OFFLINE_SKIP, BE_PTASK_SCHEDULE_FROM_LAST,
5cd47f
+                          0, test_be_ptask_send,
5cd47f
                           NULL, NULL, "Test ptask", &ptask);
5cd47f
     assert_int_equal(ret, EINVAL);
5cd47f
     assert_null(ptask);
5cd47f
@@ -358,7 +362,8 @@ void test_be_ptask_create_einval_name(void **state)
5cd47f
     errno_t ret;
5cd47f
 
5cd47f
     ret = be_ptask_create(test_ctx, test_ctx->be_ctx, PERIOD, 0, 0, 0, 0,
5cd47f
-                          BE_PTASK_OFFLINE_SKIP, 0, test_be_ptask_send,
5cd47f
+                          BE_PTASK_OFFLINE_SKIP, BE_PTASK_SCHEDULE_FROM_LAST,
5cd47f
+                          0, test_be_ptask_send,
5cd47f
                           test_be_ptask_recv, NULL, NULL, &ptask);
5cd47f
     assert_int_equal(ret, EINVAL);
5cd47f
     assert_null(ptask);
5cd47f
@@ -373,7 +378,8 @@ void test_be_ptask_create_no_delay(void **state)
5cd47f
 
5cd47f
     now = get_current_time();
5cd47f
     ret = be_ptask_create(test_ctx, test_ctx->be_ctx, PERIOD, 0, 0, 0, 0,
5cd47f
-                          BE_PTASK_OFFLINE_SKIP, 0, test_be_ptask_send,
5cd47f
+                          BE_PTASK_OFFLINE_SKIP, BE_PTASK_SCHEDULE_FROM_LAST,
5cd47f
+                          0, test_be_ptask_send,
5cd47f
                           test_be_ptask_recv, test_ctx, "Test ptask", &ptask);
5cd47f
     assert_int_equal(ret, ERR_OK);
5cd47f
     assert_non_null(ptask);
5cd47f
@@ -400,7 +406,8 @@ void test_be_ptask_create_first_delay(void **state)
5cd47f
 
5cd47f
     now = get_current_time();
5cd47f
     ret = be_ptask_create(test_ctx, test_ctx->be_ctx, PERIOD, DELAY, 0, 0, 0,
5cd47f
-                          BE_PTASK_OFFLINE_SKIP, 0, test_be_ptask_send,
5cd47f
+                          BE_PTASK_OFFLINE_SKIP, BE_PTASK_SCHEDULE_FROM_LAST,
5cd47f
+                          0, test_be_ptask_send,
5cd47f
                           test_be_ptask_recv, test_ctx, "Test ptask", &ptask);
5cd47f
     assert_int_equal(ret, ERR_OK);
5cd47f
     assert_non_null(ptask);
5cd47f
@@ -425,7 +432,8 @@ void test_be_ptask_disable(void **state)
5cd47f
     errno_t ret;
5cd47f
 
5cd47f
     ret = be_ptask_create(test_ctx, test_ctx->be_ctx, PERIOD, 0, 0, 0, 0,
5cd47f
-                          BE_PTASK_OFFLINE_SKIP, 0, test_be_ptask_send,
5cd47f
+                          BE_PTASK_OFFLINE_SKIP, BE_PTASK_SCHEDULE_FROM_LAST,
5cd47f
+                          0, test_be_ptask_send,
5cd47f
                           test_be_ptask_recv, test_ctx, "Test ptask", &ptask);
5cd47f
     assert_int_equal(ret, ERR_OK);
5cd47f
     assert_non_null(ptask);
5cd47f
@@ -449,7 +457,8 @@ void test_be_ptask_enable(void **state)
5cd47f
 
5cd47f
     now = get_current_time();
5cd47f
     ret = be_ptask_create(test_ctx, test_ctx->be_ctx, PERIOD, 0, 0, 0, 0,
5cd47f
-                          BE_PTASK_OFFLINE_SKIP, 0, test_be_ptask_send,
5cd47f
+                          BE_PTASK_OFFLINE_SKIP, BE_PTASK_SCHEDULE_FROM_LAST,
5cd47f
+                          0, test_be_ptask_send,
5cd47f
                           test_be_ptask_recv, test_ctx, "Test ptask", &ptask);
5cd47f
     assert_int_equal(ret, ERR_OK);
5cd47f
     assert_non_null(ptask);
5cd47f
@@ -481,7 +490,8 @@ void test_be_ptask_enable_delay(void **state)
5cd47f
     errno_t ret;
5cd47f
 
5cd47f
     ret = be_ptask_create(test_ctx, test_ctx->be_ctx, PERIOD, 0, DELAY, 0, 0,
5cd47f
-                          BE_PTASK_OFFLINE_SKIP, 0, test_be_ptask_send,
5cd47f
+                          BE_PTASK_OFFLINE_SKIP, BE_PTASK_SCHEDULE_FROM_LAST,
5cd47f
+                          0, test_be_ptask_send,
5cd47f
                           test_be_ptask_recv, test_ctx, "Test ptask", &ptask);
5cd47f
     assert_int_equal(ret, ERR_OK);
5cd47f
     assert_non_null(ptask);
5cd47f
@@ -520,7 +530,8 @@ void test_be_ptask_offline_skip(void **state)
5cd47f
 
5cd47f
     now = get_current_time();
5cd47f
     ret = be_ptask_create(test_ctx, test_ctx->be_ctx, PERIOD, 0, 0, 0, 0,
5cd47f
-                          BE_PTASK_OFFLINE_SKIP, 0, test_be_ptask_send,
5cd47f
+                          BE_PTASK_OFFLINE_SKIP, BE_PTASK_SCHEDULE_FROM_LAST,
5cd47f
+                          0, test_be_ptask_send,
5cd47f
                           test_be_ptask_recv, test_ctx, "Test ptask", &ptask);
5cd47f
     assert_int_equal(ret, ERR_OK);
5cd47f
     assert_non_null(ptask);
5cd47f
@@ -553,7 +564,9 @@ void test_be_ptask_offline_disable(void **state)
5cd47f
     will_return(be_add_offline_cb, test_ctx);
5cd47f
 
5cd47f
     ret = be_ptask_create(test_ctx, test_ctx->be_ctx, PERIOD, 0, 0, 0, 0,
5cd47f
-                          BE_PTASK_OFFLINE_DISABLE, 0, test_be_ptask_send,
5cd47f
+                          BE_PTASK_OFFLINE_DISABLE,
5cd47f
+                          BE_PTASK_SCHEDULE_FROM_LAST,
5cd47f
+                          0, test_be_ptask_send,
5cd47f
                           test_be_ptask_recv, test_ctx, "Test ptask", &ptask);
5cd47f
     assert_int_equal(ret, ERR_OK);
5cd47f
     assert_non_null(ptask);
5cd47f
@@ -583,7 +596,9 @@ void test_be_ptask_offline_execute(void **state)
5cd47f
     mark_offline(test_ctx);
5cd47f
 
5cd47f
     ret = be_ptask_create(test_ctx, test_ctx->be_ctx, PERIOD, 0, 0, 0, 0,
5cd47f
-                          BE_PTASK_OFFLINE_EXECUTE, 0, test_be_ptask_send,
5cd47f
+                          BE_PTASK_OFFLINE_EXECUTE,
5cd47f
+                          BE_PTASK_SCHEDULE_FROM_LAST,
5cd47f
+                          0, test_be_ptask_send,
5cd47f
                           test_be_ptask_recv, test_ctx, "Test ptask", &ptask);
5cd47f
     assert_int_equal(ret, ERR_OK);
5cd47f
     assert_non_null(ptask);
5cd47f
@@ -610,7 +625,8 @@ void test_be_ptask_reschedule_ok(void **state)
5cd47f
 
5cd47f
     now = get_current_time();
5cd47f
     ret = be_ptask_create(test_ctx, test_ctx->be_ctx, PERIOD, 0, 0, 0, 0,
5cd47f
-                          BE_PTASK_OFFLINE_SKIP, 0, test_be_ptask_send,
5cd47f
+                          BE_PTASK_OFFLINE_SKIP, BE_PTASK_SCHEDULE_FROM_LAST,
5cd47f
+                          0, test_be_ptask_send,
5cd47f
                           test_be_ptask_recv, test_ctx, "Test ptask", &ptask);
5cd47f
     assert_int_equal(ret, ERR_OK);
5cd47f
     assert_non_null(ptask);
5cd47f
@@ -641,7 +657,8 @@ void test_be_ptask_reschedule_null(void **state)
5cd47f
     errno_t ret;
5cd47f
 
5cd47f
     ret = be_ptask_create(test_ctx, test_ctx->be_ctx, PERIOD, 0, 0, 0, 0,
5cd47f
-                          BE_PTASK_OFFLINE_SKIP, 0, test_be_ptask_null_send,
5cd47f
+                          BE_PTASK_OFFLINE_SKIP, BE_PTASK_SCHEDULE_FROM_LAST,
5cd47f
+                          0, test_be_ptask_null_send,
5cd47f
                           test_be_ptask_recv, test_ctx, "Test ptask",
5cd47f
                           &ptask);
5cd47f
     assert_int_equal(ret, ERR_OK);
5cd47f
@@ -668,7 +685,8 @@ void test_be_ptask_reschedule_error(void **state)
5cd47f
     errno_t ret;
5cd47f
 
5cd47f
     ret = be_ptask_create(test_ctx, test_ctx->be_ctx, PERIOD, 0, 0, 0, 0,
5cd47f
-                          BE_PTASK_OFFLINE_SKIP, 0, test_be_ptask_send,
5cd47f
+                          BE_PTASK_OFFLINE_SKIP, BE_PTASK_SCHEDULE_FROM_LAST,
5cd47f
+                          0, test_be_ptask_send,
5cd47f
                           test_be_ptask_error_recv, test_ctx, "Test ptask",
5cd47f
                           &ptask);
5cd47f
     assert_int_equal(ret, ERR_OK);
5cd47f
@@ -695,7 +713,8 @@ void test_be_ptask_reschedule_timeout(void **state)
5cd47f
     errno_t ret;
5cd47f
 
5cd47f
     ret = be_ptask_create(test_ctx, test_ctx->be_ctx, PERIOD, 0, 0, 0, 1,
5cd47f
-                          BE_PTASK_OFFLINE_SKIP, 0, test_be_ptask_timeout_send,
5cd47f
+                          BE_PTASK_OFFLINE_SKIP, BE_PTASK_SCHEDULE_FROM_LAST,
5cd47f
+                          0, test_be_ptask_timeout_send,
5cd47f
                           test_be_ptask_error_recv, test_ctx, "Test ptask",
5cd47f
                           &ptask);
5cd47f
     assert_int_equal(ret, ERR_OK);
5cd47f
@@ -732,7 +751,8 @@ void test_be_ptask_reschedule_backoff(void **state)
5cd47f
 
5cd47f
     now_first = get_current_time();
5cd47f
     ret = be_ptask_create(test_ctx, test_ctx->be_ctx, PERIOD, 0, 0, 0, 0,
5cd47f
-                          BE_PTASK_OFFLINE_SKIP, PERIOD*2, test_be_ptask_send,
5cd47f
+                          BE_PTASK_OFFLINE_SKIP, BE_PTASK_SCHEDULE_FROM_LAST,
5cd47f
+                          PERIOD*2, test_be_ptask_send,
5cd47f
                           test_be_ptask_recv, test_ctx, "Test ptask", &ptask);
5cd47f
     assert_int_equal(ret, ERR_OK);
5cd47f
     assert_non_null(ptask);
5cd47f
@@ -786,7 +806,8 @@ void test_be_ptask_get_period(void **state)
5cd47f
     errno_t ret;
5cd47f
 
5cd47f
     ret = be_ptask_create(test_ctx, test_ctx->be_ctx, PERIOD, 0, 0, 0, 0,
5cd47f
-                          BE_PTASK_OFFLINE_SKIP, 0, test_be_ptask_send,
5cd47f
+                          BE_PTASK_OFFLINE_SKIP, BE_PTASK_SCHEDULE_FROM_LAST,
5cd47f
+                          0, test_be_ptask_send,
5cd47f
                           test_be_ptask_recv, test_ctx, "Test ptask", &ptask);
5cd47f
     assert_int_equal(ret, ERR_OK);
5cd47f
     assert_non_null(ptask);
5cd47f
@@ -806,7 +827,8 @@ void test_be_ptask_get_timeout(void **state)
5cd47f
     errno_t ret;
5cd47f
 
5cd47f
     ret = be_ptask_create(test_ctx, test_ctx->be_ctx, PERIOD, 0, 0, 0, TIMEOUT,
5cd47f
-                          BE_PTASK_OFFLINE_SKIP, 0, test_be_ptask_send,
5cd47f
+                          BE_PTASK_OFFLINE_SKIP, BE_PTASK_SCHEDULE_FROM_LAST,
5cd47f
+                          0, test_be_ptask_send,
5cd47f
                           test_be_ptask_recv, test_ctx, "Test ptask", &ptask);
5cd47f
     assert_int_equal(ret, ERR_OK);
5cd47f
     assert_non_null(ptask);
5cd47f
-- 
5cd47f
2.20.1
5cd47f