libubus: fix publishing objects after reconnect
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
This commit is contained in:
parent
2b4fc4c916
commit
62bfc16a09
1 changed files with 8 additions and 3 deletions
11
libubus-io.c
11
libubus-io.c
|
@ -190,6 +190,8 @@ static void
|
||||||
ubus_refresh_state(struct ubus_context *ctx)
|
ubus_refresh_state(struct ubus_context *ctx)
|
||||||
{
|
{
|
||||||
struct ubus_object *obj, *tmp;
|
struct ubus_object *obj, *tmp;
|
||||||
|
struct ubus_object **objs;
|
||||||
|
int n, i = 0;
|
||||||
|
|
||||||
/* clear all type IDs, they need to be registered again */
|
/* clear all type IDs, they need to be registered again */
|
||||||
avl_for_each_element(&ctx->objects, obj, avl)
|
avl_for_each_element(&ctx->objects, obj, avl)
|
||||||
|
@ -197,11 +199,14 @@ ubus_refresh_state(struct ubus_context *ctx)
|
||||||
obj->type->id = 0;
|
obj->type->id = 0;
|
||||||
|
|
||||||
/* push out all objects again */
|
/* push out all objects again */
|
||||||
avl_for_each_element_safe(&ctx->objects, obj, avl, tmp) {
|
objs = alloca(ctx->objects.count * sizeof(*objs));
|
||||||
|
avl_remove_all_elements(&ctx->objects, obj, avl, tmp) {
|
||||||
|
objs[i++] = obj;
|
||||||
obj->id = 0;
|
obj->id = 0;
|
||||||
avl_delete(&ctx->objects, &obj->avl);
|
|
||||||
ubus_add_object(ctx, obj);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (n = i, i = 0; i < n; i++)
|
||||||
|
ubus_add_object(ctx, objs[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
int ubus_reconnect(struct ubus_context *ctx, const char *path)
|
int ubus_reconnect(struct ubus_context *ctx, const char *path)
|
||||||
|
|
Loading…
Add table
Reference in a new issue