projects
/
project
/
ubus.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
fix message buffering
[project/ubus.git]
/
ubusd_proto.c
diff --git
a/ubusd_proto.c
b/ubusd_proto.c
index
99d6691
..
3333330
100644
(file)
--- a/
ubusd_proto.c
+++ b/
ubusd_proto.c
@@
-58,14
+58,14
@@
bool ubusd_send_hello(struct ubus_client *cl)
return false;
ubus_msg_init(ub, UBUS_MSG_HELLO, 0, cl->id.id);
return false;
ubus_msg_init(ub, UBUS_MSG_HELLO, 0, cl->id.id);
- ubus_msg_send(cl, ub);
+ ubus_msg_send(cl, ub
, true
);
return true;
}
static int ubusd_send_pong(struct ubus_client *cl, struct ubus_msg_buf *ub, struct blob_attr **attr)
{
ub->hdr.type = UBUS_MSG_DATA;
return true;
}
static int ubusd_send_pong(struct ubus_client *cl, struct ubus_msg_buf *ub, struct blob_attr **attr)
{
ub->hdr.type = UBUS_MSG_DATA;
- ubus_msg_send(cl, ub
us_msg_ref(ub)
);
+ ubus_msg_send(cl, ub
, false
);
return 0;
}
return 0;
}
@@
-86,7
+86,7
@@
static int ubusd_handle_publish(struct ubus_client *cl, struct ubus_msg_buf *ub,
if (!ub)
return UBUS_STATUS_NO_DATA;
if (!ub)
return UBUS_STATUS_NO_DATA;
- ubus_msg_send(cl, ub);
+ ubus_msg_send(cl, ub
, true
);
return 0;
}
return 0;
}
@@
-100,6
+100,7
@@
static void ubusd_send_obj(struct ubus_client *cl, struct ubus_msg_buf *ub, stru
if (obj->path.key)
blob_put_string(&b, UBUS_ATTR_OBJPATH, obj->path.key);
blob_put_int32(&b, UBUS_ATTR_OBJID, obj->id.id);
if (obj->path.key)
blob_put_string(&b, UBUS_ATTR_OBJPATH, obj->path.key);
blob_put_int32(&b, UBUS_ATTR_OBJID, obj->id.id);
+ blob_put_int32(&b, UBUS_ATTR_OBJTYPE, obj->type->id.id);
s = blob_nest_start(&b, UBUS_ATTR_SIGNATURE);
list_for_each_entry(m, &obj->type->methods, list)
s = blob_nest_start(&b, UBUS_ATTR_SIGNATURE);
list_for_each_entry(m, &obj->type->methods, list)
@@
-110,7
+111,7
@@
static void ubusd_send_obj(struct ubus_client *cl, struct ubus_msg_buf *ub, stru
if (!ub)
return;
if (!ub)
return;
- ubus_msg_send(cl, ub);
+ ubus_msg_send(cl, ub
, true
);
}
static int ubusd_handle_lookup(struct ubus_client *cl, struct ubus_msg_buf *ub, struct blob_attr **attr)
}
static int ubusd_handle_lookup(struct ubus_client *cl, struct ubus_msg_buf *ub, struct blob_attr **attr)
@@
-175,6
+176,10
@@
static int ubusd_handle_invoke(struct ubus_client *cl, struct ubus_msg_buf *ub,
obj = container_of(id, struct ubus_object, id);
method = blob_data(attr[UBUS_ATTR_METHOD]);
obj = container_of(id, struct ubus_object, id);
method = blob_data(attr[UBUS_ATTR_METHOD]);
+
+ if (!obj->client)
+ return obj->recv_msg(cl, method, attr[UBUS_ATTR_DATA]);
+
blob_buf_init(&b, 0);
blob_put_int32(&b, UBUS_ATTR_OBJID, obj->id.id);
blob_put_string(&b, UBUS_ATTR_METHOD, method);
blob_buf_init(&b, 0);
blob_put_int32(&b, UBUS_ATTR_OBJID, obj->id.id);
blob_put_string(&b, UBUS_ATTR_METHOD, method);
@@
-190,7
+195,7
@@
static int ubusd_handle_invoke(struct ubus_client *cl, struct ubus_msg_buf *ub,
ub->hdr.type = UBUS_MSG_INVOKE;
ub->hdr.peer = cl->id.id;
ub->hdr.type = UBUS_MSG_INVOKE;
ub->hdr.peer = cl->id.id;
- ubus_msg_send(obj->client, ub);
+ ubus_msg_send(obj->client, ub
, true
);
return -1;
}
return -1;
}
@@
-198,18
+203,16
@@
static int ubusd_handle_invoke(struct ubus_client *cl, struct ubus_msg_buf *ub,
static int ubusd_handle_response(struct ubus_client *cl, struct ubus_msg_buf *ub, struct blob_attr **attr)
{
struct ubus_object *obj;
static int ubusd_handle_response(struct ubus_client *cl, struct ubus_msg_buf *ub, struct blob_attr **attr)
{
struct ubus_object *obj;
- struct ubus_id *id;
if (!attr[UBUS_ATTR_OBJID] ||
(ub->hdr.type == UBUS_MSG_STATUS && !attr[UBUS_ATTR_STATUS]) ||
(ub->hdr.type == UBUS_MSG_DATA && !attr[UBUS_ATTR_DATA]))
goto error;
if (!attr[UBUS_ATTR_OBJID] ||
(ub->hdr.type == UBUS_MSG_STATUS && !attr[UBUS_ATTR_STATUS]) ||
(ub->hdr.type == UBUS_MSG_DATA && !attr[UBUS_ATTR_DATA]))
goto error;
-
id = ubus_find_id(&objects,
blob_get_int32(attr[UBUS_ATTR_OBJID]));
- if (!
id
)
+
obj = ubusd_find_object(
blob_get_int32(attr[UBUS_ATTR_OBJID]));
+ if (!
obj
)
goto error;
goto error;
- obj = container_of(id, struct ubus_object, id);
if (cl != obj->client)
goto error;
if (cl != obj->client)
goto error;
@@
-218,7
+221,7
@@
static int ubusd_handle_response(struct ubus_client *cl, struct ubus_msg_buf *ub
goto error;
ub->hdr.peer = blob_get_int32(attr[UBUS_ATTR_OBJID]);
goto error;
ub->hdr.peer = blob_get_int32(attr[UBUS_ATTR_OBJID]);
- ubus_msg_send(cl, ub);
+ ubus_msg_send(cl, ub
, true
);
return -1;
error:
return -1;
error:
@@
-257,7
+260,7
@@
void ubusd_receive_message(struct ubus_client *cl, struct ubus_msg_buf *ub)
ubus_msg_free(ub);
*retmsg_data = htonl(ret);
ubus_msg_free(ub);
*retmsg_data = htonl(ret);
- ubus_msg_send(cl,
ubus_msg_ref(retmsg)
);
+ ubus_msg_send(cl,
retmsg, false
);
}
static void __init ubusd_proto_init(void)
}
static void __init ubusd_proto_init(void)