dpward / rpms / sssd

Forked from rpms/sssd 3 years ago
Clone

Blame SOURCES/0046-BE-Introduce-flag-for-be_ptask_create.patch

d6181b
From c5a0909216c406ce3e23d6f41146daf2bb303226 Mon Sep 17 00:00:00 2001
d6181b
From: Tomas Halman <thalman@redhat.com>
d6181b
Date: Fri, 19 Jul 2019 13:05:44 +0200
d6181b
Subject: [PATCH 46/48] BE: Introduce flag for be_ptask_create
d6181b
MIME-Version: 1.0
d6181b
Content-Type: text/plain; charset=UTF-8
d6181b
Content-Transfer-Encoding: 8bit
d6181b
d6181b
The be_ptask_create has already too many parameters. Lets have flags
d6181b
parameter to avoid future extending.
d6181b
d6181b
Reviewed-by: Pavel Březina <pbrezina@redhat.com>
d6181b
---
d6181b
 src/providers/ad/ad_dyndns.c             |  2 +-
d6181b
 src/providers/ad/ad_machine_pw_renewal.c |  2 +-
d6181b
 src/providers/ad/ad_subdomains.c         |  2 +-
d6181b
 src/providers/be_ptask.c                 | 17 +++++-
d6181b
 src/providers/be_ptask.h                 | 10 ++++
d6181b
 src/providers/be_ptask_private.h         |  1 +
d6181b
 src/providers/be_refresh.c               |  2 +-
d6181b
 src/providers/data_provider_be.c         |  2 +-
d6181b
 src/providers/ipa/ipa_dyndns.c           |  2 +-
d6181b
 src/providers/ipa/ipa_subdomains.c       |  2 +-
d6181b
 src/providers/ldap/ldap_id_cleanup.c     |  2 +-
d6181b
 src/providers/ldap/ldap_id_enum.c        |  2 +-
d6181b
 src/providers/ldap/sdap_sudo_shared.c    |  4 +-
d6181b
 src/tests/cmocka/test_be_ptask.c         | 67 +++++++++++++++---------
d6181b
 14 files changed, 80 insertions(+), 37 deletions(-)
d6181b
d6181b
diff --git a/src/providers/ad/ad_dyndns.c b/src/providers/ad/ad_dyndns.c
d6181b
index 02ea7f24b..af765b581 100644
d6181b
--- a/src/providers/ad/ad_dyndns.c
d6181b
+++ b/src/providers/ad/ad_dyndns.c
d6181b
@@ -101,7 +101,7 @@ errno_t ad_dyndns_init(struct be_ctx *be_ctx,
d6181b
     ret = be_ptask_create(ad_opts, be_ctx, period, ptask_first_delay, 0, 0, period,
d6181b
                           BE_PTASK_OFFLINE_DISABLE, BE_PTASK_SCHEDULE_FROM_LAST, 0,
d6181b
                           ad_dyndns_update_send, ad_dyndns_update_recv, ad_opts,
d6181b
-                          "Dyndns update", NULL);
d6181b
+                          "Dyndns update", 0, NULL);
d6181b
 
