dpward / rpms / sssd

Forked from rpms/sssd 3 years ago
Clone

Blame SOURCES/0047-BE-Convert-be_ptask-params-to-flags.patch

d6181b
From f5ef6aa9965fec34c8de9fe2635b0e5c5b8a0ab9 Mon Sep 17 00:00:00 2001
d6181b
From: Tomas Halman <thalman@redhat.com>
d6181b
Date: Fri, 19 Jul 2019 15:59:32 +0200
d6181b
Subject: [PATCH 47/48] BE: Convert be_ptask params to flags
d6181b
MIME-Version: 1.0
d6181b
Content-Type: text/plain; charset=UTF-8
d6181b
Content-Transfer-Encoding: 8bit
d6181b
d6181b
The be_ptask_create call has a lot of parameters.
d6181b
Some of them can be converted to flags to simplify
d6181b
the declaration.
d6181b
d6181b
Reviewed-by: Pavel Březina <pbrezina@redhat.com>
d6181b
---
d6181b
 src/providers/ad/ad_dyndns.c             |   9 +-
d6181b
 src/providers/ad/ad_machine_pw_renewal.c |  10 +-
d6181b
 src/providers/ad/ad_subdomains.c         |  11 +-
d6181b
 src/providers/be_ptask.c                 |  74 ++++++---
d6181b
 src/providers/be_ptask.h                 |  39 ++---
d6181b
 src/providers/be_ptask_private.h         |   2 -
d6181b
 src/providers/be_refresh.c               |   9 +-
d6181b
 src/providers/data_provider_be.c         |   4 +-
d6181b
 src/providers/ipa/ipa_dyndns.c           |   7 +-
d6181b
 src/providers/ipa/ipa_subdomains.c       |   7 +-
d6181b
 src/providers/ldap/ldap_id_cleanup.c     |   5 +-
d6181b
 src/providers/ldap/ldap_id_enum.c        |   6 +-
d6181b
 src/providers/ldap/sdap_sudo_shared.c    |  16 +-
d6181b
 src/tests/cmocka/test_be_ptask.c         | 194 ++++++++++++++++-------
d6181b
 14 files changed, 251 insertions(+), 142 deletions(-)
d6181b
d6181b
diff --git a/src/providers/ad/ad_dyndns.c b/src/providers/ad/ad_dyndns.c
d6181b
index af765b581..c9763d449 100644
d6181b
--- a/src/providers/ad/ad_dyndns.c
d6181b
+++ b/src/providers/ad/ad_dyndns.c
d6181b
@@ -98,10 +98,13 @@ errno_t ad_dyndns_init(struct be_ctx *be_ctx,
d6181b
         return EINVAL;
d6181b
     }
d6181b
 
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
+    ret = be_ptask_create(ad_opts, be_ctx, period, ptask_first_delay, 0, 0,
d6181b
+                          period, 0,
d6181b
                           ad_dyndns_update_send, ad_dyndns_update_recv, ad_opts,
d6181b
-                          "Dyndns update", 0, NULL);
d6181b
+                          "Dyndns update",
d6181b
+                          BE_PTASK_OFFLINE_DISABLE |
d6181b
+                          BE_PTASK_SCHEDULE_FROM_LAST,
d6181b
+                          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 67802c04a..9dc36247a 100644
d6181b
--- a/src/providers/ad/ad_machine_pw_renewal.c
d6181b
+++ b/src/providers/ad/ad_machine_pw_renewal.c
d6181b
@@ -381,14 +381,14 @@ errno_t ad_machine_account_password_renewal_init(struct be_ctx *be_ctx,
d6181b
         goto done;
d6181b
     }
d6181b
 
