kore

Kore is a web application platform for writing scalable, concurrent web based processes in C or Python.
Commits | Files | Refs | README | LICENSE | git clone https://git.kore.io/kore.git

commit 8ba29104ebe2b42be3edd2c9175caf89a8e58e3c
parent b9bd2e9a149dc1aa715fc6945c9fbfee492c67ed
Author: Joris Vink <joris@coders.se>
Date:   Sun, 29 Jun 2014 21:14:43 +0200

Task improvements.

Make sure req is initialized to NULL.
Schedule a task on the event loop only when bound to a request.

Diffstat:
contrib/tasks/kore_tasks.c | 6++++--
1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/contrib/tasks/kore_tasks.c b/contrib/tasks/kore_tasks.c @@ -61,6 +61,8 @@ kore_task_create(struct kore_task **out, void (*entry)(struct kore_task *)) struct kore_task_thread *tt; t = kore_malloc(sizeof(struct kore_task)); + + t->req = NULL; t->entry = entry; t->type = KORE_TYPE_TASK; t->state = KORE_TASK_STATE_CREATED; @@ -68,8 +70,6 @@ kore_task_create(struct kore_task **out, void (*entry)(struct kore_task *)) if (socketpair(AF_UNIX, SOCK_STREAM, 0,t->fds) == -1) fatal("kore_task_create: socketpair() %s", errno_s); - kore_platform_schedule_read(t->fds[0], t); - pthread_mutex_lock(&task_thread_lock); if (TAILQ_EMPTY(&task_threads)) task_thread_spawn(&tt); @@ -97,6 +97,8 @@ kore_task_bind_request(struct kore_task *t, struct http_request *req) t->req = req; req->task = t; req->flags |= HTTP_REQUEST_SLEEPING; + + kore_platform_schedule_read(t->fds[0], t); } void