d6181b
     if (ret != EOK) {
d6181b
         DEBUG(SSSDBG_CRIT_FAILURE, "Unable to setup ptask "
d6181b
diff --git a/src/providers/ad/ad_machine_pw_renewal.c b/src/providers/ad/ad_machine_pw_renewal.c
d6181b
index 47941dfbf..67802c04a 100644
d6181b
--- a/src/providers/ad/ad_machine_pw_renewal.c
d6181b
+++ b/src/providers/ad/ad_machine_pw_renewal.c
d6181b
@@ -388,7 +388,7 @@ errno_t ad_machine_account_password_renewal_init(struct be_ctx *be_ctx,
d6181b
                           ad_machine_account_password_renewal_send,
d6181b
                           ad_machine_account_password_renewal_recv,
d6181b
                           renewal_data,
d6181b
-                          "AD machine account password renewal", NULL);
d6181b
+                          "AD machine account password renewal", 0, NULL);
d6181b
     if (ret != EOK) {
d6181b
         DEBUG(SSSDBG_OP_FAILURE, "be_ptask_create failed.\n");
d6181b
         goto done;
d6181b
diff --git a/src/providers/ad/ad_subdomains.c b/src/providers/ad/ad_subdomains.c
d6181b
index 2510498da..0f46b46ad 100644
d6181b
--- a/src/providers/ad/ad_subdomains.c
d6181b
+++ b/src/providers/ad/ad_subdomains.c
d6181b
@@ -2070,7 +2070,7 @@ errno_t ad_subdomains_init(TALLOC_CTX *mem_ctx,
d6181b
                           BE_PTASK_SCHEDULE_FROM_LAST,
d6181b
                           0,
d6181b
                           ad_subdomains_ptask_send, ad_subdomains_ptask_recv, sd_ctx,
d6181b
-                          "Subdomains Refresh", NULL);
d6181b
+                          "Subdomains Refresh", 0, NULL);
d6181b
     if (ret != EOK) {
d6181b
         DEBUG(SSSDBG_CRIT_FAILURE, "Unable to setup ptask "
d6181b
               "[%d]: %s\n", ret, sss_strerror(ret));
d6181b
diff --git a/src/providers/be_ptask.c b/src/providers/be_ptask.c
d6181b
index 32d9a03ce..56c9c82fe 100644
d6181b
--- a/src/providers/be_ptask.c
d6181b
+++ b/src/providers/be_ptask.c
d6181b
@@ -208,6 +208,12 @@ static void be_ptask_schedule(struct be_ptask *task,
d6181b
         delay = task->enabled_delay;
d6181b
         break;
d6181b
     case BE_PTASK_PERIOD:
d6181b
+        if (task->flags & BE_PTASK_NO_PERIODIC) {
d6181b
+            /* Periodic task is disabled, */
d6181b
+            /* only online/offline change can cause some activity. */
d6181b
+            return;
d6181b
+        }
d6181b
+
d6181b
         delay = task->period;
d6181b
 
d6181b
         if (backoff_allowed(task) && task->period * 2 <= task->max_backoff) {
d6181b
@@ -269,16 +275,21 @@ errno_t be_ptask_create(TALLOC_CTX *mem_ctx,
d6181b
                         be_ptask_recv_t recv_fn,
d6181b
                         void *pvt,
d6181b
                         const char *name,
d6181b
+                        uint32_t flags,
d6181b
                         struct be_ptask **_task)
d6181b
 {
d6181b
     struct be_ptask *task = NULL;
d6181b
     errno_t ret;
d6181b
 
d6181b
-    if (be_ctx == NULL || period == 0 || send_fn == NULL || recv_fn == NULL
d6181b
+    if (be_ctx == NULL || send_fn == NULL || recv_fn == NULL
d6181b
         || name == NULL) {
d6181b
         return EINVAL;
d6181b
     }
d6181b
 
d6181b
+    if (period == 0 && (flags & BE_PTASK_NO_PERIODIC) == 0) {
d6181b
+        return EINVAL;
d6181b
+    }
d6181b
+
d6181b
     task = talloc_zero(mem_ctx, struct be_ptask);
d6181b
     if (task == NULL) {
d6181b
         ret = ENOMEM;
d6181b
@@ -306,6 +317,7 @@ errno_t be_ptask_create(TALLOC_CTX *mem_ctx,
d6181b
         goto done;
d6181b
     }
d6181b
 
d6181b
+    task->flags = flags;
d6181b
     task->enabled = true;
d6181b
 
d6181b
     talloc_set_destructor((TALLOC_CTX*)task, be_ptask_destructor);
d6181b
@@ -451,6 +463,7 @@ errno_t be_ptask_create_sync(TALLOC_CTX *mem_ctx,
d6181b
                              be_ptask_sync_t fn,
d6181b
                              void *pvt,
d6181b
                              const char *name,
d6181b
+                             uint32_t flags,
d6181b
                              struct be_ptask **_task)
d6181b
 {
d6181b
     errno_t ret;
d6181b
@@ -469,7 +482,7 @@ errno_t be_ptask_create_sync(TALLOC_CTX *mem_ctx,
d6181b
                           enabled_delay, random_offset, timeout, offline,
d6181b
                           BE_PTASK_SCHEDULE_FROM_LAST,
d6181b
                           max_backoff, be_ptask_sync_send, be_ptask_sync_recv,
d6181b
-                          ctx, name, _task);
d6181b
+                          ctx, name, flags, _task);
d6181b
     if (ret != EOK) {
d6181b
         goto done;
d6181b
     }
d6181b
diff --git a/src/providers/be_ptask.h b/src/providers/be_ptask.h
d6181b
index c23278e88..a33443965 100644
d6181b
--- a/src/providers/be_ptask.h
d6181b
+++ b/src/providers/be_ptask.h
d6181b
@@ -30,6 +30,14 @@ struct be_ctx;
d6181b
 
d6181b
 struct be_ptask;
d6181b
 
d6181b
+/* be_ptask flags */
d6181b
+
d6181b
+/**
d6181b
+ * Do not schedule periodic task. This flag is useful for tasks that
d6181b
+ * should be performend only when there is offline/online change.
d6181b
+ */
d6181b
+#define BE_PTASK_NO_PERIODIC         0x0001
d6181b
+
d6181b
 /**
d6181b
  * Defines how should task behave when back end is offline.
d6181b
  */
d6181b
@@ -127,6 +135,7 @@ errno_t be_ptask_create(TALLOC_CTX *mem_ctx,
d6181b
                         be_ptask_recv_t recv_fn,
d6181b
                         void *pvt,
d6181b
                         const char *name,
d6181b
+                        uint32_t flags,
d6181b
                         struct be_ptask **_task);
d6181b
 
d6181b
 errno_t be_ptask_create_sync(TALLOC_CTX *mem_ctx,
d6181b
@@ -141,6 +150,7 @@ errno_t be_ptask_create_sync(TALLOC_CTX *mem_ctx,
d6181b
                              be_ptask_sync_t fn,
d6181b
                              void *pvt,
d6181b
                              const char *name,
d6181b
+                             uint32_t flags,
d6181b
                              struct be_ptask **_task);
d6181b
 
d6181b
 void be_ptask_enable(struct be_ptask *task);
d6181b
diff --git a/src/providers/be_ptask_private.h b/src/providers/be_ptask_private.h
d6181b
index e89105f95..496a2f9ae 100644
d6181b
--- a/src/providers/be_ptask_private.h
d6181b
+++ b/src/providers/be_ptask_private.h
d6181b
@@ -43,6 +43,7 @@ struct be_ptask {
d6181b
     time_t last_execution;  /* last time when send was called */
d6181b
     struct tevent_req *req; /* active tevent request */
d6181b
     struct tevent_timer *timer; /* active tevent timer */
d6181b
+    uint32_t flags;
d6181b
     bool enabled;
d6181b
 };
d6181b
 
d6181b
diff --git a/src/providers/be_refresh.c b/src/providers/be_refresh.c
d6181b
index 8f50e231d..687d3f022 100644
d6181b
--- a/src/providers/be_refresh.c
d6181b
+++ b/src/providers/be_refresh.c
d6181b
@@ -177,7 +177,7 @@ static errno_t be_refresh_ctx_init(struct be_ctx *be_ctx,
d6181b
                               BE_PTASK_SCHEDULE_FROM_NOW,
d6181b
                               0,
d6181b
                               be_refresh_send, be_refresh_recv,
d6181b
-                              ctx, "Refresh Records", NULL);
d6181b
+                              ctx, "Refresh Records", 0, NULL);
d6181b
         if (ret != EOK) {
d6181b
             DEBUG(SSSDBG_FATAL_FAILURE,
d6181b
                   "Unable to initialize refresh periodic task [%d]: %s\n",
d6181b
diff --git a/src/providers/data_provider_be.c b/src/providers/data_provider_be.c
d6181b
index 877841055..f21669b8c 100644
d6181b
--- a/src/providers/data_provider_be.c
d6181b
+++ b/src/providers/data_provider_be.c
d6181b
@@ -133,7 +133,7 @@ void be_mark_offline(struct be_ctx *ctx)
d6181b
                                    BE_PTASK_OFFLINE_EXECUTE,
d6181b
                                    3600 /* max_backoff */,
d6181b
                                    try_to_go_online,
d6181b
-                                   ctx, "Check if online (periodic)",
d6181b
+                                   ctx, "Check if online (periodic)", 0,
d6181b
                                    &ctx->check_if_online_ptask);
d6181b
         if (ret != EOK) {
d6181b
             DEBUG(SSSDBG_FATAL_FAILURE,
d6181b
diff --git a/src/providers/ipa/ipa_dyndns.c b/src/providers/ipa/ipa_dyndns.c
d6181b
index 8e8ff5a4f..27852c2e2 100644
d6181b
--- a/src/providers/ipa/ipa_dyndns.c
d6181b
+++ b/src/providers/ipa/ipa_dyndns.c
d6181b
@@ -78,7 +78,7 @@ errno_t ipa_dyndns_init(struct be_ctx *be_ctx,
d6181b
                           BE_PTASK_SCHEDULE_FROM_LAST,
d6181b
                           0,
d6181b
                           ipa_dyndns_update_send, ipa_dyndns_update_recv, ctx,
d6181b
-                          "Dyndns update", NULL);
d6181b
+                          "Dyndns update", 0, NULL);
d6181b
     if (ret != EOK) {
d6181b
         DEBUG(SSSDBG_CRIT_FAILURE, "Unable to setup ptask "
d6181b
               "[%d]: %s\n", ret, sss_strerror(ret));
d6181b
diff --git a/src/providers/ipa/ipa_subdomains.c b/src/providers/ipa/ipa_subdomains.c
d6181b
index 3a17c851d..13e49c5c0 100644
d6181b
--- a/src/providers/ipa/ipa_subdomains.c
d6181b
+++ b/src/providers/ipa/ipa_subdomains.c
d6181b
@@ -3138,7 +3138,7 @@ errno_t ipa_subdomains_init(TALLOC_CTX *mem_ctx,
d6181b
                           BE_PTASK_SCHEDULE_FROM_LAST,
d6181b
                           0,
d6181b
                           ipa_subdomains_ptask_send, ipa_subdomains_ptask_recv, sd_ctx,
d6181b
-                          "Subdomains Refresh", NULL);
d6181b
+                          "Subdomains Refresh", 0, NULL);
d6181b
     if (ret != EOK) {
d6181b
         DEBUG(SSSDBG_CRIT_FAILURE, "Unable to setup ptask "
d6181b
               "[%d]: %s\n", ret, sss_strerror(ret));
d6181b
diff --git a/src/providers/ldap/ldap_id_cleanup.c b/src/providers/ldap/ldap_id_cleanup.c
d6181b
index e50fb0f22..df56f4da4 100644
d6181b
--- a/src/providers/ldap/ldap_id_cleanup.c
d6181b
+++ b/src/providers/ldap/ldap_id_cleanup.c
d6181b
@@ -88,7 +88,7 @@ errno_t ldap_setup_cleanup(struct sdap_id_ctx *id_ctx,
d6181b
     ret = be_ptask_create_sync(sdom, id_ctx->be, period, first_delay,
d6181b
                                5 /* enabled delay */, 0 /* random offset */,
d6181b
                                period /* timeout */, BE_PTASK_OFFLINE_SKIP, 0,
d6181b
-                               ldap_cleanup_task, cleanup_ctx, name,
d6181b
+                               ldap_cleanup_task, cleanup_ctx, name, 0,
d6181b
                                &sdom->cleanup_task);
d6181b
     if (ret != EOK) {
d6181b
         DEBUG(SSSDBG_FATAL_FAILURE, "Unable to initialize cleanup periodic "
d6181b
diff --git a/src/providers/ldap/ldap_id_enum.c b/src/providers/ldap/ldap_id_enum.c
d6181b
index 062185c55..2137f6821 100644
d6181b
--- a/src/providers/ldap/ldap_id_enum.c
d6181b
+++ b/src/providers/ldap/ldap_id_enum.c
d6181b
@@ -102,7 +102,7 @@ errno_t ldap_setup_enumeration(struct be_ctx *be_ctx,
d6181b
                           BE_PTASK_SCHEDULE_FROM_LAST,
d6181b
                           0,                        /* max_backoff */
d6181b
                           send_fn, recv_fn,
d6181b
-                          ectx, "enumeration", &sdom->enum_task);
d6181b
+                          ectx, "enumeration", 0, &sdom->enum_task);
d6181b
     if (ret != EOK) {
d6181b
         DEBUG(SSSDBG_FATAL_FAILURE,
d6181b
               "Unable to initialize enumeration periodic task\n");
d6181b
diff --git a/src/providers/ldap/sdap_sudo_shared.c b/src/providers/ldap/sdap_sudo_shared.c
d6181b
index a00d8e6a9..59356bd44 100644
d6181b
--- a/src/providers/ldap/sdap_sudo_shared.c
d6181b
+++ b/src/providers/ldap/sdap_sudo_shared.c
d6181b
@@ -94,7 +94,7 @@ sdap_sudo_ptask_setup_generic(struct be_ctx *be_ctx,
d6181b
                               BE_PTASK_SCHEDULE_FROM_LAST,
d6181b
                               0,
d6181b
                               full_send_fn, full_recv_fn, pvt,
d6181b
-                              "SUDO Full Refresh", NULL);
d6181b
+                              "SUDO Full Refresh", 0, NULL);
d6181b
         if (ret != EOK) {
d6181b
             DEBUG(SSSDBG_CRIT_FAILURE, "Unable to setup full refresh ptask "
d6181b
                   "[%d]: %s\n", ret, sss_strerror(ret));
d6181b
@@ -113,7 +113,7 @@ sdap_sudo_ptask_setup_generic(struct be_ctx *be_ctx,
d6181b
                               BE_PTASK_SCHEDULE_FROM_LAST,
d6181b
                               0,
d6181b
                               smart_send_fn, smart_recv_fn, pvt,
d6181b
-                              "SUDO Smart Refresh", NULL);
d6181b
+                              "SUDO Smart Refresh", 0, NULL);
d6181b
         if (ret != EOK) {
d6181b
             DEBUG(SSSDBG_CRIT_FAILURE, "Unable to setup smart refresh ptask "
d6181b
                   "[%d]: %s\n", ret, sss_strerror(ret));
d6181b
diff --git a/src/tests/cmocka/test_be_ptask.c b/src/tests/cmocka/test_be_ptask.c
d6181b
index 03b1165bb..ac8c0767f 100644
d6181b
--- a/src/tests/cmocka/test_be_ptask.c
d6181b
+++ b/src/tests/cmocka/test_be_ptask.c
d6181b
@@ -306,7 +306,7 @@ void test_be_ptask_create_einval_be(void **state)
d6181b
     ret = be_ptask_create(test_ctx, NULL, PERIOD, 0, 0, 0, 0,
d6181b
                           BE_PTASK_OFFLINE_SKIP, BE_PTASK_SCHEDULE_FROM_LAST,
d6181b
                           0, test_be_ptask_send,
d6181b
-                          test_be_ptask_recv, NULL, "Test ptask", &ptask);
d6181b
+                          test_be_ptask_recv, NULL, "Test ptask", 0, &ptask);
d6181b
     assert_int_equal(ret, EINVAL);
d6181b
     assert_null(ptask);
d6181b
 }
d6181b
@@ -320,7 +320,7 @@ void test_be_ptask_create_einval_period(void **state)
d6181b
     ret = be_ptask_create(test_ctx, test_ctx->be_ctx, 0, 0, 0, 0, 0,
d6181b
                           BE_PTASK_OFFLINE_SKIP, BE_PTASK_SCHEDULE_FROM_LAST,
d6181b
                           0, test_be_ptask_send,
d6181b
-                          test_be_ptask_recv, NULL, "Test ptask", &ptask);
d6181b
+                          test_be_ptask_recv, NULL, "Test ptask", 0, &ptask);
d6181b
     assert_int_equal(ret, EINVAL);
d6181b
     assert_null(ptask);
d6181b
 }
d6181b
@@ -334,7 +334,7 @@ void test_be_ptask_create_einval_send(void **state)
d6181b
     ret = be_ptask_create(test_ctx, test_ctx->be_ctx, PERIOD, 0, 0, 0, 0,
d6181b
                           BE_PTASK_OFFLINE_SKIP, BE_PTASK_SCHEDULE_FROM_LAST,
d6181b
                           0, NULL,
d6181b
-                          test_be_ptask_recv, NULL, "Test ptask", &ptask);
d6181b
+                          test_be_ptask_recv, NULL, "Test ptask", 0, &ptask);
d6181b
     assert_int_equal(ret, EINVAL);
d6181b
     assert_null(ptask);
d6181b
 }
d6181b
@@ -348,7 +348,7 @@ void test_be_ptask_create_einval_recv(void **state)
d6181b
     ret = be_ptask_create(test_ctx, test_ctx->be_ctx, PERIOD, 0, 0, 0, 0,
d6181b
                           BE_PTASK_OFFLINE_SKIP, BE_PTASK_SCHEDULE_FROM_LAST,
d6181b
                           0, test_be_ptask_send,
d6181b
-                          NULL, NULL, "Test ptask", &ptask);
d6181b
+                          NULL, NULL, "Test ptask", 0, &ptask);
d6181b
     assert_int_equal(ret, EINVAL);
d6181b
     assert_null(ptask);
d6181b
 }
d6181b
@@ -362,7 +362,7 @@ void test_be_ptask_create_einval_name(void **state)
d6181b
     ret = be_ptask_create(test_ctx, test_ctx->be_ctx, PERIOD, 0, 0, 0, 0,
d6181b
                           BE_PTASK_OFFLINE_SKIP, BE_PTASK_SCHEDULE_FROM_LAST,
d6181b
                           0, test_be_ptask_send,
d6181b
-                          test_be_ptask_recv, NULL, NULL, &ptask);
d6181b
+                          test_be_ptask_recv, NULL, NULL, 0, &ptask);
d6181b
     assert_int_equal(ret, EINVAL);
d6181b
     assert_null(ptask);
d6181b
 }
d6181b
@@ -378,7 +378,7 @@ void test_be_ptask_create_no_delay(void **state)
d6181b
     ret = be_ptask_create(test_ctx, test_ctx->be_ctx, PERIOD, 0, 0, 0, 0,
d6181b
                           BE_PTASK_OFFLINE_SKIP, BE_PTASK_SCHEDULE_FROM_LAST,
d6181b
                           0, test_be_ptask_send,
d6181b
-                          test_be_ptask_recv, test_ctx, "Test ptask", &ptask);
d6181b
+                          test_be_ptask_recv, test_ctx, "Test ptask", 0, &ptask);
d6181b
     assert_int_equal(ret, ERR_OK);
d6181b
     assert_non_null(ptask);
d6181b
     assert_non_null(ptask->timer);
d6181b
@@ -406,7 +406,7 @@ void test_be_ptask_create_first_delay(void **state)
d6181b
     ret = be_ptask_create(test_ctx, test_ctx->be_ctx, PERIOD, DELAY, 0, 0, 0,
d6181b
                           BE_PTASK_OFFLINE_SKIP, BE_PTASK_SCHEDULE_FROM_LAST,
d6181b
                           0, test_be_ptask_send,
d6181b
-                          test_be_ptask_recv, test_ctx, "Test ptask", &ptask);
d6181b
+                          test_be_ptask_recv, test_ctx, "Test ptask", 0, &ptask);
d6181b
     assert_int_equal(ret, ERR_OK);
d6181b
     assert_non_null(ptask);
d6181b
     assert_non_null(ptask->timer);
d6181b
@@ -432,7 +432,7 @@ void test_be_ptask_disable(void **state)
d6181b
     ret = be_ptask_create(test_ctx, test_ctx->be_ctx, PERIOD, 0, 0, 0, 0,
d6181b
                           BE_PTASK_OFFLINE_SKIP, BE_PTASK_SCHEDULE_FROM_LAST,
d6181b
                           0, test_be_ptask_send,
d6181b
-                          test_be_ptask_recv, test_ctx, "Test ptask", &ptask);
d6181b
+                          test_be_ptask_recv, test_ctx, "Test ptask", 0, &ptask);
d6181b
     assert_int_equal(ret, ERR_OK);
