(file) Return to client.cpp CVS log (file) (dir) Up to [OMI] / omi / omiclient

Diff for /omi/omiclient/client.cpp between version 1.1 and 1.3

version 1.1, 2012/05/30 22:47:49 version 1.3, 2015/04/20 18:19:55
Line 25 
Line 25 
 #include "client.h" #include "client.h"
 #include <base/packing.h> #include <base/packing.h>
 #include <protocol/protocol.h> #include <protocol/protocol.h>
 #include <base/time.h>  #include <pal/sleep.h>
 #include <base/paths.h> #include <base/paths.h>
 #include "thread.h"  #include <pal/thread.h>
   #include <base/log.h>
 #define TRACE printf("TRACE: %s(%u)\n", __FILE__, __LINE__)  
  
 #if 0 #if 0
 # define D(X) X # define D(X) X
Line 37 
Line 36 
 # define D(X) /* empty */ # define D(X) /* empty */
 #endif #endif
  
   STRAND_DEBUGNAME(OmiClient);
   
 MI_BEGIN_NAMESPACE MI_BEGIN_NAMESPACE
  
 //============================================================================== //==============================================================================
Line 45 
Line 46 
 // //
 //============================================================================== //==============================================================================
  
 Uint64 _NextMsgID()  PAL_Uint64 _NextOperationId()
 { {
     static Mutex mutex;      static volatile ptrdiff_t _operationId = 10000;
     mutex.Lock();      PAL_Uint64 x = Atomic_Inc(&_operationId);
     static Uint64 _msgID = 10000;  
     Uint64 x = _msgID++;  
     mutex.Unlock();  
  
     return x;     return x;
 } }
Line 74 
Line 72 
     return r;     return r;
 } }
  
   static String _StrToString(const char* str)
   {
       String r;
   
       while (str)
       {
           MI_Char c = *str++;
           r.Append(&c, 1);
       }
   
       return r;
   }
   
 //============================================================================== //==============================================================================
 // //
 // class EnvelopeHandler // class EnvelopeHandler
Line 106 
Line 117 
             m_handler->HandleDisconnect();             m_handler->HandleDisconnect();
     }     }
  
     virtual void HandleNoOp(Uint64 msgID)      virtual void HandleNoOp(Uint64 operationId)
     {     {
         if (m_handler)         if (m_handler)
             m_handler->HandleNoOp(msgID);              m_handler->HandleNoOp(operationId);
     }     }
  
     virtual void HandleInstance(Uint64 msgID, const DInstance& instance)      virtual void HandleInstance(Uint64 operationId, const DInstance& instance)
     {     {
         if (m_handler)         if (m_handler)
             m_handler->HandleInstance(msgID, instance);              m_handler->HandleInstance(operationId, instance);
     }     }
  
     virtual void HandleResult(Uint64 msgID, MI_Result result)      virtual void HandleResult(Uint64 operationId, MI_Result result)
     {     {
         if (m_handler)         if (m_handler)
             m_handler->HandleResult(msgID, result);              m_handler->HandleResult(operationId, result);
       }
       virtual void HandleResult(Uint64 operationId, MI_Result result, const MI_Char *error, const DInstance* cimError)
       {
           if (m_handler)
               m_handler->HandleResult(operationId, result, error, cimError);
     }     }
  
 private: private:
Line 140 
Line 156 
  
     enum State { START, DONE, FAILED };     enum State { START, DONE, FAILED };
  
     NoOpHandler(Handler* handler, Uint64 msgID) :      NoOpHandler(Handler* handler, Uint64 operationId) :
         EnvelopeHandler(handler), m_state(START), m_msgID(msgID)          EnvelopeHandler(handler), m_state(START), m_operationId(operationId)
     {     {
     }     }
  
     virtual void HandleNoOp(Uint64 msgID)      virtual void HandleNoOp(Uint64 operationId)
     {     {
         if (msgID != m_msgID)          if (operationId != m_operationId)
         {         {
             EnvelopeHandler::HandleNoOp(msgID);              EnvelopeHandler::HandleNoOp(operationId);
             return;             return;
         }         }
  
Line 163 
Line 179 
     }     }
  
     State m_state;     State m_state;
     Uint64 m_msgID;      Uint64 m_operationId;
 }; };
  
 //============================================================================== //==============================================================================
Line 178 
Line 194 
  
     enum State { START, DONE, FAILED };     enum State { START, DONE, FAILED };
  
     ResultHandler(Handler* handler, Uint64 msgID) :      ResultHandler(Handler* handler, Uint64 operationId) :
         EnvelopeHandler(handler),         EnvelopeHandler(handler),
         m_state(START),         m_state(START),
         m_msgID(msgID),          m_operationId(operationId),
         m_result(MI_RESULT_OK)          m_result(MI_RESULT_OK),
           m_cimerror(NULL),
           m_errorMessage(NULL)
     {     {
     }     }
  
     virtual void HandleResult(Uint64 msgID, Result result)      virtual void HandleResult(Uint64 operationId, Result result)
     {     {
         if (msgID != m_msgID)          if (operationId != m_operationId)
         {         {
             EnvelopeHandler::HandleResult(msgID, result);              EnvelopeHandler::HandleResult(operationId, result);
             return;             return;
         }         }
  
Line 204 
Line 222 
         m_state = DONE;         m_state = DONE;
     }     }
  
       virtual void HandleResult(Uint64 operationId, MI_Result result, const MI_Char *error, const DInstance* cimError)
       {
           if (operationId != m_operationId)
           {
               EnvelopeHandler::HandleResult(operationId, result, error, cimError);
               return;
           }
   
           if (m_state != START)
           {
               m_state = FAILED;
               return;
           }
   
           m_result = result;
           m_cimerror = cimError;
           m_errorMessage = error;
           m_state = DONE;
       }
   
     State m_state;     State m_state;
     Uint64 m_msgID;      Uint64 m_operationId;
     Result m_result;     Result m_result;
       const DInstance* m_cimerror;
       const MI_Char *m_errorMessage;
 }; };
  
 //============================================================================== //==============================================================================
Line 223 
Line 263 
  
     InstanceHandler(     InstanceHandler(
         Handler* handler,         Handler* handler,
         Uint64 msgID,          Uint64 operationId,
         DInstance& instance)         DInstance& instance)
         :         :
         EnvelopeHandler(handler),         EnvelopeHandler(handler),
         m_state(INSTANCE),         m_state(INSTANCE),
         m_msgID(msgID),          m_operationId(operationId),
         m_instance(instance),         m_instance(instance),
         m_result(MI_RESULT_OK)          m_result(MI_RESULT_OK),
           m_errorMessage(NULL),
           m_cimerror(NULL)
     {     {
     }     }
  
     virtual void HandleInstance(Uint64 msgID, const DInstance& instance)      virtual void HandleInstance(Uint64 operationId, const DInstance& instance)
     {     {
         if (msgID != m_msgID)          if (operationId != m_operationId)
         {         {
             EnvelopeHandler::HandleInstance(msgID, instance);              EnvelopeHandler::HandleInstance(operationId, instance);
             return;             return;
         }         }
  
Line 252 
Line 294 
         m_state = RESULT;         m_state = RESULT;
     }     }
  
     virtual void HandleResult(Uint64 msgID, Result result)      virtual void HandleResult(Uint64 operationId, Result result)
     {     {
         if (msgID != m_msgID)          if (operationId != m_operationId)
         {         {
             EnvelopeHandler::HandleResult(msgID, result);              EnvelopeHandler::HandleResult(operationId, result);
             return;             return;
         }         }
  
Line 270 
Line 312 
         m_state = DONE;         m_state = DONE;
     }     }
  
       virtual void HandleResult(Uint64 operationId, MI_Result result, const MI_Char *error, const DInstance* cimError)
       {
           if (operationId != m_operationId)
           {
               EnvelopeHandler::HandleResult(operationId, result, error, cimError);
               return;
           }
   
           if (m_state != INSTANCE && m_state != RESULT)
           {
               m_state = FAILED;
               return;
           }
   
           m_result = result;
           m_cimerror = cimError;
           m_errorMessage = error;
           m_state = DONE;
       }
   
     State m_state;     State m_state;
     Uint64 m_msgID;      Uint64 m_operationId;
     DInstance& m_instance;     DInstance& m_instance;
     Result m_result;     Result m_result;
       const MI_Char *m_errorMessage;
       const DInstance* m_cimerror;
 }; };
  
 //============================================================================== //==============================================================================
