]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
Changes in shared code that don't affect open-vm-tools functionality.
authorVMware, Inc <>
Mon, 26 Apr 2010 17:57:21 +0000 (10:57 -0700)
committerMarcelo Vanzin <mvanzin@vmware.com>
Mon, 26 Apr 2010 17:57:21 +0000 (10:57 -0700)
Signed-off-by: Marcelo Vanzin <mvanzin@vmware.com>
open-vm-tools/services/vmtoolsd/serviceObj.c

index 7447592136b6697889a5ab28e45ba1329a3012b3..1c23454c343061e4c45889a56654d6e75399e387 100644 (file)
@@ -97,10 +97,19 @@ ToolsCoreCapabilitiesAccumulator(GSignalInvocationHint *ihint,
  * Accumulator function for the "service control" signal. Updates the return
  * value according to the signal's documentation.
  *
- * @param[in]  ihint       Unused.
- * @param[out] retval      Return value of the signal.
- * @param[in]  handlerRet  Return value from the current handler.
- * @param[in]  data        Unused.
+ * The gobject library initializes the return value to "0" regardless of
+ * what the signal emitter sets it to. So the accumulator does two things
+ * to have a non-zero default return value:
+ *
+ *    - if the current return value is zero, it's set to the default return
+ *      value (ERROR_CALL_NOT_IMPLEMENTED).
+ *    - the return value is always offset by one; so the signal emitter
+ *      should decrement the return value when looking at it.
+ *
+ * @param[in]     ihint       Unused.
+ * @param[in,out] retval      Return value of the signal (offset by 1).
+ * @param[in]     handlerRet  Return value from the current handler.
+ * @param[in]     data        Unused.
  *
  * @return TRUE.
  */
@@ -113,25 +122,32 @@ ToolsCoreServiceControlAccumulator(GSignalInvocationHint *ihint,
 {
    guint ret = g_value_get_uint(retval);
    guint handlerVal = g_value_get_uint(handlerRet);
+
+   if (ret == 0) {
+      ret = ERROR_CALL_NOT_IMPLEMENTED + 1;
+   }
+
    switch (ret) {
-   case ERROR_CALL_NOT_IMPLEMENTED:
-      ret = handlerVal;
+   case ERROR_CALL_NOT_IMPLEMENTED + 1:
+      ret = handlerVal + 1;
       break;
 
-   case NO_ERROR:
+   case NO_ERROR + 1:
       if (handlerVal != ERROR_CALL_NOT_IMPLEMENTED) {
-         ret = handlerVal;
+         ret = handlerVal + 1;
       }
       break;
 
    default:
       break;
    }
+
    g_value_set_uint(retval, ret);
    return TRUE;
 }
 #endif
 
+
 /**
  * Initializes the ToolsCoreService class. Sets up the signals that are sent
  * by the vmtoolsd service.
@@ -212,7 +228,7 @@ ToolsCore_Service_class_init(gpointer _klass,
                 G_OBJECT_CLASS_TYPE(klass),
                 G_SIGNAL_RUN_LAST,
                 0,
-                NULL,
+                ToolsCoreServiceControlAccumulator,
                 NULL,
                 g_cclosure_user_marshal_UINT__POINTER_POINTER_UINT_UINT_POINTER,
                 G_TYPE_UINT,