d6181b
     assert_non_null(ptask);
d6181b
     assert_non_null(ptask->timer);
d6181b
@@ -457,7 +457,7 @@ void test_be_ptask_enable(void **state)
d6181b
     ret = be_ptask_create(test_ctx, test_ctx->be_ctx, PERIOD, 0, 0, 0, 0,
d6181b
                           BE_PTASK_OFFLINE_SKIP, BE_PTASK_SCHEDULE_FROM_LAST,
d6181b
                           0, test_be_ptask_send,
d6181b
-                          test_be_ptask_recv, test_ctx, "Test ptask", &ptask);
d6181b
+                          test_be_ptask_recv, test_ctx, "Test ptask", 0, &ptask);
d6181b
     assert_int_equal(ret, ERR_OK);
d6181b
     assert_non_null(ptask);
d6181b
     assert_non_null(ptask->timer);
d6181b
@@ -490,7 +490,7 @@ void test_be_ptask_enable_delay(void **state)
d6181b
     ret = be_ptask_create(test_ctx, test_ctx->be_ctx, PERIOD, 0, DELAY, 0, 0,
d6181b
                           BE_PTASK_OFFLINE_SKIP, BE_PTASK_SCHEDULE_FROM_LAST,
d6181b
                           0, test_be_ptask_send,
d6181b
-                          test_be_ptask_recv, test_ctx, "Test ptask", &ptask);
d6181b
+                          test_be_ptask_recv, test_ctx, "Test ptask", 0, &ptask);
d6181b
     assert_int_equal(ret, ERR_OK);
