Commit f166cabc authored by Witold Krecicki's avatar Witold Krecicki
Browse files

Document isc_task_sendto properly, make sure that cpu we're sending to is always sane

parent 025c74ad
......@@ -212,7 +212,8 @@ isc_task_send(isc_task_t *task, isc_event_t **eventp);
void
isc_task_sendto(isc_task_t *task, isc_event_t **eventp, int c);
/*%<
* Send '*event' to 'task'.
* Send '*event' to 'task', if task is idle try starting it on cpu 'c'
* If 'c' is smaller than 0 then cpu is selected randomly.
*
* Requires:
*
......@@ -231,7 +232,8 @@ void
isc_task_sendanddetach(isc_task_t **taskp, isc_event_t **eventp);
/*%<
* Send '*event' to '*taskp' and then detach '*taskp' from its
* task.
* task. If task is idle try starting it on cpu 'c'
* If 'c' is smaller than 0 then cpu is selected randomly.
*
* Requires:
*
......
......@@ -481,14 +481,13 @@ isc_task_sendto(isc_task_t *task0, isc_event_t **eventp, int c) {
*/
REQUIRE(VALID_TASK(task));
XTRACE("isc_task_send");
if (c == -1) {
if (c < 0) {
c = atomic_fetch_add_explicit(&task->manager->curq, 1,
memory_order_relaxed)
% task->manager->workers;
memory_order_relaxed);
}
XTRACE("isc_task_send");
c %= task->manager->workers;
/*
* We're trying hard to hold locks for as short a time as possible.
......@@ -532,13 +531,14 @@ isc_task_sendtoanddetach(isc_task_t **taskp, isc_event_t **eventp, int c) {
REQUIRE(taskp != NULL);
task = (isc__task_t *)*taskp;
REQUIRE(VALID_TASK(task));
if (c == -1) {
XTRACE("isc_task_sendanddetach");
if (c < 0) {
c = atomic_fetch_add_explicit(&task->manager->curq, 1,
memory_order_relaxed)
% task->manager->workers;
memory_order_relaxed);
}
c %= task->manager->workers;
XTRACE("isc_task_sendanddetach");
LOCK(&task->lock);
idle1 = task_send(task, eventp, c);
idle2 = task_detach(task);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment