From: VMware, Inc <> Date: Fri, 18 Sep 2009 21:53:43 +0000 (-0700) Subject: rpcChannel: Add wrapper functions for start/stop. X-Git-Tag: 2009.09.18-193784~1 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=8bb94fbfbdf65b53b87279cf81529756dba7a2ca;p=thirdparty%2Fopen-vm-tools.git rpcChannel: Add wrapper functions for start/stop. 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 --- diff --git a/open-vm-tools/lib/include/rpcChannel.h b/open-vm-tools/lib/include/rpcChannel.h index 93b5932b2..ea03cbf9c 100644 --- a/open-vm-tools/lib/include/rpcChannel.h +++ b/open-vm-tools/lib/include/rpcChannel.h @@ -42,6 +42,7 @@ #include #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); } diff --git a/open-vm-tools/services/vmtoolsd/mainLoop.c b/open-vm-tools/services/vmtoolsd/mainLoop.c index b68c8c742..4c6bbfc8d 100644 --- a/open-vm-tools/services/vmtoolsd/mainLoop.c +++ b/open-vm-tools/services/vmtoolsd/mainLoop.c @@ -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) {