]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
Don't unregister capabilities if they were never set.
authorVMware, Inc <>
Thu, 18 Nov 2010 22:12:13 +0000 (14:12 -0800)
committerMarcelo Vanzin <mvanzin@vmware.com>
Thu, 18 Nov 2010 22:12:13 +0000 (14:12 -0800)
This avoid an issue where a second instance of vmtoolsd would fail to claim
the RPC channel to communicate with the VMX, shut down, and unregister all
capabilities in the process, which would overwrite the state set by the
existing instance of vmtoolsd.

Signed-off-by: Marcelo Vanzin <mvanzin@vmware.com>
open-vm-tools/services/vmtoolsd/pluginMgr.c
open-vm-tools/services/vmtoolsd/toolsCoreInt.h
open-vm-tools/services/vmtoolsd/toolsRpc.c

index 7293290105b70065aab61dcc6bcd98cc0ffb5170..966c2497b2e95293f2a1514b5f378bfe9fe1a320 100644 (file)
@@ -732,23 +732,25 @@ void
 ToolsCore_UnloadPlugins(ToolsServiceState *state)
 {
    guint i;
-   GArray *pcaps = NULL;
 
    if (state->plugins == NULL) {
       return;
    }
 
-   g_signal_emit_by_name(state->ctx.serviceObj,
-                         TOOLS_CORE_SIG_CAPABILITIES,
-                         &state->ctx,
-                         FALSE,
-                         &pcaps);
-
-   if (pcaps != NULL) {
-      if (state->ctx.rpc) {
-         ToolsCore_SetCapabilities(state->ctx.rpc, pcaps, FALSE);
+   if (state->capsRegistered) {
+      GArray *pcaps = NULL;
+      g_signal_emit_by_name(state->ctx.serviceObj,
+                            TOOLS_CORE_SIG_CAPABILITIES,
+                            &state->ctx,
+                            FALSE,
+                            &pcaps);
+
+      if (pcaps != NULL) {
+         if (state->ctx.rpc) {
+            ToolsCore_SetCapabilities(state->ctx.rpc, pcaps, FALSE);
+         }
+         g_array_free(pcaps, TRUE);
       }
-      g_array_free(pcaps, TRUE);
    }
 
    /*
index aba4fa5a606584345ada1e77ad0c55f9686370a6..1fd87d12599e7d2493784b798c71a0195f890e4a 100644 (file)
@@ -79,6 +79,7 @@ typedef struct ToolsServiceState {
    guint          configCheckTask;
    gboolean       log;
    gboolean       mainService;
+   gboolean       capsRegistered;
    gchar         *commonPath;
    gchar         *pluginPath;
    GPtrArray     *plugins;
index f289089ecaad41eb9733ab1181f9174d061d0f09..cde14d44864590768902f9948308dd92dd01eb48 100644 (file)
@@ -152,6 +152,7 @@ ToolsCoreRpcCapReg(RpcInData *data)
       g_free(toolsVersion);
    }
 
+   state->capsRegistered = TRUE;
    free(confPath);
    return RPCIN_SETRETVALS(data, "", TRUE);
 }