ubusd: fix incomplete copy of shared buf during queue-ing
For a shared ubus_msg_buf, the ubus_msg_ref function will create a copy for queue-ing. Problem is, that during the dequeue (especially) in client_cb, the header is 0-ed (because it's was a newly alloc-ed buffer). And during ubus_msg_writev(), the header info will be ignored by the client. Signed-off-by: Alexandru Ardelean <ardeleanalex@gmail.com>
This commit is contained in:
parent
91acde66b9
commit
c09e4f06f0
1 changed files with 9 additions and 2 deletions
11
ubusd.c
11
ubusd.c
|
@ -32,8 +32,15 @@
|
||||||
|
|
||||||
static struct ubus_msg_buf *ubus_msg_ref(struct ubus_msg_buf *ub)
|
static struct ubus_msg_buf *ubus_msg_ref(struct ubus_msg_buf *ub)
|
||||||
{
|
{
|
||||||
if (ub->refcount == ~0)
|
struct ubus_msg_buf *new_ub;
|
||||||
return ubus_msg_new(ub->data, ub->len, false);
|
if (ub->refcount == ~0) {
|
||||||
|
new_ub = ubus_msg_new(ub->data, ub->len, false);
|
||||||
|
if (!new_ub)
|
||||||
|
return NULL;
|
||||||
|
memcpy(&new_ub->hdr, &ub->hdr, sizeof(struct ubus_msghdr));
|
||||||
|
new_ub->fd = ub->fd;
|
||||||
|
return new_ub;
|
||||||
|
}
|
||||||
|
|
||||||
ub->refcount++;
|
ub->refcount++;
|
||||||
return ub;
|
return ub;
|
||||||
|
|
Loading…
Reference in a new issue