d6181b
     assert_non_null(ptask);
d6181b
     assert_non_null(ptask->timer);
d6181b
@@ -530,7 +530,7 @@ void test_be_ptask_offline_skip(void **state)
d6181b
     ret = be_ptask_create(test_ctx, test_ctx->be_ctx, PERIOD, 0, 0, 0, 0,
d6181b
                           BE_PTASK_OFFLINE_SKIP, BE_PTASK_SCHEDULE_FROM_LAST,
d6181b
                           0, test_be_ptask_send,
d6181b
-                          test_be_ptask_recv, test_ctx, "Test ptask", &ptask);
d6181b
+                          test_be_ptask_recv, test_ctx, "Test ptask", 0, &ptask);
d6181b
     assert_int_equal(ret, ERR_OK);
d6181b
     assert_non_null(ptask);
d6181b
     assert_non_null(ptask->timer);
d6181b
@@ -565,7 +565,7 @@ void test_be_ptask_offline_disable(void **state)
d6181b
                           BE_PTASK_OFFLINE_DISABLE,
d6181b
                           BE_PTASK_SCHEDULE_FROM_LAST,
d6181b
                           0, test_be_ptask_send,
d6181b
-                          test_be_ptask_recv, test_ctx, "Test ptask", &ptask);
d6181b
+                          test_be_ptask_recv, test_ctx, "Test ptask", 0, &ptask);
d6181b
     assert_int_equal(ret, ERR_OK);
