dpward / rpms / sssd

Forked from rpms/sssd 3 years ago
Clone

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

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