<div dir="ltr"><div>Hi,<br><br></div><div>Following this thread: <a href="https://lists.openwrt.org/pipermail/openwrt-devel/2015-April/032335.html" target="_blank">https://lists.openwrt.org/pipermail/openwrt-devel/2015-April/032335.html</a><br><br></div><div>I know how to use ubus with threading by call ubus_invoke_async() instead ubus_invoke().<br><br></div><div>In ubus example: <br>    static struct ubus_request req;<br>    ubus_invoke_async(ctx, id, "hello", b.head, &req);<br>    req.fd_cb = test_client_fd_cb;<br>    req.complete_cb = test_client_complete_cb;<br>    ubus_complete_request_async(ctx, &req);<br></div><div><br></div><div>We need to create a ubus_request to register callbacks and maybe more data for this callback.<br><br></div><div>My question is how to call ubus_invoke_async() many times with one callback for this function.<br></div><div>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.<br><br></div><div>Digging in to source code:<br></div><div>I found this struct will be assign to the main context, <br>    INIT_LIST_HEAD(&req->list);<br>    INIT_LIST_HEAD(&req->pending);<br>    req->ctx = ctx;<br>    req->peer = peer;<br>    req->seq = ++ctx->request_seq;<br><br>I tried to do req->ctx= NULL; and free it in callback function but i didn't work.<br><br></div><div>How could I do that?<br></div><div><br></div>Thanks<div class="gmail_extra">Tuan Nguyen<br></div></div>