summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVMware, Inc <>2013-09-17 20:39:21 -0700
committerDmitry Torokhov <dmitry.torokhov@gmail.com>2013-09-22 22:26:42 -0700
commitcb790dbad75717d0ffb99bc268ee9ed6214c93ba (patch)
treeeff520244143ed34ef89b0fcaf668419da63d423
parent155eb8d6615c947b71167fabe44b2fbca70a1e39 (diff)
Fix nested logging for VmxLogger with vsocket channel.
Signed-off-by: Dmitry Torokhov <dtor@vmware.com>
-rw-r--r--open-vm-tools/lib/include/vmware/tools/utils.h6
-rw-r--r--open-vm-tools/libvmtools/vmtoolsLog.c28
-rw-r--r--open-vm-tools/libvmtools/vmxLogger.c17
3 files changed, 45 insertions, 6 deletions
diff --git a/open-vm-tools/lib/include/vmware/tools/utils.h b/open-vm-tools/lib/include/vmware/tools/utils.h
index 6e1931d2..676d9000 100644
--- a/open-vm-tools/lib/include/vmware/tools/utils.h
+++ b/open-vm-tools/lib/include/vmware/tools/utils.h
@@ -142,6 +142,12 @@ VMTools_CreateTimer(gint timeout);
void
VMTools_SetGuestSDKMode(void);
+void
+VMTools_StopLogging(void);
+
+void
+VMTools_RestartLogging(void);
+
GArray *
VMTools_WrapArray(gconstpointer data,
guint elemSize,
diff --git a/open-vm-tools/libvmtools/vmtoolsLog.c b/open-vm-tools/libvmtools/vmtoolsLog.c
index 2a093c4a..de5972de 100644
--- a/open-vm-tools/libvmtools/vmtoolsLog.c
+++ b/open-vm-tools/libvmtools/vmtoolsLog.c
@@ -114,6 +114,7 @@ static LogHandler *gDefaultData;
static LogHandler *gErrorData;
static GPtrArray *gDomains = NULL;
static gboolean gLogInitialized = FALSE;
+static gboolean gLoggingStopped = FALSE;
/* Internal functions. */
@@ -903,6 +904,11 @@ VMToolsLogWrapper(GLogLevelFlags level,
return;
}
+ if (gLoggingStopped) {
+ /* This is to avoid nested logging in vmxLogger */
+ return;
+ }
+
if (gPanicCount == 0) {
char *msg = Str_Vasprintf(NULL, fmt, args);
if (msg != NULL) {
@@ -919,6 +925,28 @@ VMToolsLogWrapper(GLogLevelFlags level,
/**
+ * This is called to avoid nested logging in vmxLogger.
+ */
+
+void
+VMTools_StopLogging(void)
+{
+ gLoggingStopped = TRUE;
+}
+
+
+/**
+ * This is called to reset logging in vmxLogger.
+ */
+
+void
+VMTools_RestartLogging(void)
+{
+ gLoggingStopped = FALSE;
+}
+
+
+/**
* Called if vmtools lib is used along with Guestlib SDK.
*/
diff --git a/open-vm-tools/libvmtools/vmxLogger.c b/open-vm-tools/libvmtools/vmxLogger.c
index fa606935..fecc69a7 100644
--- a/open-vm-tools/libvmtools/vmxLogger.c
+++ b/open-vm-tools/libvmtools/vmxLogger.c
@@ -36,7 +36,7 @@ typedef struct VMXLoggerData {
*******************************************************************************
* VMXLoggerLog -- */ /**
*
- * Logs a message to the VMX using the backdoor.
+ * Logs a message to the VMX using RpcChannel.
*
* The logger uses its own RpcChannel, opening and closing the channel for each
* log message sent. This is not optimal, especially if the application already
@@ -61,20 +61,25 @@ VMXLoggerLog(const gchar *domain,
VMXLoggerData *logger = data;
g_static_mutex_lock(&logger->lock);
+
+ /*
+ * To avoid nested logging inside of RpcChannel, we need to disable logging
+ * here. See bug 1069390.
+ */
+
+ VMTools_StopLogging();
+
if (RpcChannel_Start(logger->chan)) {
gchar *msg;
gint cnt = VMToolsAsprintf(&msg, "log %s", message);
- /*
- * XXX: RpcChannel_Send() can log stuff in certain situations, which will
- * cause this to blow up. Hopefully we won't hit those too often since
- * we're stopping / starting the channel for each log message.
- */
RpcChannel_Send(logger->chan, msg, cnt, NULL, NULL);
g_free(msg);
RpcChannel_Stop(logger->chan);
}
+
+ VMTools_RestartLogging();
g_static_mutex_unlock(&logger->lock);
}