summaryrefslogtreecommitdiffhomepage
path: root/main.c
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@openwrt.org>2012-03-19 20:37:34 +0100
committerFelix Fietkau <nbd@openwrt.org>2012-03-19 20:37:34 +0100
commit17f3e46961723c1ae512dee4492d809c505260dc (patch)
treeca0599015cb0afb48f5ce5ac943b587e73e1b5a1 /main.c
parent889a60c26de78b288fb16a9c17db4a248e958fbd (diff)
fix log buffer splitting
Diffstat (limited to 'main.c')
-rw-r--r--main.c14
1 files 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)