diff options
author | Ben Kelly <ben@benjii.net> | 2016-02-02 15:02:59 +0200 |
---|---|---|
committer | Felix Fietkau <nbd@openwrt.org> | 2016-02-07 14:24:28 +0100 |
commit | 6a86e65f7d4836bfe387d213a6dfaea1d5d162dd (patch) | |
tree | 40d427cc80ad11a47b646aac51dd61dcbe1814df | |
parent | 619f3a160de4f417226b69039538882787b3811c (diff) | |
download | ubus-6a86e65f7d4836bfe387d213a6dfaea1d5d162dd.tar.gz |
libubus.h: add ubus_auto_shutdown()
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>
-rw-r--r-- | libubus.h | 6 |
1 files changed, 6 insertions, 0 deletions
@@ -240,6 +240,12 @@ void ubus_free(struct ubus_context *ctx); /* call this only for struct ubus_context pointers initialised by ubus_connect_ctx() */ void ubus_shutdown(struct ubus_context *ctx); +static inline void ubus_auto_shutdown(struct ubus_auto_conn *conn) +{ + uloop_timeout_cancel(&conn->timer); + ubus_shutdown(&conn->ctx); +} + const char *ubus_strerror(int error); static inline void ubus_add_uloop(struct ubus_context *ctx) |