[obfsproxy/master] Fix bugs in logging functions.

commit 93c9626b9a70614409ee7132a7a98052c19a6fb0 Author: George Kadianakis <desnacked@riseup.net> Date: Fri Feb 3 17:23:21 2012 +0200 Fix bugs in logging functions. * Don't use obfs_assert() in logv(). * Don't set the logging method before opening the log file, in log_set_method(). --- src/util.c | 11 +++++++---- 1 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/util.c b/src/util.c index 0ac7811..000bf85 100644 --- a/src/util.c +++ b/src/util.c @@ -20,6 +20,7 @@ #include <fcntl.h> #include <stdio.h> #include <unistd.h> +#include <assert.h> #include <event2/dns.h> #ifndef _WIN32 @@ -457,13 +458,15 @@ write_logfile_prologue(int logfile) int log_set_method(int method, const char *filename) { - logging_method = method; if (method == LOG_METHOD_FILE) { if (open_and_set_obfsproxy_logfile(filename) < 0) return -1; if (write_logfile_prologue(logging_logfile) < 0) return -1; } + + logging_method = method; + return 0; } @@ -543,10 +546,10 @@ logv(int severity, const char *format, va_list ap) if (logging_method == LOG_METHOD_STDERR) fprintf(stderr, "%s", buf); else if (logging_method == LOG_METHOD_FILE) { - obfs_assert(logging_logfile); - obfs_assert(!(write(logging_logfile, buf, strlen(buf)) < 0)); + assert(logging_logfile >= 0); + assert(!(write(logging_logfile, buf, strlen(buf)) < 0)); } else - obfs_assert(0); + assert(0); } /**** Public logging API. ****/
participants (1)
-
nickm@torproject.org