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

Hans Dedecker dedeckeh at gmail.com
Thu Jul 6 00:26:22 PDT 2017


On Wed, Jul 5, 2017 at 5:01 PM, Ron Brash <ron.brash at gmail.com> wrote:
> Hello all,
>
> Here is a repost of the previous concatonated patch.
Please leave the above lines out as the patch comment only needs to
explain what the patch is about as is done in the lines below
>
> 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.
Leave the lines below out ...
>
> 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/
>
>
... till here as this does not belong in the commit message and also
breaks the patch ...
>
> ------------------------------------------------------------------
>
> 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);
> -
> +
unnecessary change
>   uloop_run();
>   ubus_free(ctx);
>   uloop_done();
> --
> 2.7.4
The patch is white space mangled as Rafal pointed out use the git
send-email tool

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



More information about the Lede-dev mailing list