ucode-mod-uline: re-introduce polling loop to fix prompt after line end
Introduce a check for the resource data in order to avoid segfaulting on exit Signed-off-by: Felix Fietkau <nbd@nbd.name>
This commit is contained in:
parent
840c1fda83
commit
0b4ddeed5e
1 changed files with 14 additions and 10 deletions
|
@ -368,21 +368,25 @@ uc_uline_cb_event(struct uline_state *s, enum uline_event ev)
|
||||||
static void uc_uline_poll_cb(struct uloop_fd *fd, unsigned int events)
|
static void uc_uline_poll_cb(struct uloop_fd *fd, unsigned int events)
|
||||||
{
|
{
|
||||||
struct uc_uline_state *us = container_of(fd, struct uc_uline_state, fd);
|
struct uc_uline_state *us = container_of(fd, struct uc_uline_state, fd);
|
||||||
|
uc_value_t *res = ucv_get(us->res);
|
||||||
uc_value_t *val;
|
uc_value_t *val;
|
||||||
|
|
||||||
uline_poll(&us->s);
|
while (!uloop_cancelled && ucv_resource_data(res, NULL) && us->poll_cb) {
|
||||||
|
uline_poll(&us->s);
|
||||||
|
|
||||||
val = us->line;
|
val = us->line;
|
||||||
if (!val)
|
if (!val)
|
||||||
return;
|
break;
|
||||||
|
|
||||||
us->line = NULL;
|
us->line = NULL;
|
||||||
if (!ucv_is_callable(us->poll_cb))
|
if (!ucv_is_callable(us->poll_cb))
|
||||||
return;
|
break;
|
||||||
|
|
||||||
uc_vm_stack_push(us->vm, ucv_get(us->res));
|
uc_vm_stack_push(us->vm, ucv_get(res));
|
||||||
uc_vm_stack_push(us->vm, ucv_get(us->poll_cb));
|
uc_vm_stack_push(us->vm, ucv_get(us->poll_cb));
|
||||||
cb_call(us, 1, val);
|
cb_call(us, 1, val);
|
||||||
|
}
|
||||||
|
ucv_put(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
|
|
Loading…
Reference in a new issue