Add ubus_auto_shutdown function, which ensures any pending uloop_timer is cancelled before calling ubus_shutdown on the context.
This avoids a condition where ubus_shutdown() is called during ubus_auto_connect attempting a reconnection.
Signed-off-by: Ben Kelly <ben@benjii.net>
At the moment, we do our own null checks before calling ubus_free().
The likely-hood of 'ctx' being null (in ubus_free()) is low,
but since free() handles null, might make sense for ubus_free() to do so as well.
Signed-off-by: Alexandru Ardelean <ardeleanalex@gmail.com>
As the man page explains:
"Specifying a timeout of zero causes poll() to return immediately,
even if no file descriptors are ready."
The use of 0 as timeout could cause libubus to busy loop if the
socket was non-blocking. For blocking sockets, this was less
apparent as the subsequent read() would then block.
Signed-off-by: Karl Vogel <karl.vogel@gmail.com>
Append ubus notification messages to the tail of the pending list
so they're processed in the order as they're put onto the pending list
Signed-off-by: Xinxing Hu <xinxing.huchn@gmail.com>
Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
The value from getglobal wasn't being removed from the stack,
resulting in an ever growing stack in the ubus event handler.
Signed-off-by: Karl Vogel <karl.vogel@gmail.com>
Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
ubus_connect_ctx() is equivalent to ubus_connect() but accepts a
pointer to a previously allocated ubus_context struct.
ubus_shutdown() is made available as an alternative to ubus_free()
to clean up contexts initialised by ubus_connect_ctx().
Signed-off-by: Delio Brignoli <dbrignoli@audioscience.com>
This fixes build warning:
/ubus.git/examples/server.c: In function 'test_hello_reply':
/ubus.git/examples/server.c:69:6: error: ignoring return value of 'pipe', declared with attribute warn_unused_result [-Werror=unused-result]
Signed-off-by: Zefir Kurtisi <zefir.kurtisi@neratec.com>
__init has a naming collision with C++ and prevents ubus_common.h
from being included. Instead, use __constructor as defined from
libubox.
Signed-off-by: Zefir Kurtisi <zefir.kurtisi@neratec.com>
Context: 1 loop with a single ubus_invoke() that times out calls
uloop_end() which ends the loop, and thus ends the application.
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Set ctx->msgbuf.data to NULL during the call. If ctx->msgbuf is needed
during the call, a new buffer will be allocated. If not,
ctx->msgbuf.data is restored to the previous value afterwards
Signed-off-by: Felix Fietkau <nbd@openwrt.org>