コード例 #1
0
ファイル: proxy.c プロジェクト: AndreRH/wine
/**************************************************************************
 *          WsCall		[webservices.@]
 */
HRESULT WINAPI WsCall( WS_SERVICE_PROXY *handle, const WS_OPERATION_DESCRIPTION *desc, const void **args,
                       WS_HEAP *heap, const WS_CALL_PROPERTY *properties, const ULONG count,
                       const WS_ASYNC_CONTEXT *ctx, WS_ERROR *error )
{
    struct proxy *proxy = (struct proxy *)handle;
    WS_MESSAGE *msg = NULL;
    HRESULT hr;
    ULONG i;

    TRACE( "%p %p %p %p %p %u %p %p\n", handle, desc, args, heap, properties, count, ctx, error );
    if (error) FIXME( "ignoring error parameter\n" );
    if (ctx) FIXME( "ignoring ctx parameter\n" );
    for (i = 0; i < count; i++)
    {
        if (properties[i].id != WS_CALL_PROPERTY_SEND_MESSAGE_CONTEXT &&
            properties[i].id != WS_CALL_PROPERTY_RECEIVE_MESSAGE_CONTEXT)
        {
            FIXME( "unimplemented call property %u\n", properties[i].id );
            return E_NOTIMPL;
        }
    }

    if (!proxy || !desc || (desc->parameterCount && !args)) return E_INVALIDARG;

    EnterCriticalSection( &proxy->cs );

    if (proxy->magic != PROXY_MAGIC)
    {
        LeaveCriticalSection( &proxy->cs );
        return E_INVALIDARG;
    }

    if ((hr = create_input_message( proxy->channel, properties, count, &msg )) != S_OK) goto done;
    if ((hr = send_message( proxy->channel, msg, desc->inputMessageDescription, desc->parameterDescription,
                            desc->parameterCount, args )) != S_OK) goto done;

    WsFreeMessage( msg );
    msg = NULL;

    if ((hr = create_output_message( proxy->channel, properties, count, &msg )) != S_OK) goto done;
    hr = receive_message( proxy->channel, msg, desc->outputMessageDescription, desc->parameterDescription,
                          desc->parameterCount, heap, args );

done:
    WsFreeMessage( msg );
    LeaveCriticalSection( &proxy->cs );
    return hr;
}
コード例 #2
0
ファイル: BPR_Drivers.cpp プロジェクト: binghuo365/BaseLab
int
Input_Device_Wrapper_Base::svc (void)
{
  ACE_Time_Value timeout;
  ACE_Message_Block *message;

  // Set a flag to indicate we're active.
  is_active_ = 1;

  // Start with the total count of messages to send.
  for (current_count_ = send_count_;
       // While we're still marked active, and there are packets to send.
       (is_active_) && (current_count_ != 0);
       )
    {
      // Create an input message to send.
      message = create_input_message ();
      if (message == 0)
        {
          if (is_active_)
            {
              is_active_ = 0;
              ACE_ERROR_RETURN ((LM_ERROR, "%t %p\n",
                                 "Failed to create input message object"),
                                 -1);
            }

          break;
        }

      // Make sure there is a send command object.
      if (send_input_msg_cmd_ == 0)
        {
          delete message;
          if (is_active_)
            {
              is_active_ = 0;
              ACE_ERROR_RETURN ((LM_ERROR, "%t %p\n",
                                 "send message command object not instantiated"),
                                -1);
            }

          break;
        }

      // Send the input message.
      if (send_input_msg_cmd_->execute ((void *) message) < 0)
        {
          delete message;
          if (is_active_)
            {
              is_active_ = 0;
              ACE_ERROR_RETURN ((LM_ERROR, "%t %p\n",
                                 "Failed executing send message command object"),
                                -1);
            }

          break;
        }

      // If all went well, decrement count of messages to send, and
      // run the reactor event loop unti we get a timeout or something
      // happens in a registered upcall.
      if (current_count_ > 0)
        --current_count_;

      timeout = ACE_Time_Value (0, input_period_);
      reactor_.run_event_loop (timeout);
    }

  is_active_ = 0;

  return 0;
}