diff --git a/lib/isc/include/isc/task.h b/lib/isc/include/isc/task.h index 4d5f0080e5..973cb30284 100644 --- a/lib/isc/include/isc/task.h +++ b/lib/isc/include/isc/task.h @@ -54,18 +54,6 @@ * * Purging calls isc_event_free() on the matching events. * - * Unsending returns a list of events that matched the pattern. - * The caller is then responsible for them. - * - * Consumers of events should purge, not unsend. - * - * Producers of events often want to remove events when the caller indicates - * it is no longer interested in the object, e.g. by canceling a timer. - * Sometimes this can be done by purging, but for some event types, the - * calls to isc_event_free() cause deadlock because the event free routine - * wants to acquire a lock the caller is already holding. Unsending instead - * of purging solves this problem. As a general rule, producers should only - * unsend events which they have sent. */ /*** @@ -337,34 +325,6 @@ isc_task_purgeevent(isc_task_t *task, isc_event_t *event); * or was marked unpurgeable. */ -unsigned int -isc_task_unsendrange(isc_task_t *task, void *sender, isc_eventtype_t first, - isc_eventtype_t last, void *tag, isc_eventlist_t *events); -/*%< - * Remove events from a task's event queue. - * - * Requires: - * - *\li 'task' is a valid task. - * - *\li last >= first. - * - *\li *events is a valid list. - * - * Ensures: - * - *\li Events in the event queue of 'task' whose sender is 'sender', whose - * type is >= first and <= last, and whose tag is 'tag' will be dequeued - * and appended to *events. - * - *\li A sender of NULL will match any sender. A NULL tag matches any - * tag. - * - * Returns: - * - *\li The number of events unsent. - */ - unsigned int isc_task_unsend(isc_task_t *task, void *sender, isc_eventtype_t type, void *tag, isc_eventlist_t *events); @@ -373,27 +333,27 @@ isc_task_unsend(isc_task_t *task, void *sender, isc_eventtype_t type, void *tag, * * Notes: * - *\li This function is equivalent to + *\li This function is equivalent to * *\code - * isc_task_unsendrange(task, sender, type, type, tag, events); + * isc_task_unsendrange(task, sender, type, type, tag, events); *\endcode * * Requires: * - *\li 'task' is a valid task. + *\li 'task' is a valid task. * - *\li *events is a valid list. + *\li *events is a valid list. * * Ensures: * - *\li Events in the event queue of 'task' whose sender is 'sender', whose - * type is 'type', and whose tag is 'tag' will be dequeued and appended - * to *events. + *\li Events in the event queue of 'task' whose sender is 'sender', whose + * type is 'type', and whose tag is 'tag' will be dequeued and appended + * to *events. * * Returns: * - *\li The number of events unsent. + *\li The number of events unsent. */ isc_result_t diff --git a/lib/isc/task.c b/lib/isc/task.c index 81909c8c36..7698c84492 100644 --- a/lib/isc/task.c +++ b/lib/isc/task.c @@ -614,12 +614,10 @@ isc_task_purge(isc_task_t *task, void *sender, isc_eventtype_t type, bool isc_task_purgeevent(isc_task_t *task, isc_event_t *event) { - isc_event_t *curr_event, *next_event; + bool found = false; /* * Purge 'event' from a task's event queue. - * - * XXXRTH: WARNING: This method may be removed before beta. */ REQUIRE(VALID_TASK(task)); @@ -635,40 +633,22 @@ isc_task_purgeevent(isc_task_t *task, isc_event_t *event) { */ LOCK(&task->lock); - for (curr_event = HEAD(task->events); curr_event != NULL; - curr_event = next_event) - { - next_event = NEXT(curr_event, ev_link); - if (curr_event == event && PURGE_OK(event)) { - DEQUEUE(task->events, curr_event, ev_link); - task->nevents--; - break; - } + if (ISC_LINK_LINKED(event, ev_link)) { + DEQUEUE(task->events, event, ev_link); + task->nevents--; + found = true; } UNLOCK(&task->lock); - if (curr_event == NULL) { + if (!found) { return (false); } - isc_event_free(&curr_event); + isc_event_free(&event); return (true); } -unsigned int -isc_task_unsendrange(isc_task_t *task, void *sender, isc_eventtype_t first, - isc_eventtype_t last, void *tag, isc_eventlist_t *events) { - /* - * Remove events from a task's event queue. - */ - REQUIRE(VALID_TASK(task)); - - XTRACE("isc_task_unsendrange"); - - return (dequeue_events(task, sender, first, last, tag, events, false)); -} - unsigned int isc_task_unsend(isc_task_t *task, void *sender, isc_eventtype_t type, void *tag, isc_eventlist_t *events) { diff --git a/lib/isc/tests b/lib/isc/tests deleted file mode 120000 index 9c8d7ce1d0..0000000000 --- a/lib/isc/tests +++ /dev/null @@ -1 +0,0 @@ -../../tests/isc \ No newline at end of file diff --git a/tests/isc/task_test.c b/tests/isc/task_test.c index 69492db851..e31b54c77f 100644 --- a/tests/isc/task_test.c +++ b/tests/isc/task_test.c @@ -1389,19 +1389,6 @@ ISC_RUN_TEST_IMPL(purgeevent) { try_purgeevent(true); } -/* - * Purge event not purgeable test: - * When the event is not marked as purgable, a call to - * isc_task_purgeevent(task, event) does not purge the event - * 'event' from the task's queue and returns false. - */ - -ISC_RUN_TEST_IMPL(purgeevent_notpurge) { - UNUSED(state); - - try_purgeevent(false); -} - ISC_TEST_LIST_START ISC_TEST_ENTRY_CUSTOM(manytasks, _setup4, _teardown) @@ -1413,7 +1400,6 @@ ISC_TEST_ENTRY_CUSTOM(privilege_drop, _setup, _teardown) ISC_TEST_ENTRY_CUSTOM(privileged_events, _setup, _teardown) ISC_TEST_ENTRY_CUSTOM(purge, _setup2, _teardown) ISC_TEST_ENTRY_CUSTOM(purgeevent, _setup2, _teardown) -ISC_TEST_ENTRY_CUSTOM(purgeevent_notpurge, _setup2, _teardown) ISC_TEST_ENTRY_CUSTOM(task_shutdown, _setup4, _teardown) ISC_TEST_ENTRY_CUSTOM(task_exclusive, _setup4, _teardown)