Followup to commit 17e19add, and would have prevented the bug independently fixed in commit 76c57a7c. * src/util/logging.c (virLogMessage): Preserve errno, since logging should be as unintrusive as possible. --- Per list discussion, this is post-0.8.8 material. src/util/logging.c | 23 +++++++++++++++++------ 1 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/util/logging.c b/src/util/logging.c index c598195..9a3e659 100644 --- a/src/util/logging.c +++ b/src/util/logging.c @@ -1,7 +1,7 @@ /* * logging.c: internal logging and debugging * - * Copyright (C) 2008, 2010 Red Hat, Inc. + * Copyright (C) 2008, 2010, 2011 Red Hat, Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -573,29 +573,38 @@ void virLogMessage(const char *category, int priority, const char *funcname, struct timeval cur_time; struct tm time_info; int len, fprio, i, ret; + int saved_errno = errno; if (!virLogInitialized) virLogStartup(); - if (fmt == NULL) - return; + if (fmt == NULL) { + errno = saved_errno; + return; + } /* * check against list of specific logging patterns */ fprio = virLogFiltersCheck(category); if (fprio == 0) { - if (priority < virLogDefaultPriority) + if (priority < virLogDefaultPriority) { + errno = saved_errno; return; - } else if (priority < fprio) + } + } else if (priority < fprio) { + errno = saved_errno; return; + } /* * serialize the error message, add level and timestamp */ VIR_GET_VAR_STR(fmt, str); - if (str == NULL) + if (str == NULL) { + errno = saved_errno; return; + } gettimeofday(&cur_time, NULL); localtime_r(&cur_time.tv_sec, &time_info); @@ -605,6 +614,7 @@ void virLogMessage(const char *category, int priority, const char *funcname, VIR_FREE(str); if (ret < 0) { /* apparently we're running out of memory */ + errno = saved_errno; return; } @@ -648,6 +658,7 @@ void virLogMessage(const char *category, int priority, const char *funcname, virLogUnlock(); VIR_FREE(msg); + errno = saved_errno; } static int virLogOutputToFd(const char *category ATTRIBUTE_UNUSED, -- 1.7.4 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list