forked from mirrors/kore
Add the actual task changes for last commit.
This commit is contained in:
parent
cf94a53be7
commit
d8508f4a7b
|
@ -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.
|
||||
```
|
||||
|
|
|
@ -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 *));
|
||||
|
||||
|
|
16
src/tasks.c
16
src/tasks.c
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue