[OpenWrt-Devel] [PATCH] libubus: handle NULL ubus_context in all sync requests by creating a local instance

Felix Fietkau nbd at openwrt.org
Thu Jul 17 12:36:52 EDT 2014


On 2014-07-17 17:25, Alexandru Ardelean wrote:
> This can serve as a convenience for sync requets, since no explicit
> ubus_connect() + ubus_free() need to be done.
> 
> It can also help in cases where there are async + sync requests,
> where one async request is working and sync calls are done.
> Seems to create some weird races, probably because of possible
> concurrent poll() calls on the same fd.
I don't like this approach. If you want to avoid races in your code
between async calls and sync calls, just create a separate context for
sync calls.
Also, allowing NULL to be passed as context creates the illusion that it
is generally sane to do so. In the case of adding/removing objects it
makes no sense and is completely misleading: any object that you add
with the internally allocated ubus context gets deleted as soon as the
context is freed.

- Felix
_______________________________________________
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