d6181b
     assert_non_null(ptask);
d6181b
     assert_non_null(ptask->timer);
d6181b
@@ -597,7 +597,7 @@ void test_be_ptask_offline_execute(void **state)
d6181b
                           BE_PTASK_OFFLINE_EXECUTE,
d6181b
                           BE_PTASK_SCHEDULE_FROM_LAST,
d6181b
                           0, test_be_ptask_send,
d6181b
-                          test_be_ptask_recv, test_ctx, "Test ptask", &ptask);
d6181b
+                          test_be_ptask_recv, test_ctx, "Test ptask", 0, &ptask);
d6181b
     assert_int_equal(ret, ERR_OK);
d6181b
     assert_non_null(ptask);
d6181b
     assert_non_null(ptask->timer);
d6181b
@@ -625,7 +625,7 @@ void test_be_ptask_reschedule_ok(void **state)
d6181b
     ret = be_ptask_create(test_ctx, test_ctx->be_ctx, PERIOD, 0, 0, 0, 0,
d6181b
                           BE_PTASK_OFFLINE_SKIP, BE_PTASK_SCHEDULE_FROM_LAST,
d6181b
                           0, test_be_ptask_send,
d6181b
-                          test_be_ptask_recv, test_ctx, "Test ptask", &ptask);
d6181b
+                          test_be_ptask_recv, test_ctx, "Test ptask", 0, &ptask);
d6181b
     assert_int_equal(ret, ERR_OK);
