void _omManager::_sendRes2Agent( NET_HANDLE handle, MsgHeader *pSrcMsg, INT32 flag, rtnContextBuf &buffObj ) { MsgOpReply reply ; INT32 rc = SDB_OK ; const CHAR *pBody = buffObj.data() ; INT32 bodyLen = buffObj.size() ; reply.header.messageLength = sizeof( MsgOpReply ) + bodyLen ; reply.header.opCode = MAKE_REPLY_TYPE( pSrcMsg->opCode ) ; reply.header.TID = pSrcMsg->TID ; reply.header.routeID.value = 0 ; reply.header.requestID = pSrcMsg->requestID ; reply.contextID = -1 ; reply.flags = flag ; reply.startFrom = 0 ; reply.numReturned = buffObj.recordNum() ; if ( bodyLen > 0 ) { rc = _netAgent.syncSend ( handle, (MsgHeader *)( &reply ), (void*)pBody, bodyLen ) ; } else { rc = _netAgent.syncSend ( handle, (void *)( &reply ) ) ; } if ( rc != SDB_OK ) { PD_LOG ( PDERROR, "send response to agent failed:rc=%d", rc ) ; } }
INT32 _pmdCoordProcessor::_processCoordMsg( MsgHeader *msg, MsgOpReply &replyHeader, rtnContextBuf &contextBuff ) { INT32 rc = SDB_OK ; if ( NULL != _pErrorObj ) { SDB_OSS_DEL _pErrorObj ; _pErrorObj = NULL ; } if ( NULL != _pResultBuff ) { _pResultBuff = NULL ; } CoordCB *pCoordcb = _pKrcb->getCoordCB(); rtnCoordProcesserFactory *pProcesserFactory = pCoordcb->getProcesserFactory(); if ( MSG_AUTH_VERIFY_REQ == msg->opCode ) { rc = SDB_COORD_UNKNOWN_OP_REQ ; goto done ; } else if ( MSG_BS_INTERRUPTE == msg->opCode || MSG_BS_INTERRUPTE_SELF == msg->opCode || MSG_BS_DISCONNECT == msg->opCode ) { } else if ( !getClient()->isAuthed() ) { rc = getClient()->authenticate( "", "" ) ; if ( rc ) { goto done ; } } switch ( msg->opCode ) { case MSG_BS_GETMORE_REQ : rc = SDB_COORD_UNKNOWN_OP_REQ ; break ; case MSG_BS_QUERY_REQ: { MsgOpQuery *pQueryMsg = ( MsgOpQuery * )msg ; CHAR *pQueryName = pQueryMsg->name ; SINT32 queryNameLen = pQueryMsg->nameLength ; if ( queryNameLen > 0 && '$' == pQueryName[0] ) { rtnCoordCommand *pCmdProcesser = pProcesserFactory->getCommandProcesser( pQueryMsg ) ; if ( NULL != pCmdProcesser ) { rc = pCmdProcesser->execute( ( CHAR *)msg, msg->messageLength, eduCB(), replyHeader, &contextBuff ) ; break ; } } } default: { rtnContextBase *pContext = NULL ; rtnCoordOperator *pOperator = pProcesserFactory->getOperator( msg->opCode ) ; rc = pOperator->execute( ( CHAR* )msg, msg->messageLength, eduCB(), replyHeader, &contextBuff ) ; if ( MSG_BS_QUERY_REQ == msg->opCode && ( ((MsgOpQuery*)msg)->flags & FLG_QUERY_WITH_RETURNDATA ) && -1 != replyHeader.contextID && NULL != ( pContext = _pRTNCB->contextFind( replyHeader.contextID ) ) ) { rc = pContext->getMore( -1, contextBuff, eduCB() ) ; if ( rc || pContext->eof() ) { _pRTNCB->contextDelete( replyHeader.contextID, eduCB() ) ; replyHeader.contextID = -1 ; } if ( SDB_DMS_EOC == rc ) { rc = SDB_OK ; } else if ( rc ) { PD_LOG( PDERROR, "Failed to query with return data, " "rc: %d", rc ) ; } } } break; } if ( rc && contextBuff.size() == 0 ) { if ( NULL != _pErrorObj ) { contextBuff = rtnContextBuf( *_pErrorObj ) ; } else { BSONObj obj = utilGetErrorBson( rc, eduCB()->getInfo( EDU_INFO_ERROR ) ) ; contextBuff = rtnContextBuf( obj ) ; } } done: return rc ; }