]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
[AppInfo] Tweak the gather loop only for a real config reload.
authorJohn Wolfe <jwolfe@vmware.com>
Wed, 19 Aug 2020 17:01:16 +0000 (10:01 -0700)
committerJohn Wolfe <jwolfe@vmware.com>
Wed, 19 Aug 2020 17:01:16 +0000 (10:01 -0700)
The poll loop for appInfo is being tweaked (destroyed and recreated)
for every tools.conf reload, even when nothing related to appinfo changed.
This may cause a few scenarios where the 'application information'
will never be collected inside the guest.  Tweak the loop only when there
is a real appinfo related config change in the tools.conf file.

open-vm-tools/services/plugins/appInfo/appInfo.c

index d96d9a075b2acf713ab0584f60dbd34703e0627e..4e64799b628bf4de72feebf93316532be4149663 100644 (file)
@@ -93,7 +93,7 @@ static guint gAppInfoPollInterval = 0;
  */
 static GSource *gAppInfoTimeoutSource = NULL;
 
-static void TweakGatherLoop(ToolsAppCtx *ctx);
+static void TweakGatherLoop(ToolsAppCtx *ctx, gboolean force);
 
 
 /*
@@ -415,7 +415,7 @@ AppInfoGather(gpointer data)      // IN
                 "information\n", __FUNCTION__);
    }
 
-   TweakGatherLoop(ctx);
+   TweakGatherLoop(ctx, TRUE);
 
    return G_SOURCE_REMOVE;
 }
@@ -483,12 +483,16 @@ TweakGatherLoopEx(ToolsAppCtx *ctx,       // IN
  * AppInfo Gather loop timeout source.
  *
  * @param[in]     ctx           The application context.
+ * @param[in]     force         If set to TRUE, the poll loop will be
+ *                              tweaked even if the poll interval hasn't
+ *                              changed from the previous value.
  *
  *****************************************************************************
  */
 
 static void
-TweakGatherLoop(ToolsAppCtx *ctx)    // IN
+TweakGatherLoop(ToolsAppCtx *ctx,  // IN
+                gboolean force)    // IN
 {
    gboolean disabled =
       VMTools_ConfigGetBoolean(ctx->config,
@@ -511,11 +515,13 @@ TweakGatherLoop(ToolsAppCtx *ctx)    // IN
       }
    }
 
-   /*
-    * pollInterval can never be a negative value. Typecasting into
-    * guint should not be a problem.
-    */
-   TweakGatherLoopEx(ctx, (guint) pollInterval);
+   if (force || (gAppInfoPollInterval != pollInterval)) {
+      /*
+       * pollInterval can never be a negative value. Typecasting into
+       * guint should not be a problem.
+       */
+      TweakGatherLoopEx(ctx, (guint) pollInterval);
+   }
 }
 
 
@@ -539,7 +545,7 @@ AppInfoServerConfReload(gpointer src,       // IN
 {
    g_info("%s: Reloading the tools configuration.\n", __FUNCTION__);
 
-   TweakGatherLoop(ctx);
+   TweakGatherLoop(ctx, FALSE);
 }
 
 
@@ -692,7 +698,7 @@ ToolsOnLoad(ToolsAppCtx *ctx)    // IN
       /*
        * Set up the AppInfo gather loop.
        */
-      TweakGatherLoop(ctx);
+      TweakGatherLoop(ctx, TRUE);
 
       return &regData;
    }