X-Git-Url: http://git.archive.openwrt.org/?p=project%2Fubus.git;a=blobdiff_plain;f=ubusd_obj.c;h=d1e53f8fb4f5c3cebd56e8eb1e165afaca7f35e1;hp=a6be1823252cfb294b5128b777ecaf43a3e864d2;hb=cb1feedb5e1388d7aea8bddef1284690c590874f;hpb=fa989780bda3ad10fcbb637390d59afe2b32ba81 diff --git a/ubusd_obj.c b/ubusd_obj.c index a6be182..d1e53f8 100644 --- a/ubusd_obj.c +++ b/ubusd_obj.c @@ -98,6 +98,7 @@ struct ubus_object *ubusd_create_object_internal(struct ubus_object_type *type, obj->type = type; INIT_LIST_HEAD(&obj->list); + INIT_LIST_HEAD(&obj->events); if (type) type->refcount++; @@ -114,15 +115,16 @@ struct ubus_object *ubusd_create_object(struct ubus_client *cl, struct blob_attr struct ubus_object_type *type = NULL; if (attr[UBUS_ATTR_OBJTYPE]) - type = ubus_get_obj_type(blob_get_int32(attr[UBUS_ATTR_OBJTYPE])); + type = ubus_get_obj_type(blob_get_u32(attr[UBUS_ATTR_OBJTYPE])); else if (attr[UBUS_ATTR_SIGNATURE]) type = ubus_create_obj_type(attr[UBUS_ATTR_SIGNATURE]); - if (!type) + if (!!type ^ !!attr[UBUS_ATTR_OBJPATH]) return NULL; obj = ubusd_create_object_internal(type, 0); - ubus_unref_object_type(type); + if (type) + ubus_unref_object_type(type); if (!obj) return NULL; @@ -141,6 +143,7 @@ struct ubus_object *ubusd_create_object(struct ubus_client *cl, struct blob_attr obj->client = cl; list_add(&obj->list, &cl->objects); + return obj; free: @@ -150,6 +153,7 @@ free: void ubusd_free_object(struct ubus_object *obj) { + ubusd_event_cleanup_object(obj); if (obj->path.key) { avl_delete(&path, &obj->path); free(obj->path.key);