From c8d14b9b5d0fa3a3f99df386b67670e083c82095 Mon Sep 17 00:00:00 2001 From: John Crispin Date: Wed, 12 Mar 2014 07:00:11 +0000 Subject: [PATCH] logd: fix internal buffer size Signed-off-by: John Crispin --- log/logd.c | 15 ++++++++++++++- log/syslog.c | 5 ++++- log/syslog.h | 2 +- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/log/logd.c b/log/logd.c index 5dd9932..e4f9b3f 100644 --- a/log/logd.c +++ b/log/logd.c @@ -14,6 +14,7 @@ #include #include #include +#include #include @@ -172,10 +173,22 @@ ubus_connect_handler(struct ubus_context *ctx) int main(int argc, char **argv) { + int ch, log_size = 16; + signal(SIGPIPE, SIG_IGN); + while ((ch = getopt(argc, argv, "S:")) != -1) { + switch (ch) { + case 'S': + log_size = atoi(optarg); + if (log_size < 1) + log_size = 16; + break; + } + } + log_size *= 1024; uloop_init(); - log_init(); + log_init(log_size); conn.cb = ubus_connect_handler; ubus_auto_connect(&conn); uloop_run(); diff --git a/log/syslog.c b/log/syslog.c index fcc4a74..4cabb43 100644 --- a/log/syslog.c +++ b/log/syslog.c @@ -274,8 +274,11 @@ log_buffer_init(int size) } void -log_init(void) +log_init(int _log_size) { + if (_log_size > 0) + log_size = _log_size; + regcomp(&pat_prio, "^<([0-9]*)>(.*)", REG_EXTENDED); regcomp(&pat_tstamp, "^\[[ 0]*([0-9]*).([0-9]*)] (.*)", REG_EXTENDED); diff --git a/log/syslog.h b/log/syslog.h index dc712ff..b682ced 100644 --- a/log/syslog.h +++ b/log/syslog.h @@ -30,7 +30,7 @@ struct log_head { char data[]; }; -void log_init(void); +void log_init(int log_size); void log_shutdown(void); typedef void (*log_list_cb)(struct log_head *h); -- 2.25.1