From 3f5b4e20a9608b9e313bf4b5f3b60ec1dcfade1b Mon Sep 17 00:00:00 2001 From: Franklin Wei Date: Sat, 16 Jan 2016 20:05:58 -0500 Subject: packetized requests --- src/util.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src/util.c') diff --git a/src/util.c b/src/util.c index 2c10eef..6d2d184 100644 --- a/src/util.c +++ b/src/util.c @@ -25,7 +25,7 @@ void remove_cruft(char *str) } /** - * WARNING: not signal-safe + * WARNING: not signal-safe AT ALL * TODO: rewrite to avoid calling *printf() */ void debugf_real(const char *func, int line, const char *file, const char *fmt, ...) @@ -33,6 +33,11 @@ void debugf_real(const char *func, int line, const char *file, const char *fmt, (void) func; (void) line; (void) file; + static int fd = -1; + if(fd < 0) + fd = open(LOGFILE, O_APPEND | O_WRONLY | O_CREAT, 0600); + if(fd < 0) + error("unknown"); int len; #if 0 char *prefix; @@ -48,6 +53,8 @@ void debugf_real(const char *func, int line, const char *file, const char *fmt, len = vasprintf(&buf, fmt, ap); write(STDOUT_FILENO, buf, len); + write(fd, buf, len); + fflush(fdopen(fd, "a")); free(buf); -- cgit v1.1