This patch fixes a logread starvation error, which occurs after many
logs are generated (around 16k if defaults are used). The log read
process seems to halt silently and yet continues running.  A restart
of the log services fixes it.

This is problematic because logs should be logged, instead of silently lost

Signed-off-by: “Ron Brash <“ron.br...@gmail.com”>
---
 log/logread.c | 24 ++++++++++++++++++++++--
 1 file changed, 22 insertions(+), 2 deletions(-)

diff --git a/log/logread.c b/log/logread.c
index edac1d9..7eb028e 100644
--- a/log/logread.c
+++ b/log/logread.c
@@ -230,8 +230,10 @@ static void logread_fd_data_cb(struct ustream *s,
int bytes)
                        break;

                cur_len = blob_len(a) + sizeof(*a);
-               if (len < cur_len)
+               if (len < cur_len) {
+                       ustream_consume(s, len);
                        break;
+               }

                log_notify(a);
                ustream_consume(s, cur_len);
@@ -240,14 +242,28 @@ static void logread_fd_data_cb(struct ustream
*s, int bytes)
                uloop_end();
 }

+static void notify_fd_remove_cb();
+
 static void logread_fd_cb(struct ubus_request *req, int fd)
 {
        static struct ustream_fd test_fd;
-
+       uloop_register_notify_fd_remove(fd, notify_fd_remove_cb);
        test_fd.stream.notify_read = logread_fd_data_cb;
        ustream_fd_init(&test_fd, fd);
 }

+struct ubus_context *context;
+uint32_t ctx_id;
+struct blob_buf * bb;
+struct ubus_request request;
+
+static void notify_fd_remove_cb() {
+       ubus_lookup_id(context, "log", &ctx_id);
+       ubus_invoke_async(context, ctx_id, "read", bb->head, &request);
+       request.fd_cb = logread_fd_cb;
+       ubus_complete_request_async(context, &request);
+}
+
 int main(int argc, char **argv)
 {
        static struct ubus_request req;
@@ -362,6 +378,9 @@ int main(int argc, char **argv)
                        sender.fd = STDOUT_FILENO;
                }

+               context = ctx;
+               bb = &b;
+
                ubus_invoke_async(ctx, id, "read", b.head, &req);
                req.fd_cb = logread_fd_cb;
                ubus_complete_request_async(ctx, &req);
@@ -374,3 +393,4 @@ int main(int argc, char **argv)

        return ret;
 }
+
--
2.7.4

_______________________________________________
Lede-dev mailing list
Lede-dev@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/lede-dev

Reply via email to