[OpenWrt-Devel] Question about conflict between ubus_invoke and uloop_run

XiaoFengMeng xiaofeng.meng at pfsw.com
Thu Apr 2 22:24:11 EDT 2015


HI !
I am Kevin and learning the ubus code and got something that is confusing me very much in the code.

My question is regarding code in  ubus_invoke -> ubus_complete_request,

I can see that there are lots of uloop related code in  "ubus_complete_request"
if (!registered) {
                                uloop_init();
                                ubus_add_uloop(ctx);
}
....
while (!req->status_msg) {
                                bool cancelled = uloop_cancelled;

                                uloop_cancelled = false;
                                if (req_timeout) {
                                                timeout = time_end - get_time_msec();
                                                if (timeout <= 0) {
                                                                ubus_set_req_status(req, UBUS_STATUS_TIMEOUT);
                                                                break;
                                                }
                                }
                                ubus_poll_data(ctx, (unsigned int) timeout);

                                uloop_cancelled = cancelled;
                }

My question is why is uloop involved here?  uloop could be working in another thread and also listen on the same socket.
I idea that, before the ubus_invoke sends the request messge, it should disable the uloop for the current socket, so that code in uloop_run will not receive anything from the same socket.

Because after calling ubus_add_uloop(ctx), the uloop_run could also be receiving the response data
And this function could cause the uloop_run to quit the while loop.
How should I understand the logic here?

And How should I do if I want to call ubus_invoke as a client and use uloop_run as a server at  the same process?

Thanks very much!

Best regards
Kevin

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.infradead.org/pipermail/openwrt-devel/attachments/20150403/f935abbd/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