INT32 rtnCoord2PhaseCommit::execute( CHAR * pReceiveBuffer, SINT32 packSize,
                                    CHAR * * ppResultBuffer, pmdEDUCB * cb,
                                    MsgOpReply & replyHeader,
                                    BSONObj **ppErrorObj )
   {
      INT32 rc = SDB_OK;
      INT32 rcTmp = SDB_OK;

      MsgHeader *pHeader               = (MsgHeader *)pReceiveBuffer;
      replyHeader.header.messageLength = sizeof( MsgOpReply );
      replyHeader.header.opCode        = MSG_BS_TRANS_COMMIT_RSP;
      replyHeader.header.requestID     = pHeader->requestID;
      replyHeader.header.routeID.value = 0;
      replyHeader.header.TID           = pHeader->TID;
      replyHeader.contextID            = -1;
      replyHeader.flags                = SDB_OK;
      replyHeader.numReturned          = 0;
      replyHeader.startFrom            = 0;

      if ( !cb->isTransaction() )
      {
         rc = SDB_DPS_TRANS_NO_TRANS;
         goto error;
      }

      rc = doPhase1( pReceiveBuffer, packSize, ppResultBuffer, cb, replyHeader );
      PD_CHECK( SDB_OK == rc, rc, errorcancel, PDERROR,
               "execute failed on phase1(rc=%d)",
               rc );

      rc = doPhase2( pReceiveBuffer, packSize, ppResultBuffer, cb, replyHeader );
      PD_RC_CHECK( rc, PDERROR,
                  "execute failed on phase2(rc=%d)",
                  rc );
   done:
      return rc;

   errorcancel:
      rcTmp = cancelOp( pReceiveBuffer, packSize, ppResultBuffer, cb, replyHeader );
      if ( rcTmp )
      {
         PD_LOG ( PDERROR,
                  "failed to cancel the operate(rc=%d)",
                  rcTmp );
      }

   error:
      replyHeader.flags = rc;
      goto done;
   }
Exemplo n.º 2
0
   INT32 rtnCoord2PhaseCommit::execute( MsgHeader *pMsg,
                                        pmdEDUCB *cb,
                                        INT64 &contextID,
                                        rtnContextBuf *buf )
   {
      INT32 rc = SDB_OK;
      INT32 rcTmp = SDB_OK;

      contextID                        = -1 ;

      if ( !cb->isTransaction() )
      {
         rc = SDB_DPS_TRANS_NO_TRANS ;
         goto error;
      }

      rc = doPhase1( pMsg, cb, contextID, buf );
      PD_CHECK( SDB_OK == rc, rc, errorcancel, PDERROR,
                "Execute failed on phase1(rc=%d)", rc ) ;

      rc = doPhase2( pMsg, cb, contextID, buf );
      PD_RC_CHECK( rc, PDERROR,
                   "Execute failed on phase2(rc=%d)", rc ) ;

   done:
      return rc ;
   errorcancel:
      rcTmp = cancelOp( pMsg, cb, contextID, buf );
      if ( rcTmp )
      {
         PD_LOG ( PDERROR, "Failed to cancel the operate, rc: %d",
                  rcTmp );
      }
   error:
      goto done ;
   }