MXS-1506: Combine housekeeper task types

The tasks themselves now control whether they are executed again. To
compare it to the old system, oneshot tasks now return `false` and
repeating tasks return `true`.

Letting the housekeeper remove the tasks makes the code simpler and
removes the possibility of the task being removed while it is being
executed. It does introduce a deadlock possibility if a housekeeper
function is called inside a housekeeper task.
This commit is contained in:
Markus Mäkelä
2018-04-03 15:12:33 +03:00
parent 96a0aae7fe
commit c70216390f
10 changed files with 105 additions and 105 deletions

View File

@ -1432,11 +1432,12 @@ struct TaskAssignment
Worker* worker;
};
static void delayed_routing_cb(void* data)
static bool delayed_routing_cb(void* data)
{
TaskAssignment* job = static_cast<TaskAssignment*>(data);
job->worker->post(job->task, mxs::Worker::EXECUTE_QUEUED);
delete job;
return false;
}
bool session_delay_routing(MXS_SESSION* session, MXS_DOWNSTREAM down, GWBUF* buffer, int seconds)
@ -1454,7 +1455,7 @@ bool session_delay_routing(MXS_SESSION* session, MXS_DOWNSTREAM down, GWBUF* buf
std::auto_ptr<TaskAssignment> job(new TaskAssignment(task, worker));
TaskAssignment* pJob = job.release();
hktask_oneshot(name.str().c_str(), delayed_routing_cb, pJob, seconds);
hktask_add(name.str().c_str(), delayed_routing_cb, pJob, seconds);
success = true;
}
catch (std::bad_alloc)