]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
rpcChannel: Add wrapper functions for start/stop.
authorVMware, Inc <>
Fri, 18 Sep 2009 21:53:43 +0000 (14:53 -0700)
committerMarcelo Vanzin <mvanzin@mvanzin-dev1.eng.vmware.com>
Sat, 19 Sep 2009 01:49:13 +0000 (18:49 -0700)
Make the RpcChannel API more obvious by providing RpcChannel_Start
and RpcChannel_Stop functions instead of relying on the function
pointers in the RpcChannel struct.

Modify vmtoolsd code to use these functions.

Signed-off-by: Marcelo Vanzin <mvanzin@vmware.com>
open-vm-tools/lib/include/rpcChannel.h
open-vm-tools/services/vmtoolsd/mainLoop.c

index 93b5932b22650106aee932e01854c88943ef9be3..ea03cbf9c90c8db11cfadc19a5b8556aae22ad11 100644 (file)
@@ -42,6 +42,7 @@
 
 #include <rpc/rpc.h>
 #include "vm_basic_types.h"
+#include "vm_assert.h"
 #include "rpcin.h"
 
 struct RpcChannel;
@@ -114,6 +115,38 @@ typedef struct RpcChannel {
 } RpcChannel;
 
 
+/**
+ * Wrapper for the start function of an RPC channel struct.
+ *
+ * @param[in]  chan        The RPC channel instance.
+ *
+ * @return TRUE on success.
+ */
+static INLINE Bool
+RpcChannel_Start(RpcChannel *chan)
+{
+   ASSERT(chan != NULL);
+   ASSERT(chan->start != NULL);
+
+   return chan->start(chan);
+}
+
+
+/**
+ * Wrapper for the stop function of an RPC channel struct.
+ *
+ * @param[in]  chan        The RPC channel instance.
+ */
+
+static INLINE void
+RpcChannel_Stop(RpcChannel *chan)
+{
+   ASSERT(chan != NULL);
+   ASSERT(chan->stop != NULL);
+
+   chan->stop(chan);
+}
+
 /**
  * Wrapper for the send function of an RPC channel struct.
  *
@@ -133,6 +166,9 @@ RpcChannel_Send(RpcChannel *chan,
                 char **result,
                 size_t *resultLen)
 {
+   ASSERT(chan != NULL);
+   ASSERT(chan->send != NULL);
+
    return chan->send(chan, data, dataLen, result, resultLen);
 }
 
index b68c8c742209b4504cd3a8dabd91e0d61bb9a6eb..4c6bbfc8df45a2a3187ae006d6ee85070c7edb55 100644 (file)
@@ -292,7 +292,7 @@ ToolsCore_Setup(ToolsServiceState *state)
     * Start the RPC channel if it's been created. The channel may be NULL if this is
     * not running in the context of a VM.
     */
-   if (state->ctx.rpc && !state->ctx.rpc->start(state->ctx.rpc)) {
+   if (state->ctx.rpc && !RpcChannel_Start(state->ctx.rpc)) {
       goto error;
    }
 
@@ -305,7 +305,7 @@ ToolsCore_Setup(ToolsServiceState *state)
 
 error:
    if (state->ctx.rpc != NULL) {
-      state->ctx.rpc->shutdown(state->ctx.rpc);
+      RpcChannel_Destroy(state->ctx.rpc);
       state->ctx.rpc = NULL;
    }
    if (state->ctx.mainLoop != NULL) {