d6181b
-    ret = be_ptask_create(be_ctx, be_ctx, period, initial_delay, 0, 0, 60,
d6181b
-                          BE_PTASK_OFFLINE_DISABLE,
d6181b
-                          BE_PTASK_SCHEDULE_FROM_LAST,
d6181b
-                          0,
d6181b
+    ret = be_ptask_create(be_ctx, be_ctx, period, initial_delay, 0, 0, 60, 0,
d6181b
                           ad_machine_account_password_renewal_send,
d6181b
                           ad_machine_account_password_renewal_recv,
d6181b
                           renewal_data,
d6181b
-                          "AD machine account password renewal", 0, NULL);
d6181b
+                          "AD machine account password renewal",
d6181b
+                          BE_PTASK_OFFLINE_DISABLE |
d6181b
+                          BE_PTASK_SCHEDULE_FROM_LAST,
d6181b
+                          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 0f46b46ad..d934e70d6 100644
d6181b
--- a/src/providers/ad/ad_subdomains.c
d6181b
+++ b/src/providers/ad/ad_subdomains.c
d6181b
@@ -2065,12 +2065,13 @@ errno_t ad_subdomains_init(TALLOC_CTX *mem_ctx,
d6181b
                   struct ad_subdomains_ctx, struct dp_subdomains_data, struct dp_reply_std);
d6181b
 
d6181b
     period = be_ctx->domain->subdomain_refresh_interval;
d6181b
-    ret = be_ptask_create(sd_ctx, be_ctx, period, 0, 0, 0, period,
d6181b
-                          BE_PTASK_OFFLINE_DISABLE,
d6181b
+    ret = be_ptask_create(sd_ctx, be_ctx, period, 0, 0, 0, period, 0,
d6181b
+                          ad_subdomains_ptask_send, ad_subdomains_ptask_recv,
d6181b
+                          sd_ctx,
d6181b
+                          "Subdomains Refresh",
d6181b
+                          BE_PTASK_OFFLINE_DISABLE |
d6181b
                           BE_PTASK_SCHEDULE_FROM_LAST,
d6181b
-                          0,
d6181b
-                          ad_subdomains_ptask_send, ad_subdomains_ptask_recv, sd_ctx,
d6181b
-                          "Subdomains Refresh", 0, NULL);
d6181b
+                          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 56c9c82fe..9a432c948 100644
d6181b
--- a/src/providers/be_ptask.c
d6181b
+++ b/src/providers/be_ptask.c
d6181b
@@ -38,7 +38,7 @@ enum be_ptask_delay {
d6181b
 
d6181b
 static void be_ptask_schedule(struct be_ptask *task,
d6181b
                               enum be_ptask_delay delay_type,
d6181b
-                              enum be_ptask_schedule from);
d6181b
+                              uint32_t from);
d6181b
 
d6181b
 static int be_ptask_destructor(void *pvt)
d6181b
 {
d6181b
@@ -107,21 +107,20 @@ static void be_ptask_execute(struct tevent_context *ev,
d6181b
 
d6181b
     if (be_is_offline(task->be_ctx)) {
d6181b
         DEBUG(SSSDBG_TRACE_FUNC, "Back end is offline\n");
d6181b
-        switch (task->offline) {
d6181b
-        case BE_PTASK_OFFLINE_SKIP:
d6181b
+        if (task->flags & BE_PTASK_OFFLINE_SKIP) {
d6181b
             be_ptask_schedule(task, BE_PTASK_PERIOD,
d6181b
                               BE_PTASK_SCHEDULE_FROM_NOW);
d6181b
             return;
d6181b
-        case BE_PTASK_OFFLINE_DISABLE:
d6181b
+        }
d6181b
+        else if(task->flags & BE_PTASK_OFFLINE_DISABLE) {
d6181b
             /* This case is normally handled by offline callback but we
d6181b
              * should handle it here as well since we can get here in some
d6181b
              * special cases for example unit tests or tevent events order. */
d6181b
             be_ptask_disable(task);
d6181b
             return;
d6181b
-        case BE_PTASK_OFFLINE_EXECUTE:
d6181b
-            /* continue */
d6181b
-            break;
d6181b
         }
d6181b
+        /* BE_PTASK_OFFLINE_EXECUTE */
d6181b
+        /* continue */
d6181b
     }
d6181b
 
d6181b
     DEBUG(SSSDBG_TRACE_FUNC, "Task [%s]: executing task, timeout %lu "
d6181b
@@ -177,7 +176,7 @@ static void be_ptask_done(struct tevent_req *req)
d6181b
         DEBUG(SSSDBG_TRACE_FUNC, "Task [%s]: finished successfully\n",
d6181b
                                   task->name);
d6181b
 
d6181b
-        be_ptask_schedule(task, BE_PTASK_PERIOD, task->success_schedule_type);
d6181b
+        be_ptask_schedule(task, BE_PTASK_PERIOD, task->flags);
d6181b
         break;
d6181b
     default:
d6181b
         DEBUG(SSSDBG_OP_FAILURE, "Task [%s]: failed with [%d]: %s\n",
d6181b
@@ -190,7 +189,7 @@ static void be_ptask_done(struct tevent_req *req)
d6181b
 
d6181b
 static void be_ptask_schedule(struct be_ptask *task,
d6181b
                               enum be_ptask_delay delay_type,
d6181b
-                              enum be_ptask_schedule from)
d6181b
+                              uint32_t from)
d6181b
 {
d6181b
     struct timeval tv = { 0, };
d6181b
     time_t delay = 0;
d6181b
@@ -228,20 +227,18 @@ static void be_ptask_schedule(struct be_ptask *task,
d6181b
         delay = delay + (rand_r(&task->ro_seed) % task->random_offset);
d6181b
     }
d6181b
 
d6181b
-    switch (from) {
d6181b
-    case BE_PTASK_SCHEDULE_FROM_NOW:
d6181b
+    if(from | BE_PTASK_SCHEDULE_FROM_NOW) {
d6181b
         tv = tevent_timeval_current_ofs(delay, 0);
d6181b
 
d6181b
         DEBUG(SSSDBG_TRACE_FUNC, "Task [%s]: scheduling task %lu seconds "
d6181b
               "from now [%lu]\n", task->name, delay, tv.tv_sec);
d6181b
-        break;
d6181b
-    case BE_PTASK_SCHEDULE_FROM_LAST:
d6181b
+    }
d6181b
+    else if (from | BE_PTASK_SCHEDULE_FROM_LAST) {
d6181b
         tv = tevent_timeval_set(task->last_execution + delay, 0);
d6181b
 
d6181b
         DEBUG(SSSDBG_TRACE_FUNC, "Task [%s]: scheduling task %lu seconds "
d6181b
                                   "from last execution time [%lu]\n",
d6181b
                                   task->name, delay, tv.tv_sec);
d6181b
-        break;
d6181b
     }
d6181b
 
d6181b
     if (task->timer != NULL) {
d6181b
@@ -261,6 +258,36 @@ static void be_ptask_schedule(struct be_ptask *task,
d6181b
     task->next_execution = tv.tv_sec;
d6181b
 }
d6181b
 
d6181b
+static unsigned int be_ptask_flag_bits(uint32_t flags)
d6181b
+{
d6181b
+    unsigned int cnt = 0;
d6181b
+    while (flags != 0) {
d6181b
+        cnt += flags & 1;
d6181b
+        flags >>= 1;
d6181b
+    }
d6181b
+    return cnt;
d6181b
+}
d6181b
+
d6181b
+static int be_ptask_flag_check(uint32_t flags)
d6181b
+{
d6181b
+    uint32_t tmpflags;
d6181b
+
d6181b
+    tmpflags = flags & (BE_PTASK_SCHEDULE_FROM_LAST |
d6181b
+                        BE_PTASK_SCHEDULE_FROM_NOW);
d6181b
+    if (be_ptask_flag_bits(tmpflags) != 1) {
d6181b
+        return EINVAL;
d6181b
+    }
d6181b
+
d6181b
+    tmpflags = flags & (BE_PTASK_OFFLINE_SKIP |
d6181b
+                        BE_PTASK_OFFLINE_DISABLE |
d6181b
+                        BE_PTASK_OFFLINE_EXECUTE);
d6181b
+    if (be_ptask_flag_bits(tmpflags) != 1) {
d6181b
+        return EINVAL;
d6181b
+    }
d6181b
+
d6181b
+    return EOK;
d6181b
+}
d6181b
+
d6181b
 errno_t be_ptask_create(TALLOC_CTX *mem_ctx,
d6181b
                         struct be_ctx *be_ctx,
d6181b
                         time_t period,
d6181b
@@ -268,8 +295,6 @@ errno_t be_ptask_create(TALLOC_CTX *mem_ctx,
d6181b
                         time_t enabled_delay,
d6181b
                         time_t random_offset,
d6181b
                         time_t timeout,
d6181b
-                        enum be_ptask_offline offline,
d6181b
-                        enum be_ptask_schedule success_schedule_type,
d6181b
                         time_t max_backoff,
d6181b
                         be_ptask_send_t send_fn,
d6181b
                         be_ptask_recv_t recv_fn,
d6181b
@@ -290,6 +315,12 @@ errno_t be_ptask_create(TALLOC_CTX *mem_ctx,
d6181b
         return EINVAL;
d6181b
     }
d6181b
 
d6181b
+    /* check flags, some of them are exclusive, some must be present */
d6181b
+    ret = be_ptask_flag_check(flags);
d6181b
+    if (ret != EOK) {
d6181b
+        return ret;
d6181b
+    }
d6181b
+
d6181b
     task = talloc_zero(mem_ctx, struct be_ptask);
d6181b
     if (task == NULL) {
d6181b
         ret = ENOMEM;
d6181b
@@ -306,8 +337,6 @@ errno_t be_ptask_create(TALLOC_CTX *mem_ctx,
d6181b
     task->ro_seed = time(NULL) * getpid();
d6181b
     task->max_backoff = max_backoff;
d6181b
     task->timeout = timeout;
d6181b
-    task->offline = offline;
d6181b
-    task->success_schedule_type = success_schedule_type;
d6181b
     task->send_fn = send_fn;
d6181b
     task->recv_fn = recv_fn;
d6181b
     task->pvt = pvt;
d6181b
@@ -322,7 +351,7 @@ errno_t be_ptask_create(TALLOC_CTX *mem_ctx,
d6181b
 
d6181b
     talloc_set_destructor((TALLOC_CTX*)task, be_ptask_destructor);
d6181b
 
d6181b
-    if (offline == BE_PTASK_OFFLINE_DISABLE) {
d6181b
+    if (flags & BE_PTASK_OFFLINE_DISABLE) {
d6181b
         /* install offline and online callbacks */
d6181b
         ret = be_add_online_cb(task, be_ctx, be_ptask_online_cb, task, NULL);
d6181b
         if (ret != EOK) {
d6181b
@@ -458,7 +487,6 @@ errno_t be_ptask_create_sync(TALLOC_CTX *mem_ctx,
d6181b
                              time_t enabled_delay,
d6181b
                              time_t random_offset,
d6181b
                              time_t timeout,
d6181b
-                             enum be_ptask_offline offline,
d6181b
                              time_t max_backoff,
d6181b
                              be_ptask_sync_t fn,
d6181b
                              void *pvt,
d6181b
@@ -479,10 +507,10 @@ errno_t be_ptask_create_sync(TALLOC_CTX *mem_ctx,
d6181b
     ctx->pvt = pvt;
d6181b
 
d6181b
     ret = be_ptask_create(mem_ctx, be_ctx, period, first_delay,
d6181b
-                          enabled_delay, random_offset, timeout, offline,
d6181b
-                          BE_PTASK_SCHEDULE_FROM_LAST,
d6181b
+                          enabled_delay, random_offset, timeout,
d6181b
                           max_backoff, be_ptask_sync_send, be_ptask_sync_recv,
d6181b
-                          ctx, name, flags, _task);
d6181b
+                          ctx, name, flags | BE_PTASK_SCHEDULE_FROM_LAST,
d6181b
+                          _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 a33443965..640c8570a 100644
d6181b
--- a/src/providers/be_ptask.h
d6181b
+++ b/src/providers/be_ptask.h
d6181b
@@ -39,33 +39,23 @@ struct be_ptask;
d6181b
 #define BE_PTASK_NO_PERIODIC         0x0001
d6181b
 
d6181b
 /**
d6181b
- * Defines how should task behave when back end is offline.
d6181b
+ * Flags defining the starting point for scheduling a task
d6181b
  */
d6181b
-enum be_ptask_offline {
d6181b
-    /* current request will be skipped and rescheduled to 'now + period' */
d6181b
-    BE_PTASK_OFFLINE_SKIP,
d6181b
-
d6181b
-    /* An offline and online callback is registered. The task is disabled
d6181b
-     * immediately when back end goes offline and then enabled again
d6181b
-     * when back end goes back online */
d6181b
-    BE_PTASK_OFFLINE_DISABLE,
d6181b
-
d6181b
-    /* current request will be executed as planned */
d6181b
-    BE_PTASK_OFFLINE_EXECUTE
d6181b
-};
d6181b
+/* Schedule starting from now, typically this is used when scheduling
d6181b
+ * relative to the finish time */
d6181b
+#define BE_PTASK_SCHEDULE_FROM_NOW   0x0002
d6181b
+/* Schedule relative to the start time of the task */
d6181b
+#define BE_PTASK_SCHEDULE_FROM_LAST  0x0004
d6181b
 
d6181b
 /**
d6181b
- * Defines the starting point for scheduling a task
d6181b
+ * Flags defining how should task behave when back end is offline.
d6181b
  */
d6181b
-enum be_ptask_schedule {
d6181b
-    /* Schedule starting from now, typically this is used when scheduling
d6181b
-     * relative to the finish time
d6181b
-     */
d6181b
-    BE_PTASK_SCHEDULE_FROM_NOW,
d6181b
-    /* Schedule relative to the start time of the task
d6181b
-     */
d6181b
-    BE_PTASK_SCHEDULE_FROM_LAST
d6181b
-};
d6181b
+/* current request will be skipped and rescheduled to 'now + period' */
d6181b
+#define BE_PTASK_OFFLINE_SKIP        0x0008
d6181b
+/* An offline and online callback is registered. The task is disabled */
d6181b
+#define BE_PTASK_OFFLINE_DISABLE     0x0010
d6181b
+/* current request will be executed as planned */
d6181b
+#define BE_PTASK_OFFLINE_EXECUTE     0x0020
d6181b
 
d6181b
 typedef struct tevent_req *
d6181b
 (*be_ptask_send_t)(TALLOC_CTX *mem_ctx,
d6181b
@@ -128,8 +118,6 @@ errno_t be_ptask_create(TALLOC_CTX *mem_ctx,
d6181b
                         time_t enabled_delay,
d6181b
                         time_t random_offset,
d6181b
                         time_t timeout,
d6181b
-                        enum be_ptask_offline offline,
d6181b
-                        enum be_ptask_schedule success_schedule_type,
d6181b
                         time_t max_backoff,
d6181b
                         be_ptask_send_t send_fn,
d6181b
                         be_ptask_recv_t recv_fn,
d6181b
@@ -145,7 +133,6 @@ errno_t be_ptask_create_sync(TALLOC_CTX *mem_ctx,
d6181b
                              time_t enabled_delay,
d6181b
                              time_t random_offset,
d6181b
                              time_t timeout,
d6181b
-                             enum be_ptask_offline offline,
d6181b
                              time_t max_backoff,
d6181b
                              be_ptask_sync_t fn,
d6181b
                              void *pvt,
d6181b
diff --git a/src/providers/be_ptask_private.h b/src/providers/be_ptask_private.h
d6181b
index 496a2f9ae..f3e5beec7 100644
d6181b
--- a/src/providers/be_ptask_private.h
d6181b
+++ b/src/providers/be_ptask_private.h
d6181b
@@ -31,8 +31,6 @@ struct be_ptask {
d6181b
     unsigned int ro_seed;
d6181b
     time_t timeout;
d6181b
     time_t max_backoff;
d6181b
-    enum be_ptask_offline offline;
d6181b
-    enum be_ptask_schedule success_schedule_type;
d6181b
     be_ptask_send_t send_fn;
d6181b
     be_ptask_recv_t recv_fn;
d6181b
     void *pvt;
d6181b
diff --git a/src/providers/be_refresh.c b/src/providers/be_refresh.c
d6181b
index 687d3f022..6cce38390 100644
d6181b
--- a/src/providers/be_refresh.c
d6181b
+++ b/src/providers/be_refresh.c
d6181b
@@ -173,11 +173,12 @@ static errno_t be_refresh_ctx_init(struct be_ctx *be_ctx,
d6181b
     refresh_interval = be_ctx->domain->refresh_expired_interval;
d6181b
     if (refresh_interval > 0) {
d6181b
         ret = be_ptask_create(be_ctx, be_ctx, refresh_interval, 30, 5, 0,
d6181b
-                              refresh_interval, BE_PTASK_OFFLINE_SKIP,
d6181b
-                              BE_PTASK_SCHEDULE_FROM_NOW,
d6181b
-                              0,
d6181b
+                              refresh_interval, 0,
d6181b
                               be_refresh_send, be_refresh_recv,
d6181b
-                              ctx, "Refresh Records", 0, NULL);
d6181b
+                              ctx, "Refresh Records",
d6181b
+                              BE_PTASK_OFFLINE_SKIP |
d6181b
+                              BE_PTASK_SCHEDULE_FROM_NOW,
d6181b
+                              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 f21669b8c..ce00231ff 100644
d6181b
--- a/src/providers/data_provider_be.c
d6181b
+++ b/src/providers/data_provider_be.c
d6181b
@@ -130,10 +130,10 @@ void be_mark_offline(struct be_ctx *ctx)
d6181b
         ret = be_ptask_create_sync(ctx, ctx,
d6181b
                                    offline_timeout, offline_timeout,
d6181b
                                    offline_timeout, 30, offline_timeout,
d6181b
-                                   BE_PTASK_OFFLINE_EXECUTE,
d6181b
                                    3600 /* max_backoff */,
d6181b
                                    try_to_go_online,
d6181b
-                                   ctx, "Check if online (periodic)", 0,
d6181b
+                                   ctx, "Check if online (periodic)",
d6181b
+                                   BE_PTASK_OFFLINE_EXECUTE,
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 27852c2e2..f8831287a 100644
d6181b
--- a/src/providers/ipa/ipa_dyndns.c
d6181b
+++ b/src/providers/ipa/ipa_dyndns.c
d6181b
@@ -74,11 +74,12 @@ errno_t ipa_dyndns_init(struct be_ctx *be_ctx,
d6181b
     }
d6181b
 
d6181b
     ret = be_ptask_create(ctx, be_ctx, period, ptask_first_delay, 0, 0, period,
d6181b
-                          BE_PTASK_OFFLINE_DISABLE,
d6181b
-                          BE_PTASK_SCHEDULE_FROM_LAST,
d6181b
                           0,
d6181b
                           ipa_dyndns_update_send, ipa_dyndns_update_recv, ctx,
d6181b
-                          "Dyndns update", 0, NULL);
d6181b
+                          "Dyndns update",
d6181b
+                          BE_PTASK_OFFLINE_DISABLE |
d6181b
+                          BE_PTASK_SCHEDULE_FROM_LAST,
d6181b
+                          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 13e49c5c0..d000f1230 100644
d6181b
--- a/src/providers/ipa/ipa_subdomains.c
d6181b
+++ b/src/providers/ipa/ipa_subdomains.c
d6181b
@@ -3134,11 +3134,12 @@ errno_t ipa_subdomains_init(TALLOC_CTX *mem_ctx,
d6181b
 
d6181b
     period = be_ctx->domain->subdomain_refresh_interval;
d6181b
     ret = be_ptask_create(sd_ctx, be_ctx, period, ptask_first_delay, 0, 0, period,
d6181b
-                          BE_PTASK_OFFLINE_DISABLE,
d6181b
-                          BE_PTASK_SCHEDULE_FROM_LAST,
d6181b
                           0,
d6181b
                           ipa_subdomains_ptask_send, ipa_subdomains_ptask_recv, sd_ctx,
d6181b
-                          "Subdomains Refresh", 0, NULL);
d6181b
+                          "Subdomains Refresh",
d6181b
+                          BE_PTASK_OFFLINE_DISABLE |
d6181b
+                          BE_PTASK_SCHEDULE_FROM_LAST,
d6181b
+                          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 df56f4da4..a62060337 100644
d6181b
--- a/src/providers/ldap/ldap_id_cleanup.c
d6181b
+++ b/src/providers/ldap/ldap_id_cleanup.c
d6181b
@@ -87,8 +87,9 @@ errno_t ldap_setup_cleanup(struct sdap_id_ctx *id_ctx,
d6181b
 
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, 0,
d6181b
+                               period /* timeout */, 0,
d6181b
+                               ldap_cleanup_task, cleanup_ctx, name,
d6181b
+                               BE_PTASK_OFFLINE_SKIP,
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 2137f6821..009d9d275 100644
d6181b
--- a/src/providers/ldap/ldap_id_enum.c
d6181b
+++ b/src/providers/ldap/ldap_id_enum.c
d6181b
@@ -98,11 +98,11 @@ errno_t ldap_setup_enumeration(struct be_ctx *be_ctx,
d6181b
                           5,                        /* enabled delay */
d6181b
                           0,                        /* random offset */
d6181b
                           period,                   /* timeout */
d6181b
-                          BE_PTASK_OFFLINE_SKIP,
d6181b
-                          BE_PTASK_SCHEDULE_FROM_LAST,
d6181b
                           0,                        /* max_backoff */
d6181b
                           send_fn, recv_fn,
d6181b
-                          ectx, "enumeration", 0, &sdom->enum_task);
d6181b
+                          ectx, "enumeration",
d6181b
+                          BE_PTASK_OFFLINE_SKIP | BE_PTASK_SCHEDULE_FROM_LAST,
d6181b
+                          &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 59356bd44..062a95ab6 100644
d6181b
--- a/src/providers/ldap/sdap_sudo_shared.c
d6181b
+++ b/src/providers/ldap/sdap_sudo_shared.c
d6181b
@@ -90,11 +90,12 @@ sdap_sudo_ptask_setup_generic(struct be_ctx *be_ctx,
d6181b
      * when offline. */
d6181b
     if (full > 0) {
d6181b
         ret = be_ptask_create(be_ctx, be_ctx, full, delay, 0, 0, full,
d6181b
-                              BE_PTASK_OFFLINE_DISABLE,
d6181b
-                              BE_PTASK_SCHEDULE_FROM_LAST,
d6181b
                               0,
d6181b
                               full_send_fn, full_recv_fn, pvt,
d6181b
-                              "SUDO Full Refresh", 0, NULL);
d6181b
+                              "SUDO Full Refresh",
d6181b
+                              BE_PTASK_OFFLINE_DISABLE |
d6181b
+                              BE_PTASK_SCHEDULE_FROM_LAST,
d6181b
+                              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
@@ -109,11 +110,12 @@ sdap_sudo_ptask_setup_generic(struct be_ctx *be_ctx,
d6181b
      * when offline. */
d6181b
     if (smart > 0) {
d6181b
         ret = be_ptask_create(be_ctx, be_ctx, smart, delay + smart, smart, 0,
d6181b
-                              smart, BE_PTASK_OFFLINE_DISABLE,
d6181b
-                              BE_PTASK_SCHEDULE_FROM_LAST,
d6181b
-                              0,
d6181b
+                              smart,                              0,
d6181b
                               smart_send_fn, smart_recv_fn, pvt,
d6181b
-                              "SUDO Smart Refresh", 0, NULL);
d6181b
+                              "SUDO Smart Refresh",
d6181b
+                              BE_PTASK_OFFLINE_DISABLE |
d6181b
+                              BE_PTASK_SCHEDULE_FROM_LAST,
d6181b
+                              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 ac8c0767f..b30775306 100644
d6181b
--- a/src/tests/cmocka/test_be_ptask.c
d6181b
+++ b/src/tests/cmocka/test_be_ptask.c
d6181b
@@ -304,9 +304,10 @@ void test_be_ptask_create_einval_be(void **state)
d6181b
     errno_t ret;
d6181b
 
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", 0, &ptask);
d6181b
+                          test_be_ptask_recv, NULL, "Test ptask",
d6181b
+                          BE_PTASK_OFFLINE_SKIP | BE_PTASK_SCHEDULE_FROM_LAST,
d6181b
+                          &ptask);
d6181b
     assert_int_equal(ret, EINVAL);
d6181b
     assert_null(ptask);
d6181b
 }
d6181b
@@ -318,9 +319,10 @@ void test_be_ptask_create_einval_period(void **state)
d6181b
     errno_t ret;
d6181b
 
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", 0, &ptask);
d6181b
+                          test_be_ptask_recv, NULL, "Test ptask",
d6181b
+                          BE_PTASK_OFFLINE_SKIP | BE_PTASK_SCHEDULE_FROM_LAST,
d6181b
+                          &ptask);
d6181b
     assert_int_equal(ret, EINVAL);
d6181b
     assert_null(ptask);
d6181b
 }
d6181b
@@ -332,9 +334,10 @@ void test_be_ptask_create_einval_send(void **state)
d6181b
     errno_t ret;
d6181b
 
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", 0, &ptask);
d6181b
+                          test_be_ptask_recv, NULL, "Test ptask",
d6181b
+                          BE_PTASK_OFFLINE_SKIP | BE_PTASK_SCHEDULE_FROM_LAST,
d6181b
+                          &ptask);
d6181b
     assert_int_equal(ret, EINVAL);
d6181b
     assert_null(ptask);
d6181b
 }
d6181b
@@ -346,9 +349,10 @@ void test_be_ptask_create_einval_recv(void **state)
d6181b
     errno_t ret;
d6181b
 
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", 0, &ptask);
d6181b
+                          NULL, NULL, "Test ptask",
d6181b
+                          BE_PTASK_OFFLINE_SKIP | BE_PTASK_SCHEDULE_FROM_LAST,
d6181b
+                          &ptask);
d6181b
     assert_int_equal(ret, EINVAL);
d6181b
     assert_null(ptask);
d6181b
 }
d6181b
@@ -360,9 +364,72 @@ void test_be_ptask_create_einval_name(void **state)
d6181b
     errno_t ret;
d6181b
 
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, 0, &ptask);
d6181b
+                          test_be_ptask_recv, NULL, NULL,
d6181b
+                          BE_PTASK_OFFLINE_SKIP | BE_PTASK_SCHEDULE_FROM_LAST,
d6181b
+                          &ptask);
d6181b
+    assert_int_equal(ret, EINVAL);
d6181b
+    assert_null(ptask);
d6181b
+}
d6181b
+
d6181b
+void test_be_ptask_mixed_from_flags_einval(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, PERIOD, 0, 0, 0, 0,
d6181b
+                          0, test_be_ptask_send,
d6181b
+                          test_be_ptask_recv, NULL, "Test ptask",
d6181b
+                          BE_PTASK_OFFLINE_SKIP |
d6181b
+                          BE_PTASK_SCHEDULE_FROM_LAST |
d6181b
+                          BE_PTASK_SCHEDULE_FROM_NOW,
d6181b
+                          &ptask);
d6181b
+    assert_int_equal(ret, EINVAL);
d6181b
+    assert_null(ptask);
d6181b
+}
d6181b
+
d6181b
+void test_be_ptask_no_from_flags_einval(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, PERIOD, 0, 0, 0, 0,
d6181b
+                          0, test_be_ptask_send,
d6181b
+                          test_be_ptask_recv, NULL, "Test ptask",
d6181b
+                          BE_PTASK_OFFLINE_SKIP,
d6181b
+                          &ptask);
d6181b
+    assert_int_equal(ret, EINVAL);
d6181b
+    assert_null(ptask);
d6181b
+}
d6181b
+void test_be_ptask_mixed_offline_flags_einval(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, PERIOD, 0, 0, 0, 0,
d6181b
+                          0, test_be_ptask_send,
d6181b
+                          test_be_ptask_recv, NULL, "Test ptask",
d6181b
+                          BE_PTASK_OFFLINE_SKIP |
d6181b
+                          BE_PTASK_OFFLINE_DISABLE |
d6181b
+                          BE_PTASK_SCHEDULE_FROM_NOW,
d6181b
+                          &ptask);
d6181b
+    assert_int_equal(ret, EINVAL);
d6181b
+    assert_null(ptask);
d6181b
+}
d6181b
+void test_be_ptask_no_offline_flags_einval(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, PERIOD, 0, 0, 0, 0,
d6181b
+                          0, test_be_ptask_send,
d6181b
+                          test_be_ptask_recv, NULL, "Test ptask",
d6181b
+                          BE_PTASK_SCHEDULE_FROM_NOW,
d6181b
+                          &ptask);
d6181b
     assert_int_equal(ret, EINVAL);
d6181b
     assert_null(ptask);
d6181b
 }
d6181b
@@ -376,9 +443,10 @@ void test_be_ptask_create_no_delay(void **state)
d6181b
 
d6181b
     now = get_current_time();
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", 0, &ptask);
d6181b
+                          test_be_ptask_recv, test_ctx, "Test ptask",
d6181b
+                          BE_PTASK_OFFLINE_SKIP | BE_PTASK_SCHEDULE_FROM_LAST,
d6181b
+                          &ptask);
d6181b
     assert_int_equal(ret, ERR_OK);
d6181b
     assert_non_null(ptask);
d6181b
     assert_non_null(ptask->timer);
d6181b
@@ -404,9 +472,10 @@ void test_be_ptask_create_first_delay(void **state)
d6181b
 
d6181b
     now = get_current_time();
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", 0, &ptask);
d6181b
+                          test_be_ptask_recv, test_ctx, "Test ptask",
d6181b
+                          BE_PTASK_OFFLINE_SKIP | BE_PTASK_SCHEDULE_FROM_LAST,
d6181b
+                          &ptask);
d6181b
     assert_int_equal(ret, ERR_OK);
d6181b
     assert_non_null(ptask);
d6181b
     assert_non_null(ptask->timer);
d6181b
@@ -430,9 +499,10 @@ void test_be_ptask_disable(void **state)
d6181b
     errno_t ret;
d6181b
 
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", 0, &ptask);
d6181b
+                          test_be_ptask_recv, test_ctx, "Test ptask",
d6181b
+                          BE_PTASK_OFFLINE_SKIP | BE_PTASK_SCHEDULE_FROM_LAST,
d6181b
+                          &ptask);
d6181b
     assert_int_equal(ret, ERR_OK);
d6181b
     assert_non_null(ptask);
d6181b
     assert_non_null(ptask->timer);
d6181b
@@ -455,9 +525,10 @@ void test_be_ptask_enable(void **state)
d6181b
 
d6181b
     now = get_current_time();
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", 0, &ptask);
d6181b
+                          test_be_ptask_recv, test_ctx, "Test ptask",
d6181b
+                          BE_PTASK_OFFLINE_SKIP | BE_PTASK_SCHEDULE_FROM_LAST,
d6181b
+                          &ptask);
d6181b
     assert_int_equal(ret, ERR_OK);
d6181b
     assert_non_null(ptask);
d6181b
     assert_non_null(ptask->timer);
d6181b
@@ -488,9 +559,10 @@ void test_be_ptask_enable_delay(void **state)
d6181b
     errno_t ret;
d6181b
 
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", 0, &ptask);
d6181b
+                          test_be_ptask_recv, test_ctx, "Test ptask",
d6181b
+                          BE_PTASK_OFFLINE_SKIP | BE_PTASK_SCHEDULE_FROM_LAST,
d6181b
+                          &ptask);
d6181b
     assert_int_equal(ret, ERR_OK);
d6181b
     assert_non_null(ptask);
d6181b
     assert_non_null(ptask->timer);
d6181b
@@ -528,9 +600,10 @@ void test_be_ptask_offline_skip(void **state)
d6181b
 
d6181b
     now = get_current_time();
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", 0, &ptask);
d6181b
+                          test_be_ptask_recv, test_ctx, "Test ptask",
d6181b
+                          BE_PTASK_OFFLINE_SKIP | BE_PTASK_SCHEDULE_FROM_LAST,
d6181b
+                          &ptask);
d6181b
     assert_int_equal(ret, ERR_OK);
d6181b
     assert_non_null(ptask);
d6181b
     assert_non_null(ptask->timer);
d6181b
@@ -562,10 +635,11 @@ void test_be_ptask_offline_disable(void **state)
d6181b
     will_return(be_add_offline_cb, test_ctx);
d6181b
 
d6181b
     ret = be_ptask_create(test_ctx, test_ctx->be_ctx, PERIOD, 0, 0, 0, 0,
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", 0, &ptask);
d6181b
+                          test_be_ptask_recv, test_ctx, "Test ptask",
d6181b
+                          BE_PTASK_OFFLINE_DISABLE |
d6181b
+                          BE_PTASK_SCHEDULE_FROM_LAST,
d6181b
+                          &ptask);
d6181b
     assert_int_equal(ret, ERR_OK);
d6181b
     assert_non_null(ptask);
d6181b
     assert_non_null(ptask->timer);
d6181b
@@ -594,10 +668,11 @@ void test_be_ptask_offline_execute(void **state)
d6181b
     mark_offline(test_ctx);
d6181b
 
d6181b
     ret = be_ptask_create(test_ctx, test_ctx->be_ctx, PERIOD, 0, 0, 0, 0,
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", 0, &ptask);
d6181b
+                          test_be_ptask_recv, test_ctx, "Test ptask",
d6181b
+                          BE_PTASK_OFFLINE_EXECUTE |
d6181b
+                          BE_PTASK_SCHEDULE_FROM_LAST,
d6181b
+                          &ptask);
d6181b
     assert_int_equal(ret, ERR_OK);
d6181b
     assert_non_null(ptask);
d6181b
     assert_non_null(ptask->timer);
d6181b
@@ -623,9 +698,10 @@ void test_be_ptask_reschedule_ok(void **state)
d6181b
 
d6181b
     now = get_current_time();
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", 0, &ptask);
d6181b
+                          test_be_ptask_recv, test_ctx, "Test ptask",
d6181b
+                          BE_PTASK_OFFLINE_SKIP | BE_PTASK_SCHEDULE_FROM_LAST,
d6181b
+                          &ptask);
d6181b
     assert_int_equal(ret, ERR_OK);
d6181b
     assert_non_null(ptask);
d6181b
     assert_non_null(ptask->timer);
d6181b
@@ -655,9 +731,9 @@ void test_be_ptask_reschedule_null(void **state)
d6181b
     errno_t ret;
d6181b
 
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", 0,
d6181b
+                          test_be_ptask_recv, test_ctx, "Test ptask",
d6181b
+                          BE_PTASK_OFFLINE_SKIP | BE_PTASK_SCHEDULE_FROM_LAST,
d6181b
                           &ptask);
d6181b
     assert_int_equal(ret, ERR_OK);
d6181b
     assert_non_null(ptask);
d6181b
@@ -683,9 +759,9 @@ void test_be_ptask_reschedule_error(void **state)
d6181b
     errno_t ret;
d6181b
 
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", 0,
d6181b
+                          test_be_ptask_error_recv, test_ctx, "Test ptask",
d6181b
+                          BE_PTASK_OFFLINE_SKIP | BE_PTASK_SCHEDULE_FROM_LAST,
d6181b
                           &ptask);
d6181b
     assert_int_equal(ret, ERR_OK);
d6181b
     assert_non_null(ptask);
d6181b
@@ -711,9 +787,9 @@ void test_be_ptask_reschedule_timeout(void **state)
d6181b
     errno_t ret;
d6181b
 
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", 0,
d6181b
+                          test_be_ptask_error_recv, test_ctx, "Test ptask",
d6181b
+                          BE_PTASK_OFFLINE_SKIP | BE_PTASK_SCHEDULE_FROM_LAST,
d6181b
                           &ptask);
d6181b
     assert_int_equal(ret, ERR_OK);
d6181b
     assert_non_null(ptask);
d6181b
@@ -749,9 +825,10 @@ void test_be_ptask_reschedule_backoff(void **state)
d6181b
 
d6181b
     now_first = get_current_time();
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", 0, &ptask);
d6181b
+                          test_be_ptask_recv, test_ctx, "Test ptask",
d6181b
+                          BE_PTASK_OFFLINE_SKIP | BE_PTASK_SCHEDULE_FROM_LAST,
d6181b
+                          &ptask);
d6181b
     assert_int_equal(ret, ERR_OK);
d6181b
     assert_non_null(ptask);
d6181b
     assert_non_null(ptask->timer);
d6181b
@@ -804,9 +881,10 @@ void test_be_ptask_get_period(void **state)
d6181b
     errno_t ret;
d6181b
 
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", 0, &ptask);
d6181b
+                          test_be_ptask_recv, test_ctx, "Test ptask",
d6181b
+                          BE_PTASK_OFFLINE_SKIP | BE_PTASK_SCHEDULE_FROM_LAST,
d6181b
+                          &ptask);
d6181b
     assert_int_equal(ret, ERR_OK);
d6181b
     assert_non_null(ptask);
d6181b
 
d6181b
@@ -825,9 +903,10 @@ void test_be_ptask_get_timeout(void **state)
d6181b
     errno_t ret;
d6181b
 
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", 0, &ptask);
d6181b
+                          test_be_ptask_recv, test_ctx, "Test ptask",
d6181b
+                          BE_PTASK_OFFLINE_SKIP | BE_PTASK_SCHEDULE_FROM_LAST,
d6181b
+                          &ptask);
d6181b
     assert_int_equal(ret, ERR_OK);
d6181b
     assert_non_null(ptask);
d6181b
 
d6181b
@@ -845,10 +924,12 @@ void test_be_ptask_no_periodic(void **state)
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
+                          BE_PTASK_NO_PERIODIC |
d6181b
+                          BE_PTASK_OFFLINE_SKIP |
d6181b
+                          BE_PTASK_SCHEDULE_FROM_LAST,
d6181b
+                          &ptask);
d6181b
     assert_int_equal(ret, ERR_OK);
d6181b
     assert_non_null(ptask);
d6181b
 
d6181b
@@ -865,8 +946,8 @@ void test_be_ptask_create_sync(void **state)
d6181b
 
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", 0, &ptask);
d6181b
+                               0, test_be_ptask_sync, test_ctx, "Test ptask",
d6181b
+                               BE_PTASK_OFFLINE_SKIP, &ptask);
d6181b
     assert_int_equal(ret, ERR_OK);
d6181b
     assert_non_null(ptask);
d6181b
     assert_non_null(ptask->timer);
d6181b
@@ -893,8 +974,8 @@ void test_be_ptask_sync_reschedule_ok(void **state)
d6181b
 
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", 0, &ptask);
d6181b
+                               0, test_be_ptask_sync, test_ctx, "Test ptask",
d6181b
+                               BE_PTASK_OFFLINE_SKIP, &ptask);
d6181b
     assert_int_equal(ret, ERR_OK);
d6181b
     assert_non_null(ptask);
d6181b
     assert_non_null(ptask->timer);
d6181b
@@ -924,9 +1005,9 @@ void test_be_ptask_sync_reschedule_error(void **state)
d6181b
     errno_t ret;
d6181b
 
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", 0, &ptask);
d6181b
+                               0, test_be_ptask_sync_error,
d6181b
+                               test_ctx, "Test ptask",
d6181b
+                               BE_PTASK_OFFLINE_SKIP, &ptask);
d6181b
     assert_int_equal(ret, ERR_OK);
