Esempio n. 1
0
static gboolean
TestDebugSendNext(RpcDebugMsgMapping *rpcdata)
{
   static RpcDebugMsgList msgList = { gRpcMessages, 0 };
   if (!RpcDebug_SendNext(rpcdata, &msgList)) {
      /*
       * Test for bug 391553: send two resets in sequence without
       * pumping the main loop. The channel should handle the second
       * reset successfully instead of asserting.
       */
      int i;
      for (i = 0; i < 2; i++) {
         RpcInData data;
         memset(&data, 0, sizeof data);
         data.clientData = gCtx->rpc;
         data.appCtx = gCtx;
         data.args = "reset";
         data.argsSize = sizeof "reset";

         g_debug("reset test %d\n", i + 1);
         RpcChannel_Dispatch(&data);
      }
      return FALSE;
   }
   return TRUE;
}
Esempio n. 2
0
static gboolean
RpcDebugDispatch(gpointer _chan)
{
   gboolean ret;
   RpcChannel *chan = _chan;
   DbgChannelData *cdata = chan->_private;
   RpcDebugPlugin *plugin = cdata->plugin;
   RpcInData data;
   RpcDebugMsgMapping rpcdata;

   memset(&data, 0, sizeof data);
   memset(&rpcdata, 0, sizeof rpcdata);

   if (plugin->sendFn == NULL || !plugin->sendFn(&rpcdata)) {
      RpcDebug_DecRef(cdata->ctx);
      cdata->hasLibRef = FALSE;
      return FALSE;
   } else if (rpcdata.message == NULL) {
      /*
       * Nothing to send. Maybe the debug plugin is waiting for something to
       * happen before sending another message.
       */
      return TRUE;
   }

   data.clientData = chan;
   data.appCtx = cdata->ctx;
   data.args = rpcdata.message;
   data.argsSize = rpcdata.messageLen;

   ret = RpcChannel_Dispatch(&data);
   if (rpcdata.validateFn != NULL) {
      ret = rpcdata.validateFn(&data, ret);
   } else if (!ret) {
      g_debug("RpcChannel_Dispatch returned error for RPC.\n");
   }

   if (data.freeResult) {
      vm_free(data.result);
   }

   if (rpcdata.freeMsg) {
      vm_free(rpcdata.message);
   }

   if (!ret) {
      VMTOOLSAPP_ERROR(cdata->ctx, 1);
      RpcDebug_DecRef(cdata->ctx);
      cdata->hasLibRef = FALSE;
      return FALSE;
   }
   return TRUE;
}