]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
Destroy the dedicated RPCI channel set up for the Vmx Guest Logging
authorOliver Kurth <okurth@vmware.com>
Wed, 1 Apr 2020 18:34:06 +0000 (11:34 -0700)
committerOliver Kurth <okurth@vmware.com>
Wed, 1 Apr 2020 18:34:06 +0000 (11:34 -0700)
when vmtoolsd process exits.

open-vm-tools/lib/include/vmware/tools/log.h
open-vm-tools/libvmtools/vmtoolsLog.c
open-vm-tools/services/vmtoolsd/mainPosix.c

index 4cb4bcb33fe36224b95ae29bc34d7fc9d5263792..222ed1658b8cdbb77fbbf617327caf4cbe13c473 100644 (file)
@@ -1,5 +1,5 @@
 /*********************************************************
- * Copyright (C) 2011-2019 VMware, Inc. All rights reserved.
+ * Copyright (C) 2011-2020 VMware, Inc. All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of the GNU Lesser General Public License as published
@@ -332,6 +332,9 @@ void
 VMTools_SetupVmxGuestLog(gboolean refreshRpcChannel, GKeyFile *cfg,
                          const gchar *level);
 
+void
+VMTools_TeardownVmxGuestLog(void);
+
 typedef enum {
    TO_HOST,
    IN_GUEST
index 725fa3103ad9b242fbca6e582f88c2aa592e2d55..3c331b5a820ff0d0809e6cab00edec793c9c5f6c 100644 (file)
@@ -1,5 +1,5 @@
 /*********************************************************
- * Copyright (C) 2008-2019 VMware, Inc. All rights reserved.
+ * Copyright (C) 2008-2020 VMware, Inc. All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of the GNU Lesser General Public License as published
@@ -2594,6 +2594,41 @@ done:
 }
 
 
+/*
+ *******************************************************************************
+ * VMTools_TeardownVmxGuestLog --                                         */ /**
+ *
+ * Destroy the dedicated RPCI channel set up for the Vmx Guest Logging.
+ * This function is called from the tools process exit code path.
+ *
+ *******************************************************************************
+ */
+
+void
+VMTools_TeardownVmxGuestLog(void)
+{
+   /*
+    * In case VMTools_UseVmxGuestLog() is never called.
+    */
+   if (!gUseVmxGuestLog) {
+      return;
+   }
+
+   /*
+    * Acquire the same locks as VMTools_SetupVmxGuestLog.
+    */
+   VMTools_AcquireLogStateLock();
+
+   g_rec_mutex_lock(&gVmxGuestLogMutex);
+
+   DestroyRpcChannel();
+
+   g_rec_mutex_unlock(&gVmxGuestLogMutex);
+
+   VMTools_ReleaseLogStateLock();
+}
+
+
 /**
  * Helper function to return the matching LogHandler for a domain name
  *
index cfe6798428eebdb27feb569891c8ca861dd2741b..f46e9e77ed238a445441d1f0fef9720d33ce9cf7 100644 (file)
@@ -1,5 +1,5 @@
 /*********************************************************
- * Copyright (C) 2008-2019 VMware, Inc. All rights reserved.
+ * Copyright (C) 2008-2020 VMware, Inc. All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of the GNU Lesser General Public License as published
@@ -187,6 +187,8 @@ main(int argc,
 
    setlocale(LC_ALL, "");
 
+   i = atexit(VMTools_TeardownVmxGuestLog);
+   ASSERT(i == 0);
    VMTools_UseVmxGuestLog(VMTOOLS_APP_NAME);
    VMTools_ConfigLogging(G_LOG_DOMAIN, NULL, TRUE, FALSE);
    VMTools_SetupVmxGuestLog(FALSE, NULL, NULL);