From: VMware, Inc <> Date: Tue, 28 Jun 2011 18:41:46 +0000 (-0700) Subject: Don't drop messages from core dump library. X-Git-Tag: 2011.06.27-437995~30 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=b67a4e00332afd497a198047f846a3a2d1008b5d;p=thirdparty%2Fopen-vm-tools.git Don't drop messages from core dump library. Instead of dropping messages to avoid glib's aversion to log recursion, just bypass glib and call our logging functions directly when recursing. Signed-off-by: Marcelo Vanzin --- diff --git a/open-vm-tools/libvmtools/vmtoolsLog.c b/open-vm-tools/libvmtools/vmtoolsLog.c index 5066dce36..cdbc785b5 100644 --- a/open-vm-tools/libvmtools/vmtoolsLog.c +++ b/open-vm-tools/libvmtools/vmtoolsLog.c @@ -890,6 +890,33 @@ VMTools_ConfigLogging(const gchar *defaultDomain, /* Wrappers for VMware's logging functions. */ +/** + * Generic wrapper for VMware log functions. + * + * CoreDump_CoreDump() may log, and glib doesn't like recursive log calls. So + * if recursing, bypass glib and log to the default domain's log handler. + * + * @param[in] level Log level. + * @param[in] fmt Message format. + * @param[in] args Message arguments. + */ + +static void +VMToolsLogWrapper(GLogLevelFlags level, + const char *fmt, + va_list args) +{ + if (gPanicCount == 0) { + g_logv(gLogDomain, level, fmt, args); + } else { + /* Try to avoid malloc() since we're aborting. */ + gchar msg[256]; + g_vsnprintf(msg, sizeof msg, fmt, args); + VMToolsLog(gLogDomain, level, msg, gDefaultData); + } +} + + /** * Logs a message using the G_LOG_LEVEL_DEBUG level. * @@ -901,7 +928,7 @@ Debug(const char *fmt, ...) { va_list args; va_start(args, fmt); - g_logv(gLogDomain, G_LOG_LEVEL_DEBUG, fmt, args); + VMToolsLogWrapper(G_LOG_LEVEL_DEBUG, fmt, args); va_end(args); } @@ -915,13 +942,10 @@ Debug(const char *fmt, ...) void Log(const char *fmt, ...) { - /* CoreDump_CoreDump() calls Log(), avoid that message. */ - if (gPanicCount == 0) { - va_list args; - va_start(args, fmt); - g_logv(gLogDomain, G_LOG_LEVEL_INFO, fmt, args); - va_end(args); - } + va_list args; + va_start(args, fmt); + VMToolsLogWrapper(G_LOG_LEVEL_INFO, fmt, args); + va_end(args); } @@ -968,7 +992,7 @@ LogV(uint32 routing, glevel = G_LOG_LEVEL_DEBUG; } - g_logv(gLogDomain, glevel, fmt, args); + VMToolsLogWrapper(glevel, fmt, args); } @@ -1019,12 +1043,9 @@ Panic(const char *fmt, ...) void Warning(const char *fmt, ...) { - /* CoreDump_CoreDump() may call Warning(), avoid that message. */ - if (gPanicCount == 0) { - va_list args; - va_start(args, fmt); - g_logv(gLogDomain, G_LOG_LEVEL_WARNING, fmt, args); - va_end(args); - } + va_list args; + va_start(args, fmt); + VMToolsLogWrapper(G_LOG_LEVEL_WARNING, fmt, args); + va_end(args); }