[git commit] syslogd: syslogd: don't *decrement* log_file->size on write failures
Denys Vlasenko
vda.linux at googlemail.com
Wed Jul 2 17:41:41 UTC 2014
commit: http://git.busybox.net/busybox/commit/?id=e46047aa87c9ec0b8e27d1d4ecfcb3e9798ddb8d
branch: http://git.busybox.net/busybox/commit/?id=refs/heads/master
Even if we fail to write to a log-file, and it's not growing,
it's not *shrinking* either....
Signed-off-by: Joshua Judson Rosen <jrosen at harvestai.com>
Signed-off-by: Denys Vlasenko <vda.linux at googlemail.com>
---
sysklogd/syslogd.c | 11 ++++++++---
1 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/sysklogd/syslogd.c b/sysklogd/syslogd.c
index d80447b..04221fc 100644
--- a/sysklogd/syslogd.c
+++ b/sysklogd/syslogd.c
@@ -569,7 +569,7 @@ static void log_to_kmsg(int pri, const char *msg)
*/
pri &= G.primask;
- write(G.kmsgfd, G.printbuf, sprintf(G.printbuf, "<%d>%s\n", pri, msg));
+ full_write(G.kmsgfd, G.printbuf, sprintf(G.printbuf, "<%d>%s\n", pri, msg));
}
#else
static void kmsg_init(void) {}
@@ -678,9 +678,14 @@ static void log_locally(time_t now, char *msg, logFile_t *log_file)
close(log_file->fd);
goto reopen;
}
- log_file->size +=
+/* TODO: what to do on write errors ("disk full")? */
+ len = full_write(log_file->fd, msg, len);
+ if (len > 0)
+ log_file->size += len;
+#else
+ full_write(log_file->fd, msg, len);
#endif
- full_write(log_file->fd, msg, len);
+
#ifdef SYSLOGD_WRLOCK
fl.l_type = F_UNLCK;
fcntl(log_file->fd, F_SETLKW, &fl);
More information about the busybox-cvs
mailing list