If the "logread" process is blocked in write call or stopped by
pressing "CTRL+Z", the logd starts to buffer all the messages in
the write buffer. Since currently there is no limit in ustream
w.max_buffers, the logd consumes all the system memory and at a
point of time which triggers Out Of Memory.
The ustream write max_buffer of logd is limited with value 4096.

Similar ticket has been reported in,
https://github.com/openwrt/packages/issues/5604

Signed-off-by: Gokulnathan Matta Raja <gokul...@gmail.com>
---
 log/logd.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/log/logd.c b/log/logd.c
index 5d6c458..6ca4a2b 100644
--- a/log/logd.c
+++ b/log/logd.c
@@ -130,6 +130,8 @@ read_log(struct ubus_context *ctx, struct ubus_object *obj,
                cl->s.stream.notify_state = client_notify_state;
                cl->fd = fds[1];
                ustream_fd_init(&cl->s, cl->fd);
+               /* Limit the ustream write max_buffers to avoid infinite memory 
consumption when no logread happens */
+               cl->s.stream.w.max_buffers = 4096;
                list_add(&cl->list, &clients);
                while ((!tb[READ_LINES] || count) && l) {
                        blob_buf_init(&b, 0);
-- 
2.25.1


_______________________________________________
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel

Reply via email to