Line 290 
Line 354 
  
     InstancesHandler(     InstancesHandler(
         Handler* handler,         Handler* handler,
         Uint64 msgID,          Uint64 operationId,
         Array<DInstance>& instances)         Array<DInstance>& instances)
         :         :
         EnvelopeHandler(handler),         EnvelopeHandler(handler),
         m_state(INSTANCES),         m_state(INSTANCES),
         m_msgID(msgID),          m_operationId(operationId),
         m_instances(instances),         m_instances(instances),
         m_result(MI_RESULT_OK)         m_result(MI_RESULT_OK)
     {     {
     }     }
  
     virtual void HandleInstance(Uint64 msgID, const DInstance& instance)      virtual void HandleInstance(Uint64 operationId, const DInstance& instance)
     {     {
         if (msgID != m_msgID)          if (operationId != m_operationId)
         {         {
             EnvelopeHandler::HandleInstance(msgID, instance);              EnvelopeHandler::HandleInstance(operationId, instance);
             return;             return;
         }         }
  
Line 318 
Line 382 
         m_instances.PushBack(instance);         m_instances.PushBack(instance);
     }     }
  
     virtual void HandleResult(Uint64 msgID, Result result)      virtual void HandleResult(Uint64 operationId, Result result)
       {
           if (operationId != m_operationId)
           {
               EnvelopeHandler::HandleResult(operationId, result);
               return;
           }
   
           if (m_state != INSTANCES)
           {
               m_state = FAILED;
               return;
           }
   
           m_result = result;
           m_state = DONE;
       }
   
       virtual void HandleResult(Uint64 operationId, Result result, const MI_Char *error, const DInstance* cimError)
     {     {
         if (msgID != m_msgID)          if (operationId != m_operationId)
         {         {
             EnvelopeHandler::HandleResult(msgID, result);              EnvelopeHandler::HandleResult(operationId, result);
             return;             return;
         }         }
  
Line 337 
Line 419 
     }     }
  
     State m_state;     State m_state;
     Uint64 m_msgID;      Uint64 m_operationId;
     Array<DInstance>& m_instances;     Array<DInstance>& m_instances;
     Result m_result;     Result m_result;
 }; };
Line 359 
Line 441 
         CONNECTSTATE_DISCONNECTED         CONNECTSTATE_DISCONNECTED
     };     };
  
     Protocol* protocol;      ProtocolSocketAndBase* protocol;
       Strand strand;  // To manage interaction with ProtocolSocket
     Handler* handler;     Handler* handler;
     ConnectState connectState;     ConnectState connectState;
  
     static void EventCallback(      static void MessageCallback(
         Protocol* protocol,          ClientRep * rep,
         ProtocolEvent event,          Message* msg);
         void* data);  
   
     static MI_Boolean MessageCallback(  
         Protocol* protocol,  
         Message* msg,  
         void* data);  
  
     bool NoOpAsync(     bool NoOpAsync(
         Uint64 msgID);          Uint64 operationId);
  
     bool GetInstanceAsync(     bool GetInstanceAsync(
         const String& nameSpace,         const String& nameSpace,
         const DInstance& instanceName,         const DInstance& instanceName,
         Uint64 msgID);          Uint64 operationId);
  
     bool CreateInstanceAsync(     bool CreateInstanceAsync(
         const String& nameSpace,         const String& nameSpace,
         const DInstance& instance,         const DInstance& instance,
         Uint64 msgID);          Uint64 operationId);
  
     bool ModifyInstanceAsync(     bool ModifyInstanceAsync(
         const String& nameSpace,         const String& nameSpace,
         const DInstance& instance,         const DInstance& instance,
         Uint64 msgID);          Uint64 operationId);
  
     bool DeleteInstanceAsync(     bool DeleteInstanceAsync(
         const String& nameSpace,         const String& nameSpace,
         const DInstance& instanceName,         const DInstance& instanceName,
         Uint64 msgID);          Uint64 operationId);
  
     bool EnumerateInstancesAsync(     bool EnumerateInstancesAsync(
         const String& nameSpace,         const String& nameSpace,
Line 402 
Line 479 
         bool deepInheritance,         bool deepInheritance,
         const String& queryLanguage,         const String& queryLanguage,
         const String& queryExpression,         const String& queryExpression,
         Uint64 msgID);          Uint64 operationId);
  
     bool InvokeAsync(     bool InvokeAsync(
         const String& nameSpace,         const String& nameSpace,
Line 410 
Line 487 
         const String& methodName,         const String& methodName,
         const DInstance& inParameters,         const DInstance& inParameters,
         DInstance& outParameters,         DInstance& outParameters,
         Uint64 msgID);          Uint64 operationId);
  
     bool AssociatorInstancesAsync(     bool AssociatorInstancesAsync(
         const String& nameSpace,         const String& nameSpace,
Line 419 
Line 496 
         const String& resultClass,         const String& resultClass,
         const String& role,         const String& role,
         const String& resultRole,         const String& resultRole,
         Uint64& msgID);          Uint64& operationId);
  
     bool ReferenceInstancesAsync(     bool ReferenceInstancesAsync(
         const String& nameSpace,         const String& nameSpace,
         const DInstance& instanceName,         const DInstance& instanceName,
         const String& assocClass,          const String& resultClass,
         const String& role,         const String& role,
         Uint64& msgID);          Uint64& operationId);
 }; };
  
 void ClientRep::EventCallback(  void ClientRep::MessageCallback(
     Protocol* protocol,      ClientRep * clientRep,
     ProtocolEvent event,      Message* msg)
     void* data)  
 {  
     ClientRep* clientRep = (ClientRep*)data;  
     Handler* handler = clientRep->handler;  
   
     D( printf("==== ClientRep::EventCallback()\n"); )  
   
   
     if (event == PROTOCOLEVENT_CONNECT)  
     {  
         D( printf("==== EventCallback() PROTOCOLEVENT_CONNECT\n"); )  
         clientRep->connectState = ClientRep::CONNECTSTATE_CONNECTED;  
         if (handler)  
             handler->HandleConnect();  
         return;  
     }  
   
     if (event == PROTOCOLEVENT_CONNECT_FAILED)  
     {  
         D( printf("==== EventCallback() PROTOCOLEVENT_CONNECT_FAILED\n"); )  
         if (handler)  
             handler->HandleConnectFailed();  
         clientRep->connectState = ClientRep::CONNECTSTATE_FAILED;  
         return;  
     }  
   
     if (event == PROTOCOLEVENT_DISCONNECT)  
     {  
         D( printf("==== EventCallback() PROTOCOLEVENT_DISCONNECT\n"); )  
         if (handler)  
             handler->HandleDisconnect();  
         clientRep->connectState = ClientRep::CONNECTSTATE_DISCONNECTED;  
         return;  
     }  
 }  
   
 MI_Boolean ClientRep::MessageCallback(  
     Protocol* protocol,  
     Message* msg,  
     void* data)  
 { {
     ClientRep* clientRep = (ClientRep*)data;  
     Handler* handler = clientRep->handler;     Handler* handler = clientRep->handler;
  
     DEBUG_ASSERT(msg != 0);     DEBUG_ASSERT(msg != 0);
Line 486 
Line 522 
             NoOpRsp* rsp = (NoOpRsp*)msg;             NoOpRsp* rsp = (NoOpRsp*)msg;
             MI_UNUSED(rsp);             MI_UNUSED(rsp);
             if (handler)             if (handler)
                 handler->HandleNoOp(rsp->base.msgID);                  handler->HandleNoOp(rsp->base.operationId);
             break;             break;
         }         }
         case PostInstanceMsgTag:         case PostInstanceMsgTag:
Line 498 
Line 534 
             {             {
                 DInstance di(rsp->instance, DInstance::CLONE);                 DInstance di(rsp->instance, DInstance::CLONE);
                 if (handler)                 if (handler)
                     handler->HandleInstance(rsp->base.msgID, di);                      handler->HandleInstance(rsp->base.operationId, di);
             }             }
  
             break;             break;
         }         }
         case SubscribeResTag:  
         {  
             D( printf("ClientRep::MessageCallback(): SubscribeResTag\n"); )  
             SubscribeRes* rsp = (SubscribeRes*)msg;  
             MI_UNUSED(rsp);  
             break;  
         }  
         case PostResultMsgTag:         case PostResultMsgTag:
         {         {
             D( printf("ClientRep::MessageCallback(): PostResultMsgTag\n"); )             D( printf("ClientRep::MessageCallback(): PostResultMsgTag\n"); )
             PostResultMsg* rsp = (PostResultMsg*)msg;             PostResultMsg* rsp = (PostResultMsg*)msg;
             if (handler)             if (handler)
                 handler->HandleResult(rsp->base.msgID, rsp->result);              {
                   if (rsp->cimError)
                   {
                       DInstance di((MI_Instance*)(rsp->cimError), DInstance::CLONE);
                       handler->HandleResult(rsp->base.operationId, rsp->result, rsp->errorMessage, &di);
                   }
                   else
                   {
                       handler->HandleResult(rsp->base.operationId, rsp->result, rsp->errorMessage, NULL);
                   }
               }
             break;             break;
         }         }
         default:         default:
Line 524 
Line 563 
             break;             break;
         }         }
     }     }
     return MI_TRUE;  
 } }
  
 bool ClientRep::NoOpAsync( bool ClientRep::NoOpAsync(
     Uint64 msgID)      Uint64 operationId)
 { {
     NoOpReq* req = 0;     NoOpReq* req = 0;
     bool result = true;     bool result = true;
  
     // Fail if not connected:     // Fail if not connected:
     if (!protocol)      if( !protocol || !strand.info.opened )
     {     {
         result = false;         result = false;
         goto done;         goto done;
Line 542 
Line 580 
  
     // Create request message:     // Create request message:
     {     {
         req = NoOpReq_New(msgID);          req = NoOpReq_New(operationId);
  
         if (!req)         if (!req)
         {         {
Line 553 
Line 591 
  
     // Send the message:     // Send the message:
     {     {
         Result r = Protocol_Send(protocol, &req->base);          Strand_SchedulePost(&strand,&req->base.base);
   
         if (r != MI_RESULT_OK)  
         {  
             result = false;  
             goto done;  
         }  
     }     }
  
 done: done:
Line 573 
Line 605 
 bool ClientRep::GetInstanceAsync( bool ClientRep::GetInstanceAsync(
     const String& nameSpace,     const String& nameSpace,
     const DInstance& instanceName,     const DInstance& instanceName,
     Uint64 msgID)      Uint64 operationId)
 { {
     GetInstanceReq* req = 0;     GetInstanceReq* req = 0;
     bool result = true;     bool result = true;
  
     // Fail if not connected.     // Fail if not connected.
     if (!protocol)      if( !protocol || !strand.info.opened )
     {     {
         result = false;         result = false;
         goto done;         goto done;
Line 587 
Line 619 
  
     // Create the request message:     // Create the request message:
     {     {
         req = GetInstanceReq_New(msgID, BinaryProtocolFlag);          req = GetInstanceReq_New(operationId, BinaryProtocolFlag);
  
         if (!req)         if (!req)
         {         {
Line 597 
Line 629 
     }     }
  
     // Set nameSpace:     // Set nameSpace:
     req->nameSpace = Batch_Zdup(req->base.batch, nameSpace.Str());      req->nameSpace = Batch_Tcsdup(req->base.base.batch, nameSpace.Str());
       if (!req->nameSpace)
       {
           result = false;
           goto done;
       }
  
     // Pack the instance name into the message's batch.     // Pack the instance name into the message's batch.
     {     {
Line 605 
Line 642 
             instanceName.m_self,             instanceName.m_self,
             NULL,             NULL,
             NULL,             NULL,
             req->base.batch,              req->base.base.batch,
             &req->packedInstanceNamePtr,             &req->packedInstanceNamePtr,
             &req->packedInstanceNameSize);             &req->packedInstanceNameSize);
  
Line 618 
Line 655 
  
     // Send the messages:     // Send the messages:
     {     {
         Result r = Protocol_Send(protocol, &req->base);          Strand_SchedulePost(&strand,&req->base.base);
   
         if (r != MI_RESULT_OK)  
         {  
             result = false;  
             goto done;  
         }  
     }     }
  
 done: done:
Line 637 
Line 668 
 bool ClientRep::CreateInstanceAsync( bool ClientRep::CreateInstanceAsync(
     const String& nameSpace,     const String& nameSpace,
     const DInstance& instance,     const DInstance& instance,
     Uint64 msgID)      Uint64 operationId)
 { {
     CreateInstanceReq* req = 0;     CreateInstanceReq* req = 0;
     bool result = true;     bool result = true;
  
     // Fail if not connected.     // Fail if not connected.
     if (!protocol)      if( !protocol || !strand.info.opened )
     {     {
         result = false;         result = false;
         goto done;         goto done;
Line 651 
Line 682 
  
     // Create the request message:     // Create the request message:
     {     {
         req = CreateInstanceReq_New(msgID, BinaryProtocolFlag);          req = CreateInstanceReq_New(operationId, BinaryProtocolFlag);
  
         if (!req)         if (!req)
         {         {
Line 661 
Line 692 
     }     }
  
     // Set nameSpace:     // Set nameSpace:
     req->nameSpace = Batch_Zdup(req->base.batch, nameSpace.Str());      req->nameSpace = Batch_Tcsdup(req->base.base.batch, nameSpace.Str());
       if (!req->nameSpace)
       {
           result = false;
           goto done;
       }
  
     // Pack the instance name into the message's batch.     // Pack the instance name into the message's batch.
     {     {
Line 669 
Line 705 
             instance.m_self,             instance.m_self,
             NULL,             NULL,
             NULL,             NULL,
             req->base.batch,              req->base.base.batch,
             &req->packedInstancePtr,             &req->packedInstancePtr,
             &req->packedInstanceSize);             &req->packedInstanceSize);
  
Line 682 
Line 718 
  
     // Send the messages:     // Send the messages:
     {     {
         Result r = Protocol_Send(protocol, &req->base);          Strand_SchedulePost(&strand,&req->base.base);
   
         if (r != MI_RESULT_OK)  
         {  
             result = false;  
             goto done;  
         }  
     }     }
  
 done: done:
Line 701 
Line 731 
 bool ClientRep::ModifyInstanceAsync( bool ClientRep::ModifyInstanceAsync(
     const String& nameSpace,     const String& nameSpace,
     const DInstance& instance,     const DInstance& instance,
     Uint64 msgID)      Uint64 operationId)
 { {
     ModifyInstanceReq* req = 0;     ModifyInstanceReq* req = 0;
     bool result = true;     bool result = true;
  
     // Fail if not connected.     // Fail if not connected.
     if (!protocol)      if( !protocol || !strand.info.opened )
     {     {
         result = false;         result = false;
         goto done;         goto done;
Line 715 
Line 745 
  
     // Create the request message:     // Create the request message:
     {     {
         req = ModifyInstanceReq_New(msgID, BinaryProtocolFlag);          req = ModifyInstanceReq_New(operationId, BinaryProtocolFlag);
  
         if (!req)         if (!req)
         {         {
Line 725 
Line 755 
     }     }
  
     // Set nameSpace:     // Set nameSpace:
     req->nameSpace = Batch_Zdup(req->base.batch, nameSpace.Str());      req->nameSpace = Batch_Tcsdup(req->base.base.batch, nameSpace.Str());
       if (!req->nameSpace)
       {
           result = false;
           goto done;
       }
  
     // Pack the instance name into the message's batch.     // Pack the instance name into the message's batch.
     {     {
Line 733 
Line 768 
             instance.m_self,             instance.m_self,
             NULL,             NULL,
             NULL,             NULL,
             req->base.batch,              req->base.base.batch,
             &req->packedInstancePtr,             &req->packedInstancePtr,
             &req->packedInstanceSize);             &req->packedInstanceSize);
  
Line 745 
Line 780 
     }     }
  
     // Send the messages:     // Send the messages:
     {      Strand_SchedulePost(&strand,&req->base.base);
         Result r = Protocol_Send(protocol, &req->base);  
   
         if (r != MI_RESULT_OK)  
         {  
             result = false;  
             goto done;  
         }  
     }  
  
 done: done:
     if (req)     if (req)
Line 765 
Line 792 
 bool ClientRep::DeleteInstanceAsync( bool ClientRep::DeleteInstanceAsync(
     const String& nameSpace,     const String& nameSpace,
     const DInstance& instanceName,     const DInstance& instanceName,
     Uint64 msgID)      Uint64 operationId)
 { {
     DeleteInstanceReq* req = 0;     DeleteInstanceReq* req = 0;
     bool result = true;     bool result = true;
  
     // Fail if not connected.     // Fail if not connected.
     if (!protocol)      if( !protocol || !strand.info.opened )
     {     {
         result = false;         result = false;
         goto done;         goto done;
Line 779 
Line 806 
  
     // Create the request message:     // Create the request message:
     {     {
         req = DeleteInstanceReq_New(msgID, BinaryProtocolFlag);          req = DeleteInstanceReq_New(operationId, BinaryProtocolFlag);
  
         if (!req)         if (!req)
         {         {
Line 789 
Line 816 
     }     }
  
     // Set nameSpace:     // Set nameSpace:
     req->nameSpace = Batch_Zdup(req->base.batch, nameSpace.Str());      req->nameSpace = Batch_Tcsdup(req->base.base.batch, nameSpace.Str());
       if (!req->nameSpace)
       {
           result = false;
           goto done;
       }
  
     // Pack the instance name into the message's batch.     // Pack the instance name into the message's batch.
     {     {
Line 797 
Line 829 
             instanceName.m_self,             instanceName.m_self,
             NULL,             NULL,
             NULL,             NULL,
             req->base.batch,              req->base.base.batch,
             &req->packedInstanceNamePtr,             &req->packedInstanceNamePtr,
             &req->packedInstanceNameSize);             &req->packedInstanceNameSize);
  
Line 809 
Line 841 
     }     }
  
     // Send the messages:     // Send the messages:
     {      Strand_SchedulePost(&strand,&req->base.base);
         Result r = Protocol_Send(protocol, &req->base);  
   
         if (r != MI_RESULT_OK)  
         {  
             result = false;  
             goto done;  
         }  
     }  
  
 done: done:
     if (req)     if (req)
Line 832 
Line 856 
     bool deepInheritance,     bool deepInheritance,
     const String& queryLanguage,     const String& queryLanguage,
     const String& queryExpression,     const String& queryExpression,
     Uint64 msgID)      Uint64 operationId)
 { {
     EnumerateInstancesReq* req = 0;     EnumerateInstancesReq* req = 0;
     bool result = true;     bool result = true;
  
     // Fail if not connected.     // Fail if not connected.
     if (!protocol)      if( !protocol || !strand.info.opened )
     {     {
         result = false;         result = false;
         goto done;         goto done;
Line 846 
Line 870 
  
     // Create the request message:     // Create the request message:
     {     {
         req = EnumerateInstancesReq_New(msgID, BinaryProtocolFlag);          req = EnumerateInstancesReq_New(operationId, BinaryProtocolFlag);
  
         if (!req)         if (!req)
         {         {
Line 857 
Line 881 
  
     // Populate the fields of the request message:     // Populate the fields of the request message:
     {     {
         req->nameSpace = Batch_Zdup(req->base.batch, nameSpace.Str());          req->nameSpace = Batch_Tcsdup(req->base.base.batch, nameSpace.Str());
         req->className = Batch_Zdup(req->base.batch, className.Str());          req->className = Batch_Tcsdup(req->base.base.batch, className.Str());
   
           if (!req->nameSpace || !req->className)
           {
               result = false;
               goto done;
           }
  
         if (queryLanguage.GetSize())         if (queryLanguage.GetSize())
         {         {
             req->queryLanguage =             req->queryLanguage =
                 Batch_Zdup(req->base.batch, queryLanguage.Str());                  Batch_Tcsdup(req->base.base.batch, queryLanguage.Str());
               if (!req->queryLanguage)
               {
                   result = false;
                   goto done;
               }
         }         }
  
         if (queryExpression.GetSize())         if (queryExpression.GetSize())
         {         {
             req->queryExpression =             req->queryExpression =
                 Batch_Zdup(req->base.batch, queryExpression.Str());                  Batch_Tcsdup(req->base.base.batch, queryExpression.Str());
               if (!req->queryExpression)
               {
                   result = false;
                   goto done;
               }
         }         }
  
         req->deepInheritance = deepInheritance;         req->deepInheritance = deepInheritance;
     }     }
  
     // Send the messages:     // Send the messages:
     {      Strand_SchedulePost(&strand,&req->base.base);
         Result r = Protocol_Send(protocol, &req->base);  
   
         if (r != MI_RESULT_OK)  
         {  
             result = false;  
             goto done;  
         }  
     }  
  
 done: done:
     if (req)     if (req)
Line 899 
Line 931 
     const String& methodName,     const String& methodName,
     const DInstance& inParameters,     const DInstance& inParameters,
     DInstance& outParameters,     DInstance& outParameters,
     Uint64 msgID)      Uint64 operationId)
 { {
     InvokeReq* req = 0;     InvokeReq* req = 0;
     bool result = true;     bool result = true;
  
     // Fail if not connected.     // Fail if not connected.
     if (!protocol)      if( !protocol || !strand.info.opened )
     {     {
         result = false;         result = false;
         goto done;         goto done;
Line 913 
Line 945 
  
     // Create the request message:     // Create the request message:
     {     {
         req = InvokeReq_New(msgID, BinaryProtocolFlag);          req = InvokeReq_New(operationId, BinaryProtocolFlag);
  
         if (!req)         if (!req)
         {         {
Line 923 
Line 955 
     }     }
  
     // Set nameSpace:     // Set nameSpace:
     req->nameSpace = Batch_Zdup(req->base.batch, nameSpace.Str());      req->nameSpace = Batch_Tcsdup(req->base.base.batch, nameSpace.Str());
       if (!req->nameSpace)
       {
           result = false;
           goto done;
       }
  
     // Set className:     // Set className:
     req->className = Batch_Zdup(req->base.batch,      req->className = Batch_Tcsdup(req->base.base.batch,
         instanceName.GetClassName().Str());         instanceName.GetClassName().Str());
       if (!req->className)
       {
           result = false;
           goto done;
       }
  
     // Set methodName:     // Set methodName:
     req->function = Batch_Zdup(req->base.batch, methodName.Str());      req->function = Batch_Tcsdup(req->base.base.batch, methodName.Str());
       if (!req->function)
       {
           result = false;
           goto done;
       }
  
     // Pack instanceName:     // Pack instanceName:
     if (instanceName.Count())     if (instanceName.Count())
Line 939 
Line 986 
             instanceName.m_self,             instanceName.m_self,
             NULL,             NULL,
             NULL,             NULL,
             req->base.batch,              req->base.base.batch,
             &req->packedInstancePtr,             &req->packedInstancePtr,
             &req->packedInstanceSize);             &req->packedInstanceSize);
  
Line 956 
Line 1003 
             inParameters.m_self,             inParameters.m_self,
             NULL,             NULL,
             NULL,             NULL,
             req->base.batch,              req->base.base.batch,
             &req->packedInstanceParamsPtr,             &req->packedInstanceParamsPtr,
             &req->packedInstanceParamsSize);             &req->packedInstanceParamsSize);
  
Line 968 
Line 1015 
     }     }
  
     // Send the messages:     // Send the messages:
     {      Strand_SchedulePost(&strand,&req->base.base);
         Result r = Protocol_Send(protocol, &req->base);  
   
         if (r != MI_RESULT_OK)  
         {  
             result = false;  
             goto done;  
         }  
     }  
  
 done: done:
     if (req)     if (req)
Line 992 
Line 1031 
     const String& resultClass,     const String& resultClass,
     const String& role,     const String& role,
     const String& resultRole,     const String& resultRole,
     Uint64& msgID)      Uint64& operationId)
 { {
     AssociatorsOfReq* req = 0;      AssociationsOfReq* req = 0;
     bool result = true;     bool result = true;
  
     // Fail if not connected.     // Fail if not connected.
     if (!protocol)      if( !protocol || !strand.info.opened )
     {     {
         result = false;         result = false;
         goto done;         goto done;
Line 1006 
Line 1045 
  
     // Create the request message:     // Create the request message:
     {     {
         req = AssociatorsOfReq_New(msgID, BinaryProtocolFlag);          req = AssociationsOfReq_New(operationId, BinaryProtocolFlag, AssociatorsOfReqTag);
  
         if (!req)         if (!req)
         {         {
Line 1016 
Line 1055 
     }     }
  
     // Set nameSpace:     // Set nameSpace:
     req->nameSpace = Batch_Zdup(req->base.batch, nameSpace.Str());      req->nameSpace = Batch_Tcsdup(req->base.base.batch, nameSpace.Str());
       if (!req->nameSpace)
       {
           result = false;
           goto done;
       }
  
     // Set assocClass:     // Set assocClass:
     if (assocClass.GetSize())     if (assocClass.GetSize())
         req->assocClass = Batch_Zdup(req->base.batch, assocClass.Str());      {
           req->assocClass = Batch_Tcsdup(req->base.base.batch, assocClass.Str());
           if (!req->assocClass)
           {
               result = false;
               goto done;
           }
       }
  
     // Set resultClass:     // Set resultClass:
     if (resultClass.GetSize())     if (resultClass.GetSize())
         req->resultClass = Batch_Zdup(req->base.batch,resultClass.Str());      {
           req->resultClass = Batch_Tcsdup(req->base.base.batch,resultClass.Str());
           if (!req->resultClass)
           {
               result = false;
               goto done;
           }
       }
  
     // Set role:     // Set role:
     if (role.GetSize())     if (role.GetSize())
         req->role = Batch_Zdup(req->base.batch, role.Str());      {
           req->role = Batch_Tcsdup(req->base.base.batch, role.Str());
           if (!req->role)
           {
               result = false;
               goto done;
           }
       }
  
     // Set resultRole:     // Set resultRole:
     if (resultRole.GetSize())     if (resultRole.GetSize())
         req->resultRole = Batch_Zdup(req->base.batch, resultRole.Str());      {
           req->resultRole = Batch_Tcsdup(req->base.base.batch, resultRole.Str());
           if (!req->resultRole)
           {
               result = false;
               goto done;
           }
       }
  
     // Pack the instance name into the message's batch.     // Pack the instance name into the message's batch.
     {     {
Line 1040 
Line 1112 
             instanceName.m_self,             instanceName.m_self,
             NULL,             NULL,
             NULL,             NULL,
             req->base.batch,              req->base.base.batch,
             &req->packedInstancePtr,             &req->packedInstancePtr,
             &req->packedInstanceSize);             &req->packedInstanceSize);
  
Line 1052 
Line 1124 
     }     }
  
     // Send the messages:     // Send the messages:
     {      Strand_SchedulePost(&strand,&req->base.base);
         Result r = Protocol_Send(protocol, &req->base);  
   
         if (r != MI_RESULT_OK)  
         {  
             result = false;  
             goto done;  
         }  
     }  
  
 done: done:
     if (req)     if (req)
     {     {
         AssociatorsOfReq_Release(req);          AssociationsOfReq_Release(req);
     }     }
  
     return result;     return result;
Line 1074 
Line 1138 
 bool ClientRep::ReferenceInstancesAsync( bool ClientRep::ReferenceInstancesAsync(
     const String& nameSpace,     const String& nameSpace,
     const DInstance& instanceName,     const DInstance& instanceName,
     const String& assocClass,      const String& resultClass,
     const String& role,     const String& role,
     Uint64& msgID)      Uint64& operationId)
 { {
     ReferencesOfReq* req = 0;      AssociationsOfReq* req = 0;
     bool result = true;     bool result = true;
  
     // Fail if not connected.     // Fail if not connected.
     if (!protocol)      if( !protocol || !strand.info.opened )
     {     {
         result = false;         result = false;
         goto done;         goto done;
Line 1090 
Line 1154 
  
     // Create the request message:     // Create the request message:
     {     {
         req = ReferencesOfReq_New(msgID, BinaryProtocolFlag);          req = AssociationsOfReq_New(operationId, BinaryProtocolFlag, ReferencesOfReqTag);
  
         if (!req)         if (!req)
         {         {
Line 1100 
Line 1164 
     }     }
  
     // Set nameSpace:     // Set nameSpace:
     req->nameSpace = Batch_Zdup(req->base.batch, nameSpace.Str());      req->nameSpace = Batch_Tcsdup(req->base.base.batch, nameSpace.Str());
       if (!req->nameSpace)
       {
           result = false;
           goto done;
       }
  
     // Set assocClass:     // Set assocClass:
     if (assocClass.GetSize())      if (resultClass.GetSize())
         req->assocClass = Batch_Zdup(req->base.batch, assocClass.Str());      {
           req->resultClass = Batch_Tcsdup(req->base.base.batch, resultClass.Str());
           if (!req->resultClass)
           {
               result = false;
               goto done;
           }
       }
  
     // Set role:     // Set role:
     if (role.GetSize())     if (role.GetSize())
         req->role = Batch_Zdup(req->base.batch, role.Str());      {
           req->role = Batch_Tcsdup(req->base.base.batch, role.Str());
           if (!req->role)
           {
               result = false;
               goto done;
           }
       }
  
     // Pack the instance name into the message's batch.     // Pack the instance name into the message's batch.
     {     {
Line 1116 
Line 1199 
             instanceName.m_self,             instanceName.m_self,
             NULL,             NULL,
             NULL,             NULL,
             req->base.batch,              req->base.base.batch,
             &req->packedInstancePtr,             &req->packedInstancePtr,
             &req->packedInstanceSize);             &req->packedInstanceSize);
  
Line 1128 
Line 1211 
     }     }
  
     // Send the messages:     // Send the messages:
       Strand_SchedulePost(&strand,&req->base.base);
   
   done:
       if (req)
           AssociationsOfReq_Release(req);
   
       return result;
   }
   
   //==============================================================================
   
   MI_EXTERN_C void _Client_Post( _In_ Strand* self_, _In_ Message* msg)
     {     {
         Result r = Protocol_Send(protocol, &req->base);      ClientRep* rep = FromOffset(ClientRep,strand,self_);
  
         if (r != MI_RESULT_OK)      trace_Client_Post(
           msg,
           msg->tag,
           MessageName(msg->tag),
           msg->operationId );
   
       ClientRep::MessageCallback( rep, msg );
   
       Strand_Ack(self_);  // return an Ack to protocol
   }
   
   MI_EXTERN_C void _Client_PostControl( _In_ Strand* self_, _In_ Message* msg)
         {         {
             result = false;      ClientRep* rep = FromOffset(ClientRep,strand,self_);
             goto done;      ProtocolEventConnect* eventMsg = (ProtocolEventConnect*)msg;
       Handler* handler = rep->handler;
   
       DEBUG_ASSERT( ProtocolEventConnectTag == msg->tag );
   
       if( eventMsg->success )
       {
           D( printf("==== EventCallback() PROTOCOLEVENT_CONNECT\n"); )
           rep->connectState = ClientRep::CONNECTSTATE_CONNECTED;
           if (handler)
               handler->HandleConnect();
       }
       else
       {
           D( printf("==== EventCallback() PROTOCOLEVENT_CONNECT_FAILED\n"); )
           if (handler)
               handler->HandleConnectFailed();
           rep->connectState = ClientRep::CONNECTSTATE_FAILED;
         }         }
     }     }
  
 done:  MI_EXTERN_C void _Client_Ack( _In_ Strand* self )
     if (req)  {
         ReferencesOfReq_Release(req);      trace_Client_Ack();
       // We are not streaming any results, so no need to manage flow control on Ack
   }
  
     return result;  MI_EXTERN_C void _Client_Cancel( _In_ Strand* self )
   {
       DEBUG_ASSERT( MI_FALSE );  // not used yet
   }
   
   MI_EXTERN_C void _Client_Close( _In_ Strand* self_ )
   {
       ClientRep* rep = FromOffset(ClientRep,strand,self_);
       Handler* handler = rep->handler;
   
       trace_Client_Close();
       // most management done by strand implementation
   
       if (handler)
           handler->HandleDisconnect();
       rep->connectState = ClientRep::CONNECTSTATE_DISCONNECTED;
   }
   
   MI_EXTERN_C void _Client_Finish( _In_ Strand* self_ )
   {
       trace_Client_Finish();
       // nothing to do here, (class take care of deleting itself)
 } }
  
   /*
       Object that implements the C++ client endpoint.
       It opens an interaction to the binary protocol below
       to communicate on a TCP Socket.
   
       Behavior:
       - Post just passed the operation to tries to ClientRep::MessageCallback
          if that fails it sends the Ack immediately
       - Post control is used to notify connected state (connect succeeded/failed)
       - Ack does not do anything at this point (as there are no secondary messages)
       - Cancel is not used
       - Puts it on disconnected state if not there already
       - Shutdown:
          The Client objects are shutdown/deleted thru the normal
          Strand logic (once the interaction is closed).
   */
   StrandFT _Client_InteractionFT =
   {
       _Client_Post,
       _Client_PostControl,
       _Client_Ack,
       _Client_Cancel,
       _Client_Close,
       _Client_Finish,
       NULL,
       NULL,
       NULL,
       NULL,
       NULL,
       NULL
   };
   
 //============================================================================== //==============================================================================
 // //
 // class Client // class Client
Line 1157 
Line 1335 
     m_rep->protocol = 0;     m_rep->protocol = 0;
     m_rep->connectState = ClientRep::CONNECTSTATE_DISCONNECTED;     m_rep->connectState = ClientRep::CONNECTSTATE_DISCONNECTED;
     m_rep->handler = handler;     m_rep->handler = handler;
   
       //Log_OpenStdErr();
       //Log_SetLevel(LOG_DEBUG);
   
       Strand_Init( STRAND_DEBUG(OmiClient) &m_rep->strand, &_Client_InteractionFT, STRAND_FLAG_ENTERSTRAND, NULL );    // this is the one that Opens the interaction (not the one that receives the open)
 } }
  
 Client::~Client() Client::~Client()
Line 1189 
Line 1372 
     if (locator.GetSize() == 0)     if (locator.GetSize() == 0)
     {     {
 #ifdef CONFIG_POSIX #ifdef CONFIG_POSIX
         locator = GetPath(ID_SOCKETFILE);          locator = _StrToString(OMI_GetPath(ID_SOCKETFILE));
 #else #else
         locator = MI_T("localhost:7777");         locator = MI_T("localhost:7777");
 #endif #endif
Line 1217 
Line 1400 
  
     // Establish connection with server:     // Establish connection with server:
     {     {
         Protocol* protocol = NULL;          InteractionOpenParams params;
         r = Protocol_New_Connector(          ProtocolSocketAndBase* protocol = NULL;
   
           Strand_OpenPrepare(&m_rep->strand,&params,NULL,NULL,MI_TRUE);
   
           r = ProtocolSocketAndBase_New_Connector(
             &protocol,             &protocol,
             NULL,             NULL,
             locator_,             locator_,
             (ProtocolCallback)ClientRep::MessageCallback,              &params,
             m_rep,  
             (ProtocolEventCallback)ClientRep::EventCallback,  
             m_rep,  
             user_,             user_,
             password_);             password_);
  
Line 1262 
Line 1446 
  
     Uint64 endTime, now;     Uint64 endTime, now;
  
     if (Time_Now(&now) != MI_RESULT_OK)      if (PAL_Time(&now) != PAL_TRUE)
         return false;         return false;
  
     endTime = now + timeOutUsec;     endTime = now + timeOutUsec;
Line 1270 
Line 1454 
     // Wait for connection establishment or timeout.     // Wait for connection establishment or timeout.
     for (;endTime >= now;)     for (;endTime >= now;)
     {     {
         Protocol_Run(m_rep->protocol, 1000);          Protocol_Run(&m_rep->protocol->internalProtocolBase, SELECT_BASE_TIMEOUT_MSEC * 1000);
  
         if (m_rep->connectState != ClientRep::CONNECTSTATE_PENDING)         if (m_rep->connectState != ClientRep::CONNECTSTATE_PENDING)
             break;             break;
  
         if (Time_Now(&now) != MI_RESULT_OK)          if (PAL_Time(&now) != PAL_TRUE)
             break;             break;
     }     }
  
Line 1290 
Line 1474 
     bool result = true;     bool result = true;
  
     // Fail if not connected:     // Fail if not connected:
     if (!m_rep->protocol)      if( !m_rep->protocol || !m_rep->strand.info.opened )
     {     {
         result = false;         result = false;
         goto done;         goto done;
     }     }
  
     // Delete the protocol object.      if ( m_rep->strand.info.opened )
     {     {
         Result r = Protocol_Delete(m_rep->protocol);          Strand_ScheduleClose( &m_rep->strand );
           Protocol_Run(&m_rep->protocol->internalProtocolBase, SELECT_BASE_TIMEOUT_MSEC * 1000);
       }
  
         if (r != MI_RESULT_OK)      // Delete the protocol object.
         {         {
             result = false;          ProtocolSocketAndBase_ReadyToFinish(m_rep->protocol);
             goto done;  
         }  
  
         m_rep->protocol = 0;         m_rep->protocol = 0;
     }     }
Line 1317 
Line 1501 
  
 bool Client::Connected() const bool Client::Connected() const
 { {
     return m_rep->protocol ? true : false;      return m_rep->protocol && m_rep->strand.info.opened ? true : false;
 } }
  
 bool Client::Run(Uint64 timeOutUsec) bool Client::Run(Uint64 timeOutUsec)
Line 1325 
Line 1509 
     bool result = true;     bool result = true;
  
     // Fail if not connected.     // Fail if not connected.
     if (!m_rep->protocol)      if (!m_rep->protocol || !m_rep->strand.info.opened)
     {     {
         result = false;         result = false;
         goto done;         goto done;
Line 1333 
Line 1517 
  
     // Process events.     // Process events.
     // ATTN: what can this return?     // ATTN: what can this return?
     Protocol_Run(m_rep->protocol, timeOutUsec);      Protocol_Run(&m_rep->protocol->internalProtocolBase, timeOutUsec);
  
 done: done:
     return result;     return result;
 } }
  
 bool Client::NoOpAsync( bool Client::NoOpAsync(
     Uint64& msgID)      Uint64& operationId)
 { {
     msgID = _NextMsgID();      operationId = _NextOperationId();
     return m_rep->NoOpAsync(msgID);      return m_rep->NoOpAsync(operationId);
 } }
  
 bool Client::GetInstanceAsync( bool Client::GetInstanceAsync(
     const String& nameSpace,     const String& nameSpace,
     const DInstance& instanceName,     const DInstance& instanceName,
     Uint64& msgID)      Uint64& operationId)
 { {
     msgID = _NextMsgID();      operationId = _NextOperationId();
     return m_rep->GetInstanceAsync(nameSpace, instanceName, msgID);      return m_rep->GetInstanceAsync(nameSpace, instanceName, operationId);
 } }
  
 bool Client::CreateInstanceAsync( bool Client::CreateInstanceAsync(
     const String& nameSpace,     const String& nameSpace,
     const DInstance& instance,     const DInstance& instance,
     Uint64& msgID)      Uint64& operationId)
 { {
     msgID = _NextMsgID();      operationId = _NextOperationId();
     return m_rep->CreateInstanceAsync(nameSpace, instance, msgID);      return m_rep->CreateInstanceAsync(nameSpace, instance, operationId);
 } }
  
 bool Client::ModifyInstanceAsync( bool Client::ModifyInstanceAsync(
     const String& nameSpace,     const String& nameSpace,
     const DInstance& instance,     const DInstance& instance,
     Uint64& msgID)      Uint64& operationId)
 { {
     msgID = _NextMsgID();      operationId = _NextOperationId();
     return m_rep->ModifyInstanceAsync(nameSpace, instance, msgID);      return m_rep->ModifyInstanceAsync(nameSpace, instance, operationId);
 } }
  
 bool Client::DeleteInstanceAsync( bool Client::DeleteInstanceAsync(
     const String& nameSpace,     const String& nameSpace,
     const DInstance& instanceName,     const DInstance& instanceName,
     Uint64& msgID)      Uint64& operationId)
 { {
     msgID = _NextMsgID();      operationId = _NextOperationId();
     return m_rep->DeleteInstanceAsync(nameSpace, instanceName, msgID);      return m_rep->DeleteInstanceAsync(nameSpace, instanceName, operationId);
 } }
  
 bool Client::EnumerateInstancesAsync( bool Client::EnumerateInstancesAsync(
Line 1388 
Line 1572 
     bool deepInheritance,     bool deepInheritance,
     const String& queryLanguage,     const String& queryLanguage,
     const String& queryExpression,     const String& queryExpression,
     Uint64& msgID)      Uint64& operationId)
 { {
     msgID = _NextMsgID();      operationId = _NextOperationId();
     return m_rep->EnumerateInstancesAsync(nameSpace, className,     return m_rep->EnumerateInstancesAsync(nameSpace, className,
         deepInheritance, queryLanguage, queryExpression, msgID);          deepInheritance, queryLanguage, queryExpression, operationId);
 } }
  
 bool Client::InvokeAsync( bool Client::InvokeAsync(
Line 1401 
Line 1585 
     const String& methodName,     const String& methodName,
     const DInstance& inParameters,     const DInstance& inParameters,
     DInstance& outParameters,     DInstance& outParameters,
     Uint64 msgID)      Uint64 operationId)
 { {
     msgID = _NextMsgID();      operationId = _NextOperationId();
     return m_rep->InvokeAsync(nameSpace, instanceName, methodName, inParameters,     return m_rep->InvokeAsync(nameSpace, instanceName, methodName, inParameters,
         outParameters, msgID);          outParameters, operationId);
 } }
  
 bool Client::AssociatorInstancesAsync( bool Client::AssociatorInstancesAsync(
Line 1415 
Line 1599 
     const String& resultClass,     const String& resultClass,
     const String& role,     const String& role,
     const String& resultRole,     const String& resultRole,
     Uint64& msgID)      Uint64& operationId)
 { {
     msgID = _NextMsgID();      operationId = _NextOperationId();
     return m_rep->AssociatorInstancesAsync(nameSpace, instanceName, assocClass,     return m_rep->AssociatorInstancesAsync(nameSpace, instanceName, assocClass,
         resultClass, role, resultRole, msgID);          resultClass, role, resultRole, operationId);
 } }
  
 bool Client::ReferenceInstancesAsync( bool Client::ReferenceInstancesAsync(
Line 1427 
Line 1611 
     const DInstance& instanceName,     const DInstance& instanceName,
     const String& assocClass,     const String& assocClass,
     const String& role,     const String& role,
     Uint64& msgID)      Uint64& operationId)
 { {
     msgID = _NextMsgID();      operationId = _NextOperationId();
     return m_rep->ReferenceInstancesAsync(nameSpace, instanceName, assocClass,     return m_rep->ReferenceInstancesAsync(nameSpace, instanceName, assocClass,
         role, msgID);          role, operationId);
 } }
  
 bool Client::GetInstance( bool Client::GetInstance(
Line 1442 
Line 1626 
     Result& result)     Result& result)
 { {
     Handler* oldHandler = m_rep->handler;     Handler* oldHandler = m_rep->handler;
     Uint64 msgID = _NextMsgID();      Uint64 operationId = _NextOperationId();
     InstanceHandler handler(oldHandler, msgID, instance);      InstanceHandler handler(oldHandler, operationId, instance);
     m_rep->handler = &handler;     m_rep->handler = &handler;
     bool flag = true;     bool flag = true;
  
     if (!m_rep->GetInstanceAsync(nameSpace, instanceName, msgID))      if (!m_rep->GetInstanceAsync(nameSpace, instanceName, operationId))
     {     {
         flag = false;         flag = false;
         goto done;         goto done;
Line 1455 
Line 1639 
  
     Uint64 endTime, now;     Uint64 endTime, now;
  
     if (Time_Now(&now) != MI_RESULT_OK)      if (PAL_Time(&now) != PAL_TRUE)
         return false;         return false;
  
     endTime = now + timeOutUsec;     endTime = now + timeOutUsec;
  
     for (;endTime >= now;)     for (;endTime >= now;)
     {     {
         Protocol_Run(m_rep->protocol, 1000);          Protocol_Run(&m_rep->protocol->internalProtocolBase, SELECT_BASE_TIMEOUT_MSEC * 1000);
  
         if (handler.m_state == InstanceHandler::FAILED ||         if (handler.m_state == InstanceHandler::FAILED ||
             handler.m_state == InstanceHandler::DONE)             handler.m_state == InstanceHandler::DONE)
Line 1470 
Line 1654 
             break;             break;
         }         }
  
         if (Time_Now(&now) != MI_RESULT_OK)          if (PAL_Time(&now) != PAL_TRUE)
             break;             break;
     }     }
  
Line 1492 
Line 1676 
     Result& result)     Result& result)
 { {
     Handler* oldHandler = m_rep->handler;     Handler* oldHandler = m_rep->handler;
     Uint64 msgID = _NextMsgID();      Uint64 operationId = _NextOperationId();
     InstanceHandler handler(oldHandler, msgID, instanceName);      InstanceHandler handler(oldHandler, operationId, instanceName);
     m_rep->handler = &handler;     m_rep->handler = &handler;
     bool flag = true;     bool flag = true;
  
     if (!m_rep->CreateInstanceAsync(nameSpace, instance, msgID))      if (!m_rep->CreateInstanceAsync(nameSpace, instance, operationId))
     {     {
         flag = false;         flag = false;
         goto done;         goto done;
Line 1505 
Line 1689 
  
     Uint64 endTime, now;     Uint64 endTime, now;
  
     if (Time_Now(&now) != MI_RESULT_OK)      if (PAL_Time(&now) != PAL_TRUE)
         return false;         return false;
  
     endTime = now + timeOutUsec;     endTime = now + timeOutUsec;
  
     for (;endTime >= now;)     for (;endTime >= now;)
     {     {
         Protocol_Run(m_rep->protocol, 1000);          Protocol_Run(&m_rep->protocol->internalProtocolBase, SELECT_BASE_TIMEOUT_MSEC * 1000);
  
         if (handler.m_state == InstanceHandler::FAILED ||         if (handler.m_state == InstanceHandler::FAILED ||
             handler.m_state == InstanceHandler::DONE)             handler.m_state == InstanceHandler::DONE)
Line 1520 
Line 1704 
             break;             break;
         }         }
  
         if (Time_Now(&now) != MI_RESULT_OK)          if (PAL_Time(&now) != PAL_TRUE)
             break;             break;
     }     }
  
Line 1541 
Line 1725 
     Result& result)     Result& result)
 { {
     Handler* oldHandler = m_rep->handler;     Handler* oldHandler = m_rep->handler;
     Uint64 msgID = _NextMsgID();      Uint64 operationId = _NextOperationId();
     ResultHandler handler(oldHandler, msgID);      ResultHandler handler(oldHandler, operationId);
     m_rep->handler = &handler;     m_rep->handler = &handler;
     bool flag = true;     bool flag = true;
  
     if (!m_rep->ModifyInstanceAsync(nameSpace, instance, msgID))      if (!m_rep->ModifyInstanceAsync(nameSpace, instance, operationId))
     {     {
         flag = false;         flag = false;
         goto done;         goto done;
Line 1554 
Line 1738 
  
     Uint64 endTime, now;     Uint64 endTime, now;
  
     if (Time_Now(&now) != MI_RESULT_OK)      if (PAL_Time(&now) != PAL_TRUE)
         return false;         return false;
  
     endTime = now + timeOutUsec;     endTime = now + timeOutUsec;
  
     for (;endTime >= now;)     for (;endTime >= now;)
     {     {
         Protocol_Run(m_rep->protocol, 1000);          Protocol_Run(&m_rep->protocol->internalProtocolBase, SELECT_BASE_TIMEOUT_MSEC * 1000);
  
         if (handler.m_state == ResultHandler::FAILED ||         if (handler.m_state == ResultHandler::FAILED ||
             handler.m_state == ResultHandler::DONE)             handler.m_state == ResultHandler::DONE)
Line 1569 
Line 1753 
             break;             break;
         }         }
  
         if (Time_Now(&now) != MI_RESULT_OK)          if (PAL_Time(&now) != PAL_TRUE)
             break;             break;
     }     }
  
Line 1590 
Line 1774 
     Result& result)     Result& result)
 { {
     Handler* oldHandler = m_rep->handler;     Handler* oldHandler = m_rep->handler;
     Uint64 msgID = _NextMsgID();      Uint64 operationId = _NextOperationId();
     ResultHandler handler(oldHandler, msgID);      ResultHandler handler(oldHandler, operationId);
     m_rep->handler = &handler;     m_rep->handler = &handler;
     bool flag = true;     bool flag = true;
  
     if (!m_rep->DeleteInstanceAsync(nameSpace, instanceName, msgID))      if (!m_rep->DeleteInstanceAsync(nameSpace, instanceName, operationId))
     {     {
         flag = false;         flag = false;
         goto done;         goto done;
Line 1603 
Line 1787 
  
     Uint64 endTime, now;     Uint64 endTime, now;
  
     if (Time_Now(&now) != MI_RESULT_OK)      if (PAL_Time(&now) != PAL_TRUE)
         return false;         return false;
  
     endTime = now + timeOutUsec;     endTime = now + timeOutUsec;
  
     for (;endTime >= now;)     for (;endTime >= now;)
     {     {
         Protocol_Run(m_rep->protocol, 1000);          Protocol_Run(&m_rep->protocol->internalProtocolBase, SELECT_BASE_TIMEOUT_MSEC * 1000);
  
         if (handler.m_state == ResultHandler::FAILED ||         if (handler.m_state == ResultHandler::FAILED ||
             handler.m_state == ResultHandler::DONE)             handler.m_state == ResultHandler::DONE)
Line 1618 
Line 1802 
             break;             break;
         }         }
  
         if (Time_Now(&now) != MI_RESULT_OK)          if (PAL_Time(&now) != PAL_TRUE)
             break;             break;
     }     }
  
Line 1635 
Line 1819 
 bool Client::NoOp(Uint64 timeOutUsec) bool Client::NoOp(Uint64 timeOutUsec)
 { {
     Handler* oldHandler = m_rep->handler;     Handler* oldHandler = m_rep->handler;
     Uint64 msgID = _NextMsgID();      Uint64 operationId = _NextOperationId();
     NoOpHandler handler(oldHandler, msgID);      NoOpHandler handler(oldHandler, operationId);
     m_rep->handler = &handler;     m_rep->handler = &handler;
     bool flag = true;     bool flag = true;
  
     if (!m_rep->NoOpAsync(msgID))      if (!m_rep->NoOpAsync(operationId))
     {     {
         flag = false;         flag = false;
         goto done;         goto done;
Line 1648 
Line 1832 
  
     Uint64 endTime, now;     Uint64 endTime, now;
  
     if (Time_Now(&now) != MI_RESULT_OK)      if (PAL_Time(&now) != PAL_TRUE)
         return false;         return false;
  
     endTime = now + timeOutUsec;     endTime = now + timeOutUsec;
  
     for (;endTime >= now;)     for (;endTime >= now;)
     {     {
         Protocol_Run(m_rep->protocol, 1000);          Protocol_Run(&m_rep->protocol->internalProtocolBase, SELECT_BASE_TIMEOUT_MSEC * 1000);
  
         if (handler.m_state == NoOpHandler::FAILED ||         if (handler.m_state == NoOpHandler::FAILED ||
             handler.m_state == NoOpHandler::DONE)             handler.m_state == NoOpHandler::DONE)
Line 1663 
Line 1847 
             break;             break;
         }         }
  
         if (Time_Now(&now) != MI_RESULT_OK)          if (PAL_Time(&now) != PAL_TRUE)
             break;             break;
     }     }
  
Line 1686 
Line 1870 
     Result& result)     Result& result)
 { {
     Handler* oldHandler = m_rep->handler;     Handler* oldHandler = m_rep->handler;
     Uint64 msgID = _NextMsgID();      Uint64 operationId = _NextOperationId();
     InstancesHandler handler(oldHandler, msgID, instances);      InstancesHandler handler(oldHandler, operationId, instances);
     m_rep->handler = &handler;     m_rep->handler = &handler;
     bool flag = true;     bool flag = true;
  
     if (!m_rep->EnumerateInstancesAsync(nameSpace, className, deepInheritance,     if (!m_rep->EnumerateInstancesAsync(nameSpace, className, deepInheritance,
         queryLanguage, queryExpression, msgID))          queryLanguage, queryExpression, operationId))
     {     {
         flag = false;         flag = false;
         goto done;         goto done;
Line 1700 
Line 1884 
  
     Uint64 endTime, now;     Uint64 endTime, now;
  
     if (Time_Now(&now) != MI_RESULT_OK)      if (PAL_Time(&now) != PAL_TRUE)
         return false;         return false;
  
     endTime = now + timeOutUsec;     endTime = now + timeOutUsec;
  
     for (;endTime >= now;)     for (;endTime >= now;)
     {     {
         Protocol_Run(m_rep->protocol, 1000);          Protocol_Run(&m_rep->protocol->internalProtocolBase, SELECT_BASE_TIMEOUT_MSEC * 1000);
  
         if (handler.m_state == InstancesHandler::FAILED ||         if (handler.m_state == InstancesHandler::FAILED ||
             handler.m_state == InstancesHandler::DONE)             handler.m_state == InstancesHandler::DONE)
Line 1715 
Line 1899 
             break;             break;
         }         }
  
         if (Time_Now(&now) != MI_RESULT_OK)          if (PAL_Time(&now) != PAL_TRUE)
             break;             break;
     }     }
  
Line 1739 
Line 1923 
     Result& result)     Result& result)
 { {
     Handler* oldHandler = m_rep->handler;     Handler* oldHandler = m_rep->handler;
     Uint64 msgID = _NextMsgID();      Uint64 operationId = _NextOperationId();
     InstanceHandler handler(oldHandler, msgID, outParameters);      InstanceHandler handler(oldHandler, operationId, outParameters);
     m_rep->handler = &handler;     m_rep->handler = &handler;
     bool flag = true;     bool flag = true;
  
     if (!m_rep->InvokeAsync(nameSpace, instanceName, methodName, inParameters,     if (!m_rep->InvokeAsync(nameSpace, instanceName, methodName, inParameters,
         outParameters, msgID))          outParameters, operationId))
     {     {
         flag = false;         flag = false;
         goto done;         goto done;
Line 1753 
Line 1937 
  
     Uint64 endTime, now;     Uint64 endTime, now;
  
     if (Time_Now(&now) != MI_RESULT_OK)      if (PAL_Time(&now) != PAL_TRUE)
         return false;         return false;
  
     endTime = now + timeOutUsec;     endTime = now + timeOutUsec;
  
     for (;endTime >= now;)     for (;endTime >= now;)
     {     {
         Protocol_Run(m_rep->protocol, 1000);          Protocol_Run(&m_rep->protocol->internalProtocolBase, SELECT_BASE_TIMEOUT_MSEC * 1000);
  
         if (handler.m_state == InstanceHandler::FAILED ||         if (handler.m_state == InstanceHandler::FAILED ||
             handler.m_state == InstanceHandler::DONE)             handler.m_state == InstanceHandler::DONE)
Line 1768 
Line 1952 
             break;             break;
         }         }
  
         if (Time_Now(&now) != MI_RESULT_OK)          if (PAL_Time(&now) != PAL_TRUE)
             break;             break;
     }     }
  
Line 1794 
Line 1978 
     Result& result)     Result& result)
 { {
     Handler* oldHandler = m_rep->handler;     Handler* oldHandler = m_rep->handler;
     Uint64 msgID = _NextMsgID();      Uint64 operationId = _NextOperationId();
     InstancesHandler handler(oldHandler, msgID, instances);      InstancesHandler handler(oldHandler, operationId, instances);
     m_rep->handler = &handler;     m_rep->handler = &handler;
     bool flag = true;     bool flag = true;
  
     if (!m_rep->AssociatorInstancesAsync(nameSpace, instanceName, assocClass,     if (!m_rep->AssociatorInstancesAsync(nameSpace, instanceName, assocClass,
         resultClass, role, resultRole, msgID))          resultClass, role, resultRole, operationId))
     {     {
         flag = false;         flag = false;
         goto done;         goto done;
Line 1808 
Line 1992 
  
     Uint64 endTime, now;     Uint64 endTime, now;
  
     if (Time_Now(&now) != MI_RESULT_OK)      if (PAL_Time(&now) != PAL_TRUE)
         return false;         return false;
  
     endTime = now + timeOutUsec;     endTime = now + timeOutUsec;
  
     for (;endTime >= now;)     for (;endTime >= now;)
     {     {
         Protocol_Run(m_rep->protocol, 1000);          Protocol_Run(&m_rep->protocol->internalProtocolBase, SELECT_BASE_TIMEOUT_MSEC * 1000);
  
         if (handler.m_state == InstancesHandler::FAILED ||         if (handler.m_state == InstancesHandler::FAILED ||
             handler.m_state == InstancesHandler::DONE)             handler.m_state == InstancesHandler::DONE)
Line 1823 
Line 2007 
             break;             break;
         }         }
  
         if (Time_Now(&now) != MI_RESULT_OK)          if (PAL_Time(&now) != PAL_TRUE)
             break;             break;
     }     }
  
Line 1847 
Line 2031 
     Result& result)     Result& result)
 { {
     Handler* oldHandler = m_rep->handler;     Handler* oldHandler = m_rep->handler;
     Uint64 msgID = _NextMsgID();      Uint64 operationId = _NextOperationId();
     InstancesHandler handler(oldHandler, msgID, instances);      InstancesHandler handler(oldHandler, operationId, instances);
     m_rep->handler = &handler;     m_rep->handler = &handler;
     bool flag = true;     bool flag = true;
  
     if (!m_rep->ReferenceInstancesAsync(nameSpace, instanceName, assocClass,     if (!m_rep->ReferenceInstancesAsync(nameSpace, instanceName, assocClass,
         role, msgID))          role, operationId))
     {     {
         flag = false;         flag = false;
         goto done;         goto done;
Line 1861 
Line 2045 
  
     Uint64 endTime, now;     Uint64 endTime, now;
  
     if (Time_Now(&now) != MI_RESULT_OK)      if (PAL_Time(&now) != PAL_TRUE)
         return false;         return false;
  
     endTime = now + timeOutUsec;     endTime = now + timeOutUsec;
  
     for (;endTime >= now;)     for (;endTime >= now;)
     {     {
         Protocol_Run(m_rep->protocol, 1000);          Protocol_Run(&m_rep->protocol->internalProtocolBase, SELECT_BASE_TIMEOUT_MSEC * 1000);
  
         if (handler.m_state == InstancesHandler::FAILED ||         if (handler.m_state == InstancesHandler::FAILED ||
             handler.m_state == InstancesHandler::DONE)             handler.m_state == InstancesHandler::DONE)
Line 1876 
Line 2060 
             break;             break;
         }         }
  
         if (Time_Now(&now) != MI_RESULT_OK)          if (PAL_Time(&now) != PAL_TRUE)
             break;             break;
     }     }
  


Legend:
Removed from v.1.1  
changed lines
  Added in v.1.3

ViewCVS 0.9.2