commit 6c2e4dd8318eb9dc7613b9fb57036ff7041344c4
parent 097a1166dfd108c3572387e1e5899c98c9bc29d5
Author: Joris Vink <joris@coders.se>
Date: Tue, 14 Apr 2015 09:01:36 +0200
Task improvements.
* Always start listening on the task its socket endpoint when
called kore_task_run() instead of at kore_task_bind_request().
* Disable read events on the task its socket endpoint when
kore_task_handle() is called for a finished task. Stops us
from entering a busy loop until kore_task_destroy() is called.
Diffstat:
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/src/tasks.c b/src/tasks.c
@@ -75,6 +75,8 @@ kore_task_run(struct kore_task *t)
{
struct kore_task_thread *tt;
+ kore_platform_schedule_read(t->fds[0], t);
+
pthread_mutex_lock(&task_thread_lock);
if (TAILQ_EMPTY(&task_threads))
task_thread_spawn(&tt);
@@ -100,7 +102,6 @@ kore_task_bind_request(struct kore_task *t, struct http_request *req)
LIST_INSERT_HEAD(&(req->tasks), t, rlist);
http_request_sleep(req);
- kore_platform_schedule_read(t->fds[0], t);
}
void
@@ -174,6 +175,7 @@ kore_task_handle(struct kore_task *t, int finished)
http_request_wakeup(t->req);
if (finished) {
+ kore_platform_disable_read(t->fds[0]);
kore_task_set_state(t, KORE_TASK_STATE_FINISHED);
if (t->req != NULL) {
if (t->req->flags & HTTP_REQUEST_DELETE)