⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 giopimpl11.cc

📁 编译工具
💻 CC
📖 第 1 页 / 共 4 页
字号:
  // Compute and initialise the message size field  {    cdrCountingStream cs(g->TCS_C(),g->TCS_W(),12);    giop_s.service_contexts() >>= cs;    operator>>= ((CORBA::ULong)0,cs);    operator>>= ((CORBA::ULong)0,cs);    CORBA::ULong(repoid_size) >>= cs;    cs.put_octet_array((const CORBA::Octet*) repoid, repoid_size);    ex._NP_marshal(cs);    outputSetFragmentSize(g,cs.total()-12);    *((CORBA::ULong*)(hdr + 8)) = cs.total() - 12;  }  // Service context  giop_s.service_contexts() >>= s;  // request id  giop_s.requestId() >>= s;  // reply status  CORBA::ULong rc = GIOP::USER_EXCEPTION;  rc >>= s;  CORBA::ULong(repoid_size) >>= s;  s.put_octet_array((const CORBA::Octet*) repoid, repoid_size);  ex._NP_marshal(s);  outputMessageEnd(g);}////////////////////////////////////////////////////////////////////////voidgiopImpl11::sendLocationForwardReply(giopStream* g,CORBA::Object_ptr obj,				     CORBA::Boolean) {  outputNewMessage(g);    char* hdr = (char*)g->pd_currentOutputBuffer +                      g->pd_currentOutputBuffer->start;  hdr[7] = (char)GIOP::Reply;  GIOP_S& giop_s = *(GIOP_S*)g;  cdrStream& s = (cdrStream&) *g;  // Compute and initialise the message size field  {    cdrCountingStream cs(g->TCS_C(),g->TCS_W(),12);    operator>>= ((CORBA::ULong)0,cs);    operator>>= ((CORBA::ULong)0,cs);    operator>>= ((CORBA::ULong)0,cs);    CORBA::Object::_marshalObjRef(obj,cs);    outputSetFragmentSize(g,cs.total()-12);    *((CORBA::ULong*)(hdr + 8)) = cs.total() - 12;  }  // Service context  operator>>= ((CORBA::ULong)0,s);  // request id  giop_s.requestId() >>= s;  // reply status  CORBA::ULong rc = GIOP::LOCATION_FORWARD;  rc >>= s;  // object reference  CORBA::Object::_marshalObjRef(obj,s);  outputMessageEnd(g);}////////////////////////////////////////////////////////////////////////voidgiopImpl11::sendLocateReply(giopStream* g,GIOP::LocateStatusType rc,			    CORBA::Object_ptr obj,CORBA::SystemException* p) {  outputNewMessage(g);  char* hdr = (char*)g->pd_currentOutputBuffer +                      g->pd_currentOutputBuffer->start;  hdr[7] = (char)GIOP::LocateReply;  GIOP_S& giop_s = *(GIOP_S*)g;  cdrStream& s = (cdrStream&) *g;  CORBA::Object_ptr extra = CORBA::Object::_nil();  // reply status  switch (rc) {  case GIOP::UNKNOWN_OBJECT:  case GIOP::OBJECT_HERE:    break;  case GIOP::OBJECT_FORWARD_PERM:    rc = GIOP::OBJECT_FORWARD;    // falls through  case GIOP::OBJECT_FORWARD:    extra = obj;    break;  default:    // None of these status types are supported.    rc = GIOP::UNKNOWN_OBJECT;    break;  }  // Compute and initialise the message size field  {    cdrCountingStream cs(g->TCS_C(),g->TCS_W(),12);    operator>>= ((CORBA::ULong)0,cs);    operator>>= ((CORBA::ULong)0,cs);    if (!CORBA::is_nil(extra)) {      CORBA::Object::_marshalObjRef(extra,cs);    }    outputSetFragmentSize(g,cs.total()-12);    *((CORBA::ULong*)(hdr + 8)) = cs.total() - 12;  }  // request id  giop_s.requestId() >>= s;  operator>>= ((CORBA::ULong)rc,s);  if (!CORBA::is_nil(extra)) {    CORBA::Object::_marshalObjRef(extra,s);  }  outputMessageEnd(g);}////////////////////////////////////////////////////////////////////////size_tgiopImpl11::outputRemaining(const giopStream* g) {  CORBA::ULong total = g->outputFragmentSize();  if (!total) {    CORBA::ULong avail = (CORBA::Long)orbParameters::giopMaxMsgSize -                         (CORBA::Long)currentOutputPtr(g);        // Adjust avail to exactly the same value as calculated in outputFlush().    // See the comment in outputFlush() for the reason why.    avail = ((avail + 4) >> 3) << 3;    avail = (avail ? avail - 4 : 0);    return avail;  }  else {    return total - currentOutputPtr(g);  }}////////////////////////////////////////////////////////////////////////voidgiopImpl11::outputFlush(giopStream* g,CORBA::Boolean knownFragmentSize) {  // Note: g->outputFragmentSize() == 0 implies that the full message  //       size has been pre-calculated and no GIOP Fragment should be  //       sent! This also means that the message size limit has been  //       checked and there is no need to check against  //       orbParameters::giopMaxMsgSize.  //         omni::ptr_arith_t outbuf_begin = ((omni::ptr_arith_t) 				    g->pd_currentOutputBuffer + 				    g->pd_currentOutputBuffer->start);  CORBA::ULong fsz =   (omni::ptr_arith_t) g->pd_outb_mkr - outbuf_begin;  if (!g->outputFragmentSize()) {    ((char*)outbuf_begin)[6] |= 0x2;    CORBA::ULong sz;    if (!knownFragmentSize) {      sz = fsz - 12;      *((CORBA::ULong*)((omni::ptr_arith_t)outbuf_begin + 8)) = sz;    }    else {      sz = *((CORBA::ULong*)((omni::ptr_arith_t)outbuf_begin + 8));    }    g->outputMessageSize(g->outputMessageSize()+sz);    if (g->outputMessageSize() > orbParameters::giopMaxMsgSize) {      OMNIORB_THROW(MARSHAL,MARSHAL_MessageSizeExceedLimitOnClient,		    (CORBA::CompletionStatus)g->completion());    }  }  else {    CORBA::Long msz = g->outputMessageSize();    if (msz) {      g->outputMessageSize(msz+fsz);    }    else {      g->outputMessageSize(fsz-12);    }  }  g->pd_currentOutputBuffer->last = g->pd_currentOutputBuffer->start + fsz;  g->sendChunk(g->pd_currentOutputBuffer);  if (outbuf_begin & 0x7) {    // start has previously been changed to non 8-bytes aligned    g->pd_currentOutputBuffer->alignStart(omni::ALIGN_8);    outbuf_begin = ((omni::ptr_arith_t) g->pd_currentOutputBuffer + 		                        g->pd_currentOutputBuffer->start);  }  g->pd_outb_mkr = (void*) outbuf_begin;  g->pd_outb_end = (void*)((omni::ptr_arith_t)g->pd_currentOutputBuffer + 			   g->pd_currentOutputBuffer->end);  g->pd_currentOutputBuffer->last = g->pd_currentOutputBuffer->start;  if (!g->outputFragmentSize()) {    char* hdr = (char*) outbuf_begin;    hdr[0] = 'G'; hdr[1] = 'I'; hdr[2] = 'O'; hdr[3] = 'P';    hdr[4] = 1;   hdr[5] = 1;   hdr[6] = _OMNIORB_HOST_BYTE_ORDER_;    hdr[7] = (char)GIOP::Fragment;    g->pd_outb_mkr = (void*)(outbuf_begin + 12);        // Now determine how much space we have left.    // If the message size has already reach orbParameters::giopMaxMsgSize,    // outputHasReachedLimit() will return TRUE.    CORBA::ULong avail = orbParameters::giopMaxMsgSize - g->outputMessageSize();    // Adjust avail to make sure that either it is 0 or when the header    // size (12) is added the result is a multiple of 8.    // This preserves our invariant: g->pd_outb_end always align on 8 bytes    // boundary.    // The value should be one of 0, 4, 12, 20, ....    avail = ((avail + 4) >> 3) << 3;    avail = (avail ? avail - 4 : 0);    omni::ptr_arith_t newmkr = (omni::ptr_arith_t) g->pd_outb_mkr + avail;    // If the new position is inside the buffer, set the end pointer.    // Note that if avail is very large, newmkr may wrap around and be    // < pd_outb_mkr.    if ((newmkr >= (omni::ptr_arith_t)g->pd_outb_mkr &&	 newmkr <  (omni::ptr_arith_t)g->pd_outb_end)) {      g->pd_outb_end = (void*) newmkr;    }  }}////////////////////////////////////////////////////////////////////////voidgiopImpl11::getReserveSpace(giopStream* g,omni::alignment_t align,size_t sz) {  // The caller has already checked that align == sz, or sz == 0.  if (outputHasReachedLimit(g)) {    // Already reached the message size limit    goto overflow;  }  g->pd_outb_mkr = (void*) omni::align_to((omni::ptr_arith_t)g->pd_outb_mkr,					  align);  if (sz == 0)    return;  if ((omni::ptr_arith_t)g->pd_outb_mkr < (omni::ptr_arith_t)g->pd_outb_end) {    omni::ptr_arith_t newmkr = ((omni::ptr_arith_t)g->pd_outb_mkr + sz);     if (newmkr <= (omni::ptr_arith_t)g->pd_outb_end)      return;    // Should never happen!!    OMNIORB_ASSERT(0);  }  // Reach here only if the buffer has been filled up completely.  outputFlush(g);  if (!outputHasReachedLimit(g))    return; overflow:    OMNIORB_THROW(MARSHAL,MARSHAL_MessageSizeExceedLimitOnClient,		  (CORBA::CompletionStatus)g->completion());}////////////////////////////////////////////////////////////////////////voidgiopImpl11::copyOutputData(giopStream* g,void* b, size_t sz,			   omni::alignment_t align) {  if (outputHasReachedLimit(g)) {    // Already reached the message size limit    OMNIORB_THROW(MARSHAL,MARSHAL_MessageSizeExceedLimitOnClient,		  (CORBA::CompletionStatus)g->completion());  }  omni::ptr_arith_t newmkr = omni::align_to((omni::ptr_arith_t)g->pd_outb_mkr,					    align);  OMNIORB_ASSERT(newmkr <= (omni::ptr_arith_t)g->pd_outb_end);  if (sz >= giopStream::directSendCutOff) {    g->pd_outb_mkr = (void*)newmkr;    if (!g->outputFragmentSize()) {      omni::ptr_arith_t outbuf_begin = ((omni::ptr_arith_t) 					g->pd_currentOutputBuffer + 					g->pd_currentOutputBuffer->start);      CORBA::ULong fsz = (omni::ptr_arith_t) g->pd_outb_mkr -             	         (omni::ptr_arith_t) outbuf_begin + sz - 12;      *((CORBA::ULong*)((omni::ptr_arith_t)outbuf_begin + 8)) = fsz;    }    outputFlush(g,1);    g->sendCopyChunk(b,sz);    if (g->outputFragmentSize()) {      size_t leftover = (newmkr + sz) % 0x7;      if (leftover) {	g->pd_currentOutputBuffer->start += leftover;	g->pd_outb_mkr = (void*) ((omni::ptr_arith_t) 				  g->pd_currentOutputBuffer + 				  g->pd_currentOutputBuffer->start);      }    }  }  else {    g->pd_outb_mkr = (void*)newmkr;    while (sz) {      size_t avail = (omni::ptr_arith_t) g->pd_outb_end	- 	             (omni::ptr_arith_t) g->pd_outb_mkr;      if (avail > sz) avail = sz;      memcpy(g->pd_outb_mkr,b,avail);      sz -= avail;      g->pd_outb_mkr = (void*)((omni::ptr_arith_t) g->pd_outb_mkr + avail);      b = (void*)((omni::ptr_arith_t) b + avail);      if (g->pd_outb_mkr == g->pd_outb_end) {	outputFlush(g);	if (sz && outputHasReachedLimit(g)) {	  // Already reached the message size limit	  OMNIORB_THROW(MARSHAL,MARSHAL_MessageSizeExceedLimitOnClient,			(CORBA::CompletionStatus)g->completion());	}      }    }  }}////////////////////////////////////////////////////////////////////////CORBA::ULonggiopImpl11::currentOutputPtr(const giopStream* g) {  CORBA::ULong fsz = (omni::ptr_arith_t) g->pd_outb_mkr -                      ((omni::ptr_arith_t) g->pd_currentOutputBuffer + 		      g->pd_currentOutputBuffer->start);  if (g->outputMessageSize()) {    return fsz + g->outputMessageSize();  }  else {    return fsz - 12;  }}////////////////////////////////////////////////////////////////////////voidgiopImpl11::outputSetFragmentSize(giopStream* g,CORBA::ULong msz) {  if (msz > orbParameters::giopMaxMsgSize) {    OMNIORB_THROW(MARSHAL,MARSHAL_MessageSizeExceedLimitOnClient,		  (CORBA::CompletionStatus)g->completion());  }  g->outputFragmentSize(msz);}////////////////////////////////////////////////////////////////////////CORBA::BooleangiopImpl11::outputHasReachedLimit(giopStream* g) {  return ( (omni::ptr_arith_t) g->pd_outb_end ==           ((omni::ptr_arith_t) g->pd_currentOutputBuffer + 		  	       g->pd_currentOutputBuffer->start + 12) );}////////////////////////////////////////////////////////////////////////static giopStreamImpl* giop_1_1_singleton = 0;class omni_giopImpl11_initialiser : public omniInitialiser {public:  void attach() {    if (!giop_1_1_singleton) {      GIOP::Version ver = { 1, 1};      giopStreamImpl* p;      giop_1_1_singleton = p = new giopStreamImpl(ver);            // Shared by the client and server side      // Process message header      p->outputMessageBegin             = giopImpl11::outputMessageBegin;      p->outputMessageEnd               = giopImpl11::outputMessageEnd;      p->inputMessageBegin              = giopImpl11::inputMessageBegin;      p->inputMessageEnd                = giopImpl11::inputMessageEnd;      p->sendMsgErrorMessage            = giopImpl11::sendMsgErrorMessage;      // Client side      // Process message header      p->marshalRequestHeader           = giopImpl11::marshalRequestHeader;      p->sendLocateRequest              = giopImpl11::sendLocateRequest;      p->unmarshalReplyHeader           = giopImpl11::unmarshalReplyHeader;      p->unmarshalLocateReply           = giopImpl11::unmarshalLocateReply;      // Server side      // Process message header      p->unmarshalWildCardRequestHeader = giopImpl11::unmarshalWildCardRequestHeader;      p->unmarshalRequestHeader         = giopImpl11::unmarshalRequestHeader;      p->unmarshalLocateRequest         = giopImpl11::unmarshalLocateRequest;      p->marshalReplyHeader             = giopImpl11::marshalReplyHeader;      p->sendSystemException            = giopImpl11::sendSystemException;      p->sendUserException              = giopImpl11::sendUserException;      p->sendLocationForwardReply       = giopImpl11::sendLocationForwardReply;      p->sendLocateReply                = giopImpl11::sendLocateReply;      // Shared by the client and the server side      // Process message body      p->inputRemaining                 = giopImpl11::inputRemaining;      p->getInputData                   = giopImpl11::getInputData;      p->skipInputData                  = giopImpl11::skipInputData;      p->copyInputData                  = giopImpl11::copyInputData;      p->outputRemaining                = giopImpl11::outputRemaining;      p->getReserveSpace                = giopImpl11::getReserveSpace;      p->copyOutputData                 = giopImpl11::copyOutputData;      p->currentInputPtr                = giopImpl11::currentInputPtr;      p->currentOutputPtr               = giopImpl11::currentOutputPtr;      giopStreamImpl::registerImpl(giop_1_1_singleton);    }  }  void detach() {     if (giop_1_1_singleton) {      delete giop_1_1_singleton;      giop_1_1_singleton = 0;    }  }};static omni_giopImpl11_initialiser initialiser;omniInitialiser& omni_giopImpl11_initialiser_ = initialiser;OMNI_NAMESPACE_END(omni)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -