[PATCH] hostapd: Set stdout line-buffered

Paul Stewart pstew
Thu Dec 4 14:23:35 PST 2014


If hostapd will use stdout for debugging, set stdout to be line
buffered in case its output is redirected to a file.  This allows
incremental output to be viewed immediately instead of at the file
buffering interval.

Signed-hostap: Paul Stewart <pstew at chromium.org>
---
 hostapd/main.c        | 2 ++
 src/utils/wpa_debug.c | 7 +++++++
 src/utils/wpa_debug.h | 2 ++
 3 files changed, 11 insertions(+)

diff --git a/hostapd/main.c b/hostapd/main.c
index 900bba9..6a90d58 100644
--- a/hostapd/main.c
+++ b/hostapd/main.c
@@ -638,6 +638,8 @@ int main(int argc, char *argv[])
 
 	if (log_file)
 		wpa_debug_open_file(log_file);
+	else
+		wpa_debug_setup_stdout();
 #ifdef CONFIG_DEBUG_LINUX_TRACING
 	if (enable_trace_dbg) {
 		int tret = wpa_debug_open_linux_tracing();
diff --git a/src/utils/wpa_debug.c b/src/utils/wpa_debug.c
index bf0833a..8ba82b1 100644
--- a/src/utils/wpa_debug.c
+++ b/src/utils/wpa_debug.c
@@ -574,6 +574,13 @@ void wpa_debug_close_file(void)
 #endif /* CONFIG_DEBUG_FILE */
 }
 
+void wpa_debug_setup_stdout(void)
+{
+#ifndef _WIN32
+	setvbuf(stdout, NULL, _IOLBF, 0);
+#endif /* _WIN32 */
+}
+
 #endif /* CONFIG_NO_STDOUT_DEBUG */
 
 
diff --git a/src/utils/wpa_debug.h b/src/utils/wpa_debug.h
index 391f197..400bea9 100644
--- a/src/utils/wpa_debug.h
+++ b/src/utils/wpa_debug.h
@@ -34,6 +34,7 @@ enum {
 #define wpa_hexdump_ascii_key(l,t,b,le) do { } while (0)
 #define wpa_debug_open_file(p) do { } while (0)
 #define wpa_debug_close_file() do { } while (0)
+#define wpa_debug_setup_stdout() do { } while (0)
 #define wpa_dbg(args...) do { } while (0)
 
 static inline int wpa_debug_reopen_file(void)
@@ -46,6 +47,7 @@ static inline int wpa_debug_reopen_file(void)
 int wpa_debug_open_file(const char *path);
 int wpa_debug_reopen_file(void);
 void wpa_debug_close_file(void);
+void wpa_debug_setup_stdout(void);
 
 /**
  * wpa_debug_printf_timestamp - Print timestamp for debug output
-- 
2.2.0.rc0.207.ga3a616c




More information about the Hostap mailing list