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

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