[LEDE-DEV] [PATCH ubox] Fix logread starvation

Ron Brash ron.brash at gmail.com
Wed Jul 5 08:01:32 PDT 2017


Hello all,

Here is a repost of the previous concatonated patch.

This patch contains the fix we needed to stop the logger from silently
starving after a number of logs were generated.  It was around the 16K
mark when the daemons would stop writing to the /var/log/messages
file, yet still remain alive.  Restarting the log service would force
a hard fix, but here is the fix we implemented, which worked.

Ron

-- 


Ron Brash
CTO  & Co-founder of Atlants Embedded Inc.
www.atlantsembedded.com
------------------------------------------------------------------

Cell +1 438 880 6441
Email  ron.brash at gmail.com
LinkedIn ca.linkedin.com/in/ronbrash/



------------------------------------------------------------------

Signed-off-by: “Ron Brash <“ron.brash at gmail.com”>
---
 log/logread.c | 27 +++++++++++++++++++++++----
 1 file changed, 23 insertions(+), 4 deletions(-)

diff --git a/log/logread.c b/log/logread.c
index edac1d9..2032819 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;
@@ -361,11 +377,14 @@ int main(int argc, char **argv)
  } else {
  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);
-
+
  uloop_run();
  ubus_free(ctx);
  uloop_done();
-- 
2.7.4



More information about the Lede-dev mailing list