d6181b
     assert_non_null(ptask);
d6181b
     assert_non_null(ptask->timer);
d6181b
@@ -657,7 +657,7 @@ void test_be_ptask_reschedule_null(void **state)
d6181b
     ret = be_ptask_create(test_ctx, test_ctx->be_ctx, PERIOD, 0, 0, 0, 0,
d6181b
                           BE_PTASK_OFFLINE_SKIP, BE_PTASK_SCHEDULE_FROM_LAST,
d6181b
                           0, test_be_ptask_null_send,
d6181b
-                          test_be_ptask_recv, test_ctx, "Test ptask",
d6181b
+                          test_be_ptask_recv, test_ctx, "Test ptask", 0,
d6181b
                           &ptask);
d6181b
     assert_int_equal(ret, ERR_OK);
d6181b
     assert_non_null(ptask);
d6181b
@@ -685,7 +685,7 @@ void test_be_ptask_reschedule_error(void **state)
d6181b
     ret = be_ptask_create(test_ctx, test_ctx->be_ctx, PERIOD, 0, 0, 0, 0,
d6181b
                           BE_PTASK_OFFLINE_SKIP, BE_PTASK_SCHEDULE_FROM_LAST,
d6181b
                           0, test_be_ptask_send,
d6181b
-                          test_be_ptask_error_recv, test_ctx, "Test ptask",
d6181b
+                          test_be_ptask_error_recv, test_ctx, "Test ptask", 0,
d6181b
                           &ptask);
