From 17f3e46961723c1ae512dee4492d809c505260dc Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Mon, 19 Mar 2012 20:37:34 +0100 Subject: [PATCH] fix log buffer splitting --- main.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/main.c b/main.c index 3fe38bf..b7d660e 100644 --- a/main.c +++ b/main.c @@ -73,7 +73,7 @@ netifd_process_log_cb(struct uloop_fd *fd, unsigned int events) { struct netifd_process *proc; const char *log_prefix; - char *buf, *cur; + char *buf, *start, *cur; int maxlen, len, read_len; proc = container_of(fd, struct netifd_process, log_uloop); @@ -100,19 +100,23 @@ retry: proc->log_buf_ofs += len; cur = buf; - buf = proc->log_buf; - while (len > 0 && (cur = memchr(cur, '\n', len))) { + start = proc->log_buf; + while (len > 0) { + cur = memchr(cur, '\n', len); + if (!cur) + break; + *cur = 0; if (!proc->log_overflow) netifd_log_message(L_NOTICE, "%s (%d): %s\n", - log_prefix, proc->uloop.pid, buf); + log_prefix, proc->uloop.pid, start); else proc->log_overflow = false; cur++; len -= cur - buf; - buf = cur; + buf = start = cur; } if (buf > proc->log_buf && len > 0) -- 2.25.1