d6181b
     assert_non_null(ptask);
d6181b
     assert_non_null(ptask->timer);
d6181b
@@ -953,10 +1034,11 @@ void test_be_ptask_sync_reschedule_backoff(void **state)
d6181b
     errno_t ret;
d6181b
 
d6181b
     now_first = 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, PERIOD*2,
d6181b
+    ret = be_ptask_create_sync(test_ctx, test_ctx->be_ctx, PERIOD,
d6181b
+                               0, 0, 0, 0, PERIOD*2,
d6181b
                                test_be_ptask_sync_error,
d6181b
-                               test_ctx, "Test ptask", 0, &ptask);
d6181b
+                               test_ctx, "Test ptask",
d6181b
+                               BE_PTASK_OFFLINE_SKIP, &ptask);
d6181b
     assert_int_equal(ret, ERR_OK);
d6181b
     assert_non_null(ptask);
d6181b
     assert_non_null(ptask->timer);
d6181b
@@ -1017,6 +1099,10 @@ int main(int argc, const char *argv[])
d6181b
         new_test(be_ptask_create_einval_send),
d6181b
         new_test(be_ptask_create_einval_recv),
d6181b
         new_test(be_ptask_create_einval_name),
d6181b
+        new_test(be_ptask_mixed_from_flags_einval),
d6181b
+        new_test(be_ptask_no_from_flags_einval),
d6181b
+        new_test(be_ptask_mixed_offline_flags_einval),
d6181b
+        new_test(be_ptask_no_offline_flags_einval),
d6181b
         new_test(be_ptask_create_no_delay),
d6181b
         new_test(be_ptask_create_first_delay),
d6181b
         new_test(be_ptask_disable),
d6181b
-- 
d6181b
2.20.1
d6181b