]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Use setlinebuf() at startup instead of calling fflush() for each logger call.
authorRoy Marples <roy@marples.name>
Mon, 28 Jul 2008 15:43:38 +0000 (15:43 +0000)
committerRoy Marples <roy@marples.name>
Mon, 28 Jul 2008 15:43:38 +0000 (15:43 +0000)
dhcpcd.c
logger.c

index 3857b7c546fed063eacd1ae73a1a53fb35d89e0a..92813fc229e79a17f173ba6fdb1b51243bdc2253 100644 (file)
--- a/dhcpcd.c
+++ b/dhcpcd.c
@@ -627,6 +627,9 @@ main(int argc, char **argv)
 #endif
 
        closefrom(3);
+       /* Saves calling fflush(stream) in the logger */
+       setlinebuf(stdout);
+       setlinebuf(stderr);
        openlog(PACKAGE, LOG_PID, LOG_LOCAL0);
        setlogprefix(PACKAGE ": ");
 
index 6eb0c295de99ddd613c6f00fbbbd5336c29c1943..f312679a044c32b596df93ff30d6e285421e58ba 100644 (file)
--- a/logger.c
+++ b/logger.c
@@ -90,10 +90,6 @@ logger(int level, const char *fmt, ...)
                fprintf(f, "%s", logprefix);
                vfprintf(f, fmt, p);
                fputc('\n', f);
-
-               /* stdout, stderr may be re-directed to some kind of buffer.
-                * So we always flush to ensure it's written. */
-               fflush(f);
        }
 
        if (level < LOG_DEBUG || level <= loglevel) {