ubusd_monitor: alloc & free the buffer outside of the loop
Should save a few cycles, since the data that's being changed is only the seq number. And the `ub` is always created as shared. Signed-off-by: Alexandru Ardelean <ardeleanalex@gmail.com>
This commit is contained in:
parent
be146ad2bc
commit
27d712d394
1 changed files with 5 additions and 3 deletions
|
@ -72,13 +72,15 @@ ubusd_monitor_message(struct ubus_client *cl, struct ubus_msg_buf *ub, bool send
|
||||||
blob_put_int8(&mb, UBUS_MONITOR_SEND, send);
|
blob_put_int8(&mb, UBUS_MONITOR_SEND, send);
|
||||||
blob_put(&mb, UBUS_MONITOR_DATA, blob_data(ub->data), blob_len(ub->data));
|
blob_put(&mb, UBUS_MONITOR_DATA, blob_data(ub->data), blob_len(ub->data));
|
||||||
|
|
||||||
|
ub = ubus_msg_new(mb.head, blob_raw_len(mb.head), true);
|
||||||
|
ub->hdr.type = UBUS_MSG_MONITOR;
|
||||||
|
|
||||||
list_for_each_entry(m, &monitors, list) {
|
list_for_each_entry(m, &monitors, list) {
|
||||||
ub = ubus_msg_new(mb.head, blob_raw_len(mb.head), true);
|
|
||||||
ub->hdr.type = UBUS_MSG_MONITOR;
|
|
||||||
ub->hdr.seq = ++m->seq;
|
ub->hdr.seq = ++m->seq;
|
||||||
ubus_msg_send(m->cl, ub);
|
ubus_msg_send(m->cl, ub);
|
||||||
ubus_msg_free(ub);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ubus_msg_free(ub);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
|
Loading…
Reference in a new issue