static bool verbose = false;
static isc_mutex_t lock;
+#ifdef ISC_PLATFORM_USETHREADS
static isc_condition_t cv;
+#endif
int counter = 0;
static int active[10];
static bool done = false;
-#ifdef ISC_PLATFORM_USETHREADS
-static isc_condition_t cv;
-#endif
-
static int
_setup(void **state) {
isc_result_t result;
set, &a, sizeof (isc_event_t));
assert_non_null(event);
+ LOCK(&lock);
assert_int_equal(a, 0);
+ UNLOCK(&lock);
isc_task_send(task, &event);
event = isc_event_allocate(mctx, task, ISC_TASKEVENT_TEST,
set, &b, sizeof (isc_event_t));
assert_non_null(event);
+ LOCK(&lock);
assert_int_equal(b, 0);
+ UNLOCK(&lock);
isc_task_send(task, &event);
+ LOCK(&lock);
while ((a == 0 || b == 0) && i++ < 5000) {
+ UNLOCK(&lock);
#ifndef ISC_PLATFORM_USETHREADS
- while (isc__taskmgr_ready(taskmgr))
+ while (isc__taskmgr_ready(taskmgr))
isc__taskmgr_dispatch(taskmgr);
#endif
isc_test_nap(1000);
+ LOCK(&lock);
}
assert_int_not_equal(a, 0);
assert_int_not_equal(b, 0);
+ UNLOCK(&lock);
isc_task_destroy(&task);
assert_null(task);
set, &a, sizeof (isc_event_t));
assert_non_null(event);
+ LOCK(&lock);
assert_int_equal(a, 0);
+ UNLOCK(&lock);
isc_task_send(task1, &event);
/* Second event: not privileged */
set, &b, sizeof (isc_event_t));
assert_non_null(event);
+ LOCK(&lock);
assert_int_equal(b, 0);
+ UNLOCK(&lock);
isc_task_send(task2, &event);
/* Third event: privileged */
set, &c, sizeof (isc_event_t));
assert_non_null(event);
+ LOCK(&lock);
assert_int_equal(c, 0);
+ UNLOCK(&lock);
isc_task_send(task1, &event);
/* Fourth event: privileged */
set, &d, sizeof (isc_event_t));
assert_non_null(event);
+ LOCK(&lock);
assert_int_equal(d, 0);
+ UNLOCK(&lock);
isc_task_send(task1, &event);
/* Fifth event: not privileged */
set, &e, sizeof (isc_event_t));
assert_non_null(event);
+ LOCK(&lock);
assert_int_equal(e, 0);
+ UNLOCK(&lock);
isc_task_send(task2, &event);
assert_int_equal(isc_taskmgr_mode(taskmgr), isc_taskmgrmode_normal);
#endif
/* We're waiting for *all* variables to be set */
+ LOCK(&lock);
while ((a == 0 || b == 0 || c == 0 || d == 0 || e == 0) && i++ < 5000) {
+ UNLOCK(&lock);
#ifndef ISC_PLATFORM_USETHREADS
while (isc__taskmgr_ready(taskmgr))
isc__taskmgr_dispatch(taskmgr);
#endif
isc_test_nap(1000);
+ LOCK(&lock);
}
/*
assert_true(e >= 4);
assert_int_equal(counter, 6);
+ UNLOCK(&lock);
isc_task_setprivilege(task1, false);
assert_false(isc_task_privilege(task1));
set_and_drop, &a, sizeof (isc_event_t));
assert_non_null(event);
+ LOCK(&lock);
assert_int_equal(a, -1);
+ UNLOCK(&lock);
isc_task_send(task1, &event);
/* Second event: not privileged */
set_and_drop, &b, sizeof (isc_event_t));
assert_non_null(event);
+ LOCK(&lock);
assert_int_equal(b, -1);
+ UNLOCK(&lock);
isc_task_send(task2, &event);
/* Third event: privileged */
set_and_drop, &c, sizeof (isc_event_t));
assert_non_null(event);
+ LOCK(&lock);
assert_int_equal(c, -1);
+ UNLOCK(&lock);
isc_task_send(task1, &event);
/* Fourth event: privileged */
set_and_drop, &d, sizeof (isc_event_t));
assert_non_null(event);
+ LOCK(&lock);
assert_int_equal(d, -1);
+ UNLOCK(&lock);
isc_task_send(task1, &event);
/* Fifth event: not privileged */
set_and_drop, &e, sizeof (isc_event_t));
assert_non_null(event);
+ LOCK(&lock);
assert_int_equal(e, -1);
+ UNLOCK(&lock);
isc_task_send(task2, &event);
assert_int_equal(isc_taskmgr_mode(taskmgr), isc_taskmgrmode_normal);
#endif
/* We're waiting for all variables to be set. */
+ LOCK(&lock);
while ((a == -1 || b == -1 || c == -1 || d == -1 || e == -1) &&
i++ < 5000) {
+ UNLOCK(&lock);
#ifndef ISC_PLATFORM_USETHREADS
while (isc__taskmgr_ready(taskmgr))
isc__taskmgr_dispatch(taskmgr);
#endif
isc_test_nap(1000);
+ LOCK(&lock);
}
/*
/* ...but all five of them did run. */
assert_int_equal(counter, 6);
+ UNLOCK(&lock);
assert_int_equal(isc_taskmgr_mode(taskmgr), isc_taskmgrmode_normal);
}
isc_task_endexclusive(task);
+ LOCK(&lock);
done = true;
+ UNLOCK(&lock);
} else {
active[taskno]++;
(void) spin(10000000);
print_message("# task exit %d\n", taskno);
}
+ LOCK(&lock);
if (done) {
isc_mem_put(event->ev_destroy_arg, event->ev_arg, sizeof (int));
isc_event_free(&event);
} else {
isc_task_send(task, &event);
}
+ UNLOCK(&lock);
}
static void
(unsigned long)ntasks);
}
+ result = isc_mutex_init(&lock);
+ assert_int_equal(result, ISC_R_SUCCESS);
+
result = isc_condition_init(&cv);
assert_int_equal(result, ISC_R_SUCCESS);
while (!done) {
WAIT(&cv, &lock);
}
+ UNLOCK(&lock);
isc_taskmgr_destroy(&taskmgr);
isc_mem_destroy(&mctx);
isc_condition_destroy(&cv);
+
+ result = isc_mutex_destroy(&lock);
+ assert_int_equal(result, ISC_R_SUCCESS);
}
/*
sd_sde1(isc_task_t *task, isc_event_t *event) {
UNUSED(task);
+ LOCK(&lock);
assert_int_equal(nevents, 256);
assert_int_equal(nsdevents, 1);
++nsdevents;
+ UNLOCK(&lock);
if (verbose) {
print_message("# shutdown 1\n");
isc_event_free(&event);
+ LOCK(&lock);
all_done = true;
+ UNLOCK(&lock);
}
static void
sd_sde2(isc_task_t *task, isc_event_t *event) {
UNUSED(task);
+ LOCK(&lock);
assert_int_equal(nevents, 256);
assert_int_equal(nsdevents, 0);
++nsdevents;
+ UNLOCK(&lock);
if (verbose) {
print_message("# shutdown 2\n");
UNUSED(state);
+ LOCK(&lock);
nevents = nsdevents = 0;
event_type = 3;
ready = false;
- LOCK(&lock);
-
result = isc_task_create(taskmgr, 0, &task);
assert_int_equal(result, ISC_R_SUCCESS);
SIGNAL(&cv);
UNLOCK(&lock);
+ LOCK(&lock);
while (!all_done) {
+ UNLOCK(&lock);
isc_test_nap(1000);
+ LOCK(&lock);
}
assert_int_equal(nsdevents, 2);
+ UNLOCK(&lock);
}
/*
UNUSED(state);
+ LOCK(&lock);
done = false;
event_type = 4;
result = isc_condition_init(&cv);
assert_int_equal(result, ISC_R_SUCCESS);
- LOCK(&lock);
-
task = NULL;
result = isc_task_create(taskmgr, 0, &task);
assert_int_equal(result, ISC_R_SUCCESS);
tag_match = true;
}
+ LOCK(&lock);
if (sender_match && type_match && tag_match) {
if ((event->ev_attributes & ISC_EVENTATTR_NOPURGE) != 0) {
if (verbose) {
} else {
++eventcnt;
}
+ UNLOCK(&lock);
isc_event_free(&event);
}
int sender_cnt, type_cnt, tag_cnt, event_cnt, i;
int purged = 0;
+ LOCK(&lock);
started = false;
done = false;
eventcnt = 0;
+ UNLOCK(&lock);
result = isc_condition_init(&cv);
assert_int_equal(result, ISC_R_SUCCESS);
pge_event2(isc_task_t *task, isc_event_t *event) {
UNUSED(task);
+ LOCK(&lock);
++eventcnt;
+ UNLOCK(&lock);
isc_event_free(&event);
}
isc_time_t now;
isc_interval_t interval;
+ LOCK(&lock);
started = false;
done = false;
eventcnt = 0;
+ UNLOCK(&lock);
result = isc_condition_init(&cv);
assert_int_equal(result, ISC_R_SUCCESS);
SIGNAL(&cv);
isc_task_shutdown(task);
+ UNLOCK(&lock);
isc_interval_set(&interval, 5, 0);
/*
* Wait for shutdown processing to complete.
*/
+ LOCK(&lock);
while (!done) {
result = isc_time_nowplusinterval(&now, &interval);
assert_int_equal(result, ISC_R_SUCCESS);
isc_task_detach(&task);
+ LOCK(&lock);
assert_int_equal(eventcnt, (purgeable ? 0 : 1));
+ UNLOCK(&lock);
}
/*