giopimpl10.cc
来自「编译工具」· CC 代码 · 共 1,684 行 · 第 1/4 页
CC
1,684 行
if (g->pd_rdlocked) { omni_tracedmutex_lock sync(*omniTransportLock); g->rdUnLock(); }}////////////////////////////////////////////////////////////////////////voidgiopImpl10::unmarshalReplyHeader(giopStream* g) { char* hdr = (char*)g->pd_currentInputBuffer + g->pd_currentInputBuffer->start; if ((GIOP::MsgType)hdr[7] != GIOP::Reply) { // Unexpected reply. The other end is terribly confused. Drop the // connection and died. inputTerminalProtocolError(g); // Never reach here. } GIOP_C& giop_c = *((GIOP_C*) g); cdrStream& s = *((cdrStream*)g); IOP::ServiceContextList sctxts; if (omniInterceptorP::clientReceiveReply) { sctxts <<= s; } else { // Skip service context CORBA::ULong svcccount; CORBA::ULong svcctag; CORBA::ULong svcctxtsize; svcccount <<= s; while (svcccount-- > 0) { svcctag <<= s; svcctxtsize <<= s; s.skipInput(svcctxtsize); } } CORBA::ULong id; id <<= s; giop_c.replyId(id); CORBA::ULong v; v <<= s; switch (v) { case GIOP::SYSTEM_EXCEPTION: case GIOP::NO_EXCEPTION: case GIOP::USER_EXCEPTION: case GIOP::LOCATION_FORWARD: break; default: // Should never receive anything other that the above // Same treatment as wrong header inputTerminalProtocolError(g); // Never reach here. break; } giop_c.replyStatus((GIOP::ReplyStatusType)v); if (omniInterceptorP::clientReceiveReply) { omniInterceptors::clientReceiveReply_T::info_T info(giop_c, sctxts); omniInterceptorP::visit(info); }}////////////////////////////////////////////////////////////////////////voidgiopImpl10::unmarshalLocateReply(giopStream* g) { char* hdr = (char*)g->pd_currentInputBuffer + g->pd_currentInputBuffer->start; if ((GIOP::MsgType)hdr[7] != GIOP::LocateReply) { // Unexpected reply. The other end is terribly confused. Drop the // connection and died. inputTerminalProtocolError(g); // Never reach here. } GIOP_C& giop_c = *((GIOP_C*) g); cdrStream& s = *((cdrStream*)g); CORBA::ULong id; id <<= s; giop_c.replyId(id); CORBA::ULong v; v <<= s; switch (v) { case GIOP::UNKNOWN_OBJECT: case GIOP::OBJECT_HERE: case GIOP::OBJECT_FORWARD: break; default: // Should never receive anything other that the above // Same treatment as wrong header inputTerminalProtocolError(g); // Never reach here. break; } giop_c.locateStatus((GIOP::LocateStatusType)v);}////////////////////////////////////////////////////////////////////////voidgiopImpl10::unmarshalWildCardRequestHeader(giopStream* g) { g->inputMatchedId(1); char* hdr = (char*)g->pd_currentInputBuffer + g->pd_currentInputBuffer->start; ((GIOP_S*)g)->requestType((GIOP::MsgType)hdr[7]); switch (((GIOP_S*)g)->requestType()) { case GIOP::CloseConnection: inputRaiseCommFailure(g); break; case GIOP::Request: case GIOP::LocateRequest: case GIOP::CancelRequest: if (g->inputMessageSize() <= orbParameters::giopMaxMsgSize) { break; } // falls through if the message has exceeded the size limit. default: inputTerminalProtocolError(g); // Never reach here. break; }}////////////////////////////////////////////////////////////////////////voidgiopImpl10::unmarshalRequestHeader(giopStream* g) { GIOP_S& giop_s = *((GIOP_S*) g); cdrStream& s = *((cdrStream*)g); giop_s.service_contexts() <<= s; CORBA::ULong vl; CORBA::Boolean vb; // request id vl <<= s; giop_s.requestId(vl); // response expected vb = s.unmarshalBoolean(); giop_s.response_expected(vb); giop_s.result_expected(1); // object key vl <<= s; if (!s.checkInputOverrun(1,vl)) { OMNIORB_THROW(MARSHAL,MARSHAL_InvalidVariableLenComponentSize, CORBA::COMPLETED_NO); } giop_s.keysize(vl); s.get_octet_array(giop_s.key(),vl); // operation vl <<= s; if (!vl || !s.checkInputOverrun(1,vl)) { OMNIORB_THROW(MARSHAL,MARSHAL_InvalidVariableLenComponentSize, CORBA::COMPLETED_NO); } giop_s.set_operation_size(vl); char* op = giop_s.operation(); s.get_octet_array((CORBA::Octet*)op,vl); op[vl-1] = '\0'; // principal vl <<= s; if (!s.checkInputOverrun(1,vl)) { OMNIORB_THROW(MARSHAL,MARSHAL_InvalidVariableLenComponentSize, CORBA::COMPLETED_NO); } giop_s.set_principal_size(vl); giop_s.get_octet_array(giop_s.principal(), vl);}////////////////////////////////////////////////////////////////////////voidgiopImpl10::unmarshalLocateRequest(giopStream* g) { GIOP_S& giop_s = *((GIOP_S*) g); cdrStream& s = *((cdrStream*)g); CORBA::ULong vl; // request ID vl <<= s; giop_s.requestId(vl); // object key vl <<= s; if (!s.checkInputOverrun(1,vl)) { OMNIORB_THROW(MARSHAL,MARSHAL_InvalidVariableLenComponentSize, CORBA::COMPLETED_NO); } giop_s.keysize(vl); s.get_octet_array(giop_s.key(),vl);}////////////////////////////////////////////////////////////////////////size_tgiopImpl10::inputRemaining(giopStream* g) { return (g->inputFragmentToCome() + ((omni::ptr_arith_t)g->pd_inb_end - (omni::ptr_arith_t)g->pd_inb_mkr));}////////////////////////////////////////////////////////////////////////voidgiopImpl10::getInputData(giopStream* g,omni::alignment_t align,size_t sz) { omni::ptr_arith_t last = omni::align_to((omni::ptr_arith_t)g->pd_inb_mkr, align); omni::ptr_arith_t end = last + sz; if ( end <= (omni::ptr_arith_t) g->pd_inb_end) { return; } else { // Invariant check // Either the full message is already in the buffer or the part that is // in the buffer always ends at an 8 byte aligned boundary. // Also remember that sz is <= 8 always! size_t extra = end - (omni::ptr_arith_t) g->pd_inb_end; if (extra != sz) { if (!g->inputFragmentToCome()) { // The full message is already in the buffer. The unmarshalling // code is asking for more. This is an error causes by the received // data. We'll let the code below to raise a MARSHAL exception sz = extra; // in case sz == 0 } else { // Very bad. Should never happen given our invariant. { if( omniORB::trace(1) ) { omniORB::logger l; l << "Fatal error in unmarshalling message from " << g->pd_strand->connection->peeraddress() << ", invariant was violated at " << __FILE__ << ":" << __LINE__ << '\n'; } } OMNIORB_ASSERT(0); // never reach here. } } } if (g->inputFragmentToCome() < sz) { if (!g->inputMatchedId()) { // Because this error occurs when the id of the reply has not // been established. We have to treat this as an error on the // connection. Other threads that are reading from this connection // will notice this as well. g->pd_strand->state(giopStrand::DYING); } OMNIORB_THROW(MARSHAL,MARSHAL_PassEndOfMessage, (CORBA::CompletionStatus)g->completion()); } if (g->inputMatchedId()) { if (g->pd_currentInputBuffer) { g->releaseInputBuffer(g->pd_currentInputBuffer); g->pd_currentInputBuffer = 0; } if (!g->pd_input) { g->pd_currentInputBuffer = g->inputChunk(g->inputFragmentToCome()); } else { g->pd_currentInputBuffer = g->pd_input; g->pd_input = g->pd_currentInputBuffer->next; g->pd_currentInputBuffer->next = 0; } } else { // We keep the buffer around until the id of the reply is established. giopStream_Buffer** pp = &g->pd_input; while (*pp) { pp = &((*pp)->next); } *pp = g->pd_currentInputBuffer; g->pd_currentInputBuffer = 0; g->pd_currentInputBuffer = g->inputChunk(g->inputFragmentToCome()); } g->pd_inb_mkr = (void*)((omni::ptr_arith_t)g->pd_currentInputBuffer + g->pd_currentInputBuffer->start); g->pd_inb_end = (void*)((omni::ptr_arith_t)g->pd_currentInputBuffer + g->pd_currentInputBuffer->last); g->inputFragmentToCome(g->inputFragmentToCome() - (g->pd_currentInputBuffer->last - g->pd_currentInputBuffer->start));}////////////////////////////////////////////////////////////////////////voidgiopImpl10::skipInputData(giopStream* g,size_t sz) { copyInputData(g,0,sz,omni::ALIGN_1);}////////////////////////////////////////////////////////////////////////voidgiopImpl10::copyInputData(giopStream* g,void* b, size_t sz, omni::alignment_t align) { // If b == 0, we don't actually copy the data but just skip <sz> bytes. omni::ptr_arith_t last = omni::align_to((omni::ptr_arith_t)g->pd_inb_mkr, align); if ( last > (omni::ptr_arith_t) g->pd_inb_end ) { // Invariant check // Either the full message is already in the buffer or the part that is // in the buffer always ends at an 8 byte aligned boundary. if (!g->inputFragmentToCome()) { // The full message is already in the buffer. The unmarshalling // code is asking for more. This is an error causes by the received // data. if (!g->inputMatchedId()) { // Because this error occurs when the id of the reply has not // been established. We have to treat this as an error on the // connection. Other threads that are reading from this connection // will notice this as well. g->pd_strand->state(giopStrand::DYING); } OMNIORB_THROW(MARSHAL,MARSHAL_PassEndOfMessage, (CORBA::CompletionStatus)g->completion()); } else { // Very bad. Should never happen given our invariant. { if( omniORB::trace(1) ) { omniORB::logger l; l << "Fatal error in unmarshalling message from " << g->pd_strand->connection->peeraddress() << ", invariant was violated at " << __FILE__ << ":" << __LINE__ << '\n'; } } OMNIORB_ASSERT(0); // never reach here. } } g->pd_inb_mkr = (void*) last; while (sz) { size_t avail = (omni::ptr_arith_t) g->pd_inb_end - (omni::ptr_arith_t) g->pd_inb_mkr; if (avail >= sz) { avail = sz; } if (avail) { if (b) memcpy(b,g->pd_inb_mkr,avail); g->pd_inb_mkr = (void*)((omni::ptr_arith_t)g->pd_inb_mkr + avail); } sz -= avail; if (b) b = (void*)((omni::ptr_arith_t)b + avail); if (!sz) break; if (g->pd_inb_mkr == g->pd_inb_end) { if (g->inputFragmentToCome() < sz) { if (!g->inputMatchedId()) { // Because this error occurs when the id of the reply has not // been established. We have to treat this as an error on the // connection. Other threads that are reading from this connection // will notice this as well. g->pd_strand->state(giopStrand::DYING); } OMNIORB_THROW(MARSHAL,MARSHAL_PassEndOfMessage, (CORBA::CompletionStatus)g->completion()); // never reach here } if (g->inputMatchedId()) { if (g->pd_currentInputBuffer) { g->releaseInputBuffer(g->pd_currentInputBuffer); g->pd_currentInputBuffer = 0; } if (g->pd_input) { g->pd_currentInputBuffer = g->pd_input; g->pd_input = g->pd_currentInputBuffer->next; g->pd_currentInputBuffer->next = 0; } else { if ( b && sz >= giopStream::directReceiveCutOff ) { CORBA::ULong transz = g->inputFragmentToCome(); if (transz > sz) transz = sz; transz = (transz >> 3) << 3; g->inputCopyChunk(b,transz); sz -= transz; b = (void*)((omni::ptr_arith_t)b + transz); g->inputFragmentToCome(g->inputFragmentToCome() - transz); continue; } else { g->pd_currentInputBuffer = g->inputChunk(g->inputFragmentToCome()); } } } else {
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?