libubox: How to terminate uloop orderly?

Koch, Alexander akoch at initse.com
Thu May 19 22:49:52 PDT 2022


Hi Peter,
Hi Aledandru,

thank you very much for your comments. You made me realize that I actually don't
need any uloop related functionality in the first place, as I've already created
my own event loop.

So my solution is to have the main loop for my ubus thread periodically call
`ubus_handle_event()` until program termination is requested:

    void *ubus_thread_main(void *arg)
    {
        while (threads_run) {
            ubus_handle_event(ctx);
            usleep(UBUS_THREAD_DELAY_US);
        }
        ubus_free(ctx);
    }


Works like a charm.


Best regards,

Alex




More information about the openwrt-devel mailing list