[LEDE-DEV] [PATCH] ubox logread

Felix Fietkau nbd at nbd.name
Mon Nov 6 03:03:21 PST 2017


On 2017-10-19 17:57, Maksym Ruchko wrote:
> The read optimization with buffer ustream in the logread caused the
> logger to hung randomly, more often under high load and when logged
> messages are large.
> 
> To reproduce 100% compile and run:
> #include <syslog.h>
> #include <stdlib.h>
> #include <string.h>
> 
> #define BUF_SIZE 8192
> 
> int i;
> static char msg_buf[BUF_SIZE];
> 
> int main(int argc, char* argv[])
> {
>         setlogmask(LOG_UPTO(LOG_NOTICE));
> 
>         openlog(argv[0], LOG_CONS | LOG_PID | LOG_NDELAY, LOG_LOCAL1);
> 
>         syslog(LOG_NOTICE, "Program started by User %d", getuid());
>         syslog(LOG_INFO, "A tree falls in a forest");
> 
>         memset(msg_buf, 'A', BUF_SIZE - 1);
>         msg_buf[BUF_SIZE-1] = '\0';
>         for (i=0; i < 10; ++i) syslog(LOG_NOTICE, msg_buf);
> 
>         syslog(LOG_NOTICE, "After");
> 
>         closelog();
> 
>         exit(0);
> }
> 
> The line "After" will not show up in the log and all subsequent log messages are blocked.
> 
> Patch below against ubox master branch at
> https://git.openwrt.org/project/ubox.git  fixes the problem, keeping
> buffers trickery as fast patch for short messages.I think your patch was only masking the real issues. I reviewed the logd
and logread code and found quite a few things to be broken.
I have now reworked the code quite a bit, and your test case also works
nicely with the updated code, please test the latest version.

Thanks for your detailed report + test case!

- Felix



More information about the Lede-dev mailing list