From: Felix Fietkau Date: Fri, 14 Dec 2012 12:11:40 +0000 (+0100) Subject: remove the "method" argument for object subscription X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=0fccce4445b1961451ce3d99a99c1c0defbd4490;p=project%2Fubus.git remove the "method" argument for object subscription Signed-off-by: Felix Fietkau --- diff --git a/libubus-sub.c b/libubus-sub.c index 87c8128..ccb4d95 100644 --- a/libubus-sub.c +++ b/libubus-sub.c @@ -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) diff --git a/ubusd_obj.c b/ubusd_obj.c index 69ca8b8..3859c45 100644 --- a/ubusd_obj.c +++ b/ubusd_obj.c @@ -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); diff --git a/ubusd_obj.h b/ubusd_obj.h index 8e80078..a21f47c 100644 --- a/ubusd_obj.h +++ b/ubusd_obj.h @@ -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); diff --git a/ubusd_proto.c b/ubusd_proto.c index 283cb77..2e4c2af 100644 --- a/ubusd_proto.c +++ b/ubusd_proto.c @@ -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; }