[OpenWrt-Devel] Question about run more than once ubus_invoke_async in the sametime

Tuan Nguyen tuan.nguyen at veriksystems.com
Thu Sep 10 06:44:16 EDT 2015


Hi,

Following this thread:
https://lists.openwrt.org/pipermail/openwrt-devel/2015-April/032335.html

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

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,
    INIT_LIST_HEAD(&req->list);
    INIT_LIST_HEAD(&req->pending);
    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
work.

How could I do that?

Thanks
Tuan Nguyen
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.infradead.org/pipermail/openwrt-devel/attachments/20150910/84e44562/attachment.htm>
-------------- next part --------------
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


More information about the openwrt-devel mailing list