]> git.ipfire.org Git - thirdparty/openwrt.git/commitdiff
ucode-mod-uline: re-introduce polling loop to fix prompt after line end 18529/head
authorFelix Fietkau <nbd@nbd.name>
Wed, 7 May 2025 15:21:38 +0000 (17:21 +0200)
committerFelix Fietkau <nbd@nbd.name>
Wed, 7 May 2025 15:22:56 +0000 (17:22 +0200)
Introduce a check for the resource data in order to avoid segfaulting
on exit

Signed-off-by: Felix Fietkau <nbd@nbd.name>
package/utils/ucode-mod-uline/src/ucode.c

index 7d7753a6d858853620be98138790d5571fa84af6..bf53a636ed2957e247e4051e10352b6755cfad70 100644 (file)
@@ -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)
 {
        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;
 
-       uline_poll(&us->s);
+       while (!uloop_cancelled && ucv_resource_data(res, NULL) && us->poll_cb) {
+               uline_poll(&us->s);
 
-       val = us->line;
-       if (!val)
-               return;
+               val = us->line;
+               if (!val)
+                       break;
 
-       us->line = NULL;
-       if (!ucv_is_callable(us->poll_cb))
-               return;
+               us->line = NULL;
+               if (!ucv_is_callable(us->poll_cb))
+                       break;
 
-       uc_vm_stack_push(us->vm, ucv_get(us->res));
-       uc_vm_stack_push(us->vm, ucv_get(us->poll_cb));
-       cb_call(us, 1, val);
+               uc_vm_stack_push(us->vm, ucv_get(res));
+               uc_vm_stack_push(us->vm, ucv_get(us->poll_cb));
+               cb_call(us, 1, val);
+       }
+       ucv_put(res);
 }
 
 static bool