d6181b
     assert_int_equal(ret, ERR_OK);
d6181b
     assert_non_null(ptask);
d6181b
@@ -713,7 +713,7 @@ void test_be_ptask_reschedule_timeout(void **state)
d6181b
     ret = be_ptask_create(test_ctx, test_ctx->be_ctx, PERIOD, 0, 0, 0, 1,
d6181b
                           BE_PTASK_OFFLINE_SKIP, BE_PTASK_SCHEDULE_FROM_LAST,
d6181b
                           0, test_be_ptask_timeout_send,
d6181b
-                          test_be_ptask_error_recv, test_ctx, "Test ptask",
d6181b
+                          test_be_ptask_error_recv, test_ctx, "Test ptask", 0,
d6181b
                           &ptask);
d6181b
     assert_int_equal(ret, ERR_OK);
d6181b
     assert_non_null(ptask);
d6181b
@@ -751,7 +751,7 @@ void test_be_ptask_reschedule_backoff(void **state)
d6181b
     ret = be_ptask_create(test_ctx, test_ctx->be_ctx, PERIOD, 0, 0, 0, 0,
d6181b
                           BE_PTASK_OFFLINE_SKIP, BE_PTASK_SCHEDULE_FROM_LAST,
d6181b
                           PERIOD*2, test_be_ptask_send,
d6181b
-                          test_be_ptask_recv, test_ctx, "Test ptask", &ptask);
d6181b
+                          test_be_ptask_recv, test_ctx, "Test ptask", 0, &ptask);
d6181b
     assert_int_equal(ret, ERR_OK);
d6181b
     assert_non_null(ptask);
d6181b
     assert_non_null(ptask->timer);
d6181b
@@ -806,7 +806,7 @@ void test_be_ptask_get_period(void **state)
d6181b
     ret = be_ptask_create(test_ctx, test_ctx->be_ctx, PERIOD, 0, 0, 0, 0,
d6181b
                           BE_PTASK_OFFLINE_SKIP, BE_PTASK_SCHEDULE_FROM_LAST,
d6181b
                           0, test_be_ptask_send,
d6181b
-                          test_be_ptask_recv, test_ctx, "Test ptask", &ptask);
d6181b
+                          test_be_ptask_recv, test_ctx, "Test ptask", 0, &ptask);
d6181b
     assert_int_equal(ret, ERR_OK);
d6181b
     assert_non_null(ptask);
d6181b
 
d6181b
@@ -827,7 +827,7 @@ void test_be_ptask_get_timeout(void **state)
d6181b
     ret = be_ptask_create(test_ctx, test_ctx->be_ctx, PERIOD, 0, 0, 0, TIMEOUT,
d6181b
                           BE_PTASK_OFFLINE_SKIP, BE_PTASK_SCHEDULE_FROM_LAST,
d6181b
                           0, test_be_ptask_send,
d6181b
-                          test_be_ptask_recv, test_ctx, "Test ptask", &ptask);
d6181b
+                          test_be_ptask_recv, test_ctx, "Test ptask", 0, &ptask);
d6181b
     assert_int_equal(ret, ERR_OK);
