[OpenWrt-Devel] how to use ubus_invoke_async parallels with once callback

Tuan Nguyen tuan.nguyen at veriksystems.com
Thu Sep 10 10:48:19 EDT 2015


Following this thread:

I know how to use ubus with threading by call ubus_invoke_async() instead

In ubus example:
    static struct ubus_request req;
    ubus_invoke_async(ctx, id, "hello", b.head, &req);
    req.fd_cb = test_client_fd_cb;
    req.complete_cb = test_client_complete_cb;
    ubus_complete_request_async(ctx, &req);

We need to create a ubus_request to register callbacks and maybe more data
for this callback.

My question is how to call ubus_invoke_async() many times with one callback
for this function.
When I tried this with the same struct ubus_request and I got lost
callback, then I tried to malloc this struct and It worked well, but I dont
know how to free this struct.

Digging in to source code:
I found this struct will be assign to the main context,
    req->ctx = ctx;
    req->peer = peer;
    req->seq = ++ctx->request_seq;

I tried to do req->ctx= NULL; and free it in callback function but i didn't

How could I do that?

Tuan Nguyen
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.infradead.org/pipermail/openwrt-devel/attachments/20150910/183497f3/attachment.htm>
-------------- next part --------------
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org

More information about the openwrt-devel mailing list