remove the "method" argument for object subscription
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
This commit is contained in:
parent
a69f062cbd
commit
0fccce4445
4 changed files with 8 additions and 14 deletions
|
@ -41,15 +41,13 @@ int ubus_register_subscriber(struct ubus_context *ctx, struct ubus_subscriber *s
|
|||
}
|
||||
|
||||
static int
|
||||
__ubus_subscribe_request(struct ubus_context *ctx, struct ubus_object *obj, uint32_t id, const char *method, int type)
|
||||
__ubus_subscribe_request(struct ubus_context *ctx, struct ubus_object *obj, uint32_t id, int type)
|
||||
{
|
||||
struct ubus_request req;
|
||||
|
||||
blob_buf_init(&b, 0);
|
||||
blob_put_int32(&b, UBUS_ATTR_OBJID, obj->id);
|
||||
blob_put_int32(&b, UBUS_ATTR_TARGET, id);
|
||||
if (method)
|
||||
blob_put_string(&b, UBUS_ATTR_METHOD, method);
|
||||
|
||||
if (ubus_start_request(ctx, &req, b.head, type, 0) < 0)
|
||||
return UBUS_STATUS_INVALID_ARGUMENT;
|
||||
|
@ -60,12 +58,12 @@ __ubus_subscribe_request(struct ubus_context *ctx, struct ubus_object *obj, uint
|
|||
|
||||
int ubus_subscribe(struct ubus_context *ctx, struct ubus_subscriber *obj, uint32_t id)
|
||||
{
|
||||
return __ubus_subscribe_request(ctx, &obj->obj, id, "event", UBUS_MSG_SUBSCRIBE);
|
||||
return __ubus_subscribe_request(ctx, &obj->obj, id, UBUS_MSG_SUBSCRIBE);
|
||||
}
|
||||
|
||||
int ubus_unsubscribe(struct ubus_context *ctx, struct ubus_subscriber *obj, uint32_t id)
|
||||
{
|
||||
return __ubus_subscribe_request(ctx, &obj->obj, id, NULL, UBUS_MSG_UNSUBSCRIBE);
|
||||
return __ubus_subscribe_request(ctx, &obj->obj, id, UBUS_MSG_UNSUBSCRIBE);
|
||||
}
|
||||
|
||||
void __hidden ubus_process_unsubscribe(struct ubus_context *ctx, struct ubus_msghdr *hdr)
|
||||
|
|
|
@ -164,12 +164,12 @@ free:
|
|||
return NULL;
|
||||
}
|
||||
|
||||
void ubus_subscribe(struct ubus_object *obj, struct ubus_object *target, const char *method)
|
||||
void ubus_subscribe(struct ubus_object *obj, struct ubus_object *target)
|
||||
{
|
||||
struct ubus_subscription *s;
|
||||
bool first = list_empty(&target->subscribers);
|
||||
|
||||
s = calloc(1, sizeof(*s) + strlen(method) + 1);
|
||||
s = calloc(1, sizeof(*s));
|
||||
if (!s)
|
||||
return;
|
||||
|
||||
|
@ -177,7 +177,6 @@ void ubus_subscribe(struct ubus_object *obj, struct ubus_object *target, const c
|
|||
s->target = target;
|
||||
list_add(&s->list, &target->subscribers);
|
||||
list_add(&s->target_list, &obj->target_list);
|
||||
strcpy(s->method, method);
|
||||
|
||||
if (first)
|
||||
ubus_notify_subscription(target);
|
||||
|
|
|
@ -38,7 +38,6 @@ struct ubus_method {
|
|||
struct ubus_subscription {
|
||||
struct list_head list, target_list;
|
||||
struct ubus_object *subscriber, *target;
|
||||
char method[];
|
||||
};
|
||||
|
||||
struct ubus_object {
|
||||
|
@ -76,7 +75,7 @@ static inline struct ubus_object *ubusd_find_object(uint32_t objid)
|
|||
return obj;
|
||||
}
|
||||
|
||||
void ubus_subscribe(struct ubus_object *obj, struct ubus_object *target, const char *method);
|
||||
void ubus_subscribe(struct ubus_object *obj, struct ubus_object *target);
|
||||
void ubus_unsubscribe(struct ubus_subscription *s);
|
||||
void ubus_notify_unsubscribe(struct ubus_subscription *s);
|
||||
void ubus_notify_subscription(struct ubus_object *obj);
|
||||
|
|
|
@ -289,10 +289,8 @@ static int ubusd_handle_add_watch(struct ubus_client *cl, struct ubus_msg_buf *u
|
|||
{
|
||||
struct ubus_object *obj, *target;
|
||||
|
||||
if (!attr[UBUS_ATTR_OBJID] || !attr[UBUS_ATTR_TARGET] ||
|
||||
!attr[UBUS_ATTR_METHOD]) {
|
||||
if (!attr[UBUS_ATTR_OBJID] || !attr[UBUS_ATTR_TARGET])
|
||||
return UBUS_STATUS_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
obj = ubusd_find_object(blob_get_u32(attr[UBUS_ATTR_OBJID]));
|
||||
if (!obj)
|
||||
|
@ -308,7 +306,7 @@ static int ubusd_handle_add_watch(struct ubus_client *cl, struct ubus_msg_buf *u
|
|||
if (cl == target->client)
|
||||
return UBUS_STATUS_INVALID_ARGUMENT;
|
||||
|
||||
ubus_subscribe(obj, target, blob_data(attr[UBUS_ATTR_METHOD]));
|
||||
ubus_subscribe(obj, target);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue