summaryrefslogtreecommitdiff
path: root/log
diff options
context:
space:
mode:
authorLuka Perkov <luka@openwrt.org>2015-04-21 19:04:46 +0200
committerJohn Crispin <blogic@openwrt.org>2015-05-14 06:25:52 +0200
commitab5b47397cc143798ba2f367f04579e5b5b82070 (patch)
tree5085c7d087488bf46ffa619ee477e1d592cc8e03 /log
parent7ef8dda5115d8a2c1157c0438af710c555f40b32 (diff)
downloadubox-ab5b47397cc143798ba2f367f04579e5b5b82070.tar.gz
logd: optimize notify function
No need to construct every time the same blob_buf for each client in the list. Signed-off-by: Luka Perkov <luka@openwrt.org>
Diffstat (limited to 'log')
-rw-r--r--log/logd.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/log/logd.c b/log/logd.c
index a4335ea..27d3cac 100644
--- a/log/logd.c
+++ b/log/logd.c
@@ -147,15 +147,17 @@ ubus_notify_log(struct log_head *l)
if (list_empty(&clients))
return;
- list_for_each_entry(c, &clients, list) {
- blob_buf_init(&b, 0);
- blobmsg_add_string(&b, "msg", l->data);
- blobmsg_add_u32(&b, "id", l->id);
- blobmsg_add_u32(&b, "priority", l->priority);
- blobmsg_add_u32(&b, "source", l->source);
- blobmsg_add_u64(&b, "time", (((__u64) l->ts.tv_sec) * 1000) + (l->ts.tv_nsec / 1000000));
+ blob_buf_init(&b, 0);
+ blobmsg_add_string(&b, "msg", l->data);
+ blobmsg_add_u32(&b, "id", l->id);
+ blobmsg_add_u32(&b, "priority", l->priority);
+ blobmsg_add_u32(&b, "source", l->source);
+ blobmsg_add_u64(&b, "time", (((__u64) l->ts.tv_sec) * 1000) + (l->ts.tv_nsec / 1000000));
+
+ list_for_each_entry(c, &clients, list)
ustream_write(&c->s.stream, (void *) b.head, blob_len(b.head) + sizeof(struct blob_attr), false);
- }
+
+ blob_buf_free(&b);
}
static void