Add the actual task changes for last commit.

This commit is contained in:
Joris Vink 2015-07-01 11:03:54 +02:00
parent cf94a53be7
commit d8508f4a7b
3 changed files with 22 additions and 3 deletions

View File

@ -18,8 +18,8 @@ Test:
Hit the connect button to open a websocket session.
Now connect a writer endpoint to the named pipe (/tmp/pipe), a great
test is tcpdump, you should see all output scroll on the browser.
Now connect a writer endpoint to the named pipe (/tmp/pipe):
$ echo "hello" > /tmp/pipe
# tcpdump -l -i interface -n > /tmp/pipe
You should see the result in your browser.
```

View File

@ -41,6 +41,7 @@ struct kore_task {
struct http_request *req;
int fds[2];
int (*entry)(struct kore_task *);
void (*cb)(struct kore_task *);
struct kore_task_thread *thread;
@ -67,6 +68,8 @@ void kore_task_handle(struct kore_task *, int);
void kore_task_bind_request(struct kore_task *,
struct http_request *);
void kore_task_bind_callback(struct kore_task *,
void (*cb)(struct kore_task *));
void kore_task_create(struct kore_task *,
int (*entry)(struct kore_task *));

View File

@ -55,6 +55,7 @@ kore_task_init(void)
void
kore_task_create(struct kore_task *t, int (*entry)(struct kore_task *))
{
t->cb = NULL;
t->req = NULL;
t->entry = entry;
t->type = KORE_TYPE_TASK;
@ -95,12 +96,24 @@ kore_task_bind_request(struct kore_task *t, struct http_request *req)
{
kore_debug("kore_task_bind_request: %p bound to %p", req, t);
if (t->cb != NULL)
fatal("cannot bind cbs and requests at the same time");
t->req = req;
LIST_INSERT_HEAD(&(req->tasks), t, rlist);
http_request_sleep(req);
}
void
kore_task_bind_callback(struct kore_task *t, void (*cb)(struct kore_task *))
{
if (t->req != NULL)
fatal("cannot bind requests and cbs at the same time");
t->cb = cb;
}
void
kore_task_destroy(struct kore_task *t)
{
@ -196,6 +209,9 @@ kore_task_handle(struct kore_task *t, int finished)
kore_task_destroy(t);
}
}
if (t->cb != NULL)
t->cb(t);
}
int