d6181b
     assert_non_null(ptask);
d6181b
 
d6181b
@@ -838,6 +838,24 @@ void test_be_ptask_get_timeout(void **state)
d6181b
     assert_null(ptask);
d6181b
 }
d6181b
 
d6181b
+void test_be_ptask_no_periodic(void **state)
d6181b
+{
d6181b
+    struct test_ctx *test_ctx = (struct test_ctx *)(*state);
d6181b
+    struct be_ptask *ptask = NULL;
d6181b
+    errno_t ret;
d6181b
+
d6181b
+    ret = be_ptask_create(test_ctx, test_ctx->be_ctx, 0, 0, DELAY, 0, 0,
d6181b
+                          BE_PTASK_OFFLINE_SKIP, BE_PTASK_SCHEDULE_FROM_LAST,
d6181b
+                          0, test_be_ptask_send,
d6181b
+                          test_be_ptask_recv, test_ctx, "Test ptask",
d6181b
+                          BE_PTASK_NO_PERIODIC, &ptask);
d6181b
+    assert_int_equal(ret, ERR_OK);
d6181b
+    assert_non_null(ptask);
d6181b
+
d6181b
+    be_ptask_destroy(&ptask);
d6181b
+    assert_null(ptask);
d6181b
+}
d6181b
+
d6181b
 void test_be_ptask_create_sync(void **state)
d6181b
 {
d6181b
     struct test_ctx *test_ctx = (struct test_ctx *)(*state);
d6181b
@@ -848,7 +866,7 @@ void test_be_ptask_create_sync(void **state)
d6181b
     now = get_current_time();
d6181b
     ret = be_ptask_create_sync(test_ctx, test_ctx->be_ctx, PERIOD, 0, 0, 0, 0,
d6181b
                                BE_PTASK_OFFLINE_SKIP, 0, test_be_ptask_sync,
d6181b
-                               test_ctx, "Test ptask", &ptask);
d6181b
+                               test_ctx, "Test ptask", 0, &ptask);
d6181b
     assert_int_equal(ret, ERR_OK);
d6181b
     assert_non_null(ptask);
d6181b
     assert_non_null(ptask->timer);
d6181b
@@ -876,7 +894,7 @@ void test_be_ptask_sync_reschedule_ok(void **state)
d6181b
     now = get_current_time();
d6181b
     ret = be_ptask_create_sync(test_ctx, test_ctx->be_ctx, PERIOD, 0, 0, 0, 0,
d6181b
                                BE_PTASK_OFFLINE_SKIP, 0, test_be_ptask_sync,
d6181b
-                               test_ctx, "Test ptask", &ptask);
d6181b
+                               test_ctx, "Test ptask", 0, &ptask);
d6181b
     assert_int_equal(ret, ERR_OK);
d6181b
     assert_non_null(ptask);
d6181b
     assert_non_null(ptask->timer);
d6181b
@@ -908,7 +926,7 @@ void test_be_ptask_sync_reschedule_error(void **state)
d6181b
     ret = be_ptask_create_sync(test_ctx, test_ctx->be_ctx, PERIOD, 0, 0, 0, 0,
d6181b
                                BE_PTASK_OFFLINE_SKIP, 0,
d6181b
                                test_be_ptask_sync_error,
d6181b
-                               test_ctx, "Test ptask", &ptask);
d6181b
+                               test_ctx, "Test ptask", 0, &ptask);
d6181b
     assert_int_equal(ret, ERR_OK);
d6181b
     assert_non_null(ptask);
d6181b
     assert_non_null(ptask->timer);
d6181b
@@ -938,7 +956,7 @@ void test_be_ptask_sync_reschedule_backoff(void **state)
d6181b
     ret = be_ptask_create_sync(test_ctx, test_ctx->be_ctx, PERIOD, 0, 0, 0, 0,
d6181b
                                BE_PTASK_OFFLINE_SKIP, PERIOD*2,
d6181b
                                test_be_ptask_sync_error,
d6181b
-                               test_ctx, "Test ptask", &ptask);
d6181b
+                               test_ctx, "Test ptask", 0, &ptask);
d6181b
     assert_int_equal(ret, ERR_OK);
d6181b
     assert_non_null(ptask);
d6181b
     assert_non_null(ptask->timer);
d6181b
@@ -1014,6 +1032,7 @@ int main(int argc, const char *argv[])
d6181b
         new_test(be_ptask_reschedule_backoff),
d6181b
         new_test(be_ptask_get_period),
d6181b
         new_test(be_ptask_get_timeout),
d6181b
+        new_test(be_ptask_no_periodic),
d6181b
         new_test(be_ptask_create_sync),
d6181b
         new_test(be_ptask_sync_reschedule_ok),
d6181b
         new_test(be_ptask_sync_reschedule_error),
d6181b
-- 
d6181b
2.20.1
d6181b