/// =-=-=-=-=-=-=- /// @brief function which sends the negotiation message error send_client_server_negotiation_message( irods::network_object_ptr _ptr, cs_neg_t& _cs_neg_msg ) { // =-=-=-=-=-=-=- // pack the negotiation message bytesBuf_t* cs_neg_buf = 0; int status = packStruct( &_cs_neg_msg, &cs_neg_buf, "CS_NEG_PI", RodsPackTable, 0, XML_PROT ); if ( status < 0 ) { return ERROR( status, "failed to pack client-server message" ); } // =-=-=-=-=-=-=- // pack the negotiation message irods::error ret = sendRodsMsg( _ptr, RODS_CS_NEG_T, cs_neg_buf, 0, 0, 0, XML_PROT ); freeBBuf( cs_neg_buf ); if ( !ret.ok() ) { return PASSMSG( "failed to send client-server negotiation message", ret ); } return SUCCESS(); } // send_client_server_negotiation_message
irods::error sendVersion( irods::network_object_ptr _ptr, int versionStatus, int reconnPort, char* reconnAddr, int cookie ) { version_t myVersion; int status; bytesBuf_t *versionBBuf = NULL; /* setup the version struct */ memset( &myVersion, 0, sizeof( myVersion ) ); myVersion.status = versionStatus; rstrcpy( myVersion.relVersion, RODS_REL_VERSION, NAME_LEN ); rstrcpy( myVersion.apiVersion, RODS_API_VERSION, NAME_LEN ); if ( reconnAddr != NULL ) { myVersion.reconnPort = reconnPort; rstrcpy( myVersion.reconnAddr, reconnAddr, LONG_NAME_LEN ); myVersion.cookie = cookie; } else { // =-=-=-=-=-=-=- // super secret jargon irods detection // sshhhhhhh... myVersion.cookie = 400; } /* alway use XML for version */ status = packStruct( ( char * ) &myVersion, &versionBBuf, "Version_PI", RodsPackTable, 0, XML_PROT ); if ( status < 0 ) { return ERROR( status, "packStruct error" ); } irods::error ret = sendRodsMsg( _ptr, RODS_VERSION_T, versionBBuf, NULL, NULL, 0, XML_PROT ); freeBBuf( versionBBuf ); if ( !ret.ok() ) { return PASS( ret ); } return SUCCESS(); } // sendVersion
// =-=-=-=-=-=-=- // irods::error writeMsgHeader( irods::network_object_ptr _ptr, msgHeader_t* _header ) { // =-=-=-=-=-=-=- // always use XML_PROT for the Header bytesBuf_t* header_buf = 0; int status = packStruct( static_cast<void *>( _header ), &header_buf, "MsgHeader_PI", RodsPackTable, 0, XML_PROT ); if ( status < 0 || 0 == header_buf ) { return ERROR( status, "packstruct error" ); } // =-=-=-=-=-=-=- // resolve a network interface plugin from the // network object irods::plugin_ptr p_ptr; irods::error ret = _ptr->resolve( irods::NETWORK_INTERFACE, p_ptr ); if ( !ret.ok() ) { freeBBuf( header_buf ); return PASSMSG( "failed to resolve network interface", ret ); } // =-=-=-=-=-=-=- // make the call to the plugin interface irods::first_class_object_ptr ptr = boost::dynamic_pointer_cast< irods::first_class_object >( _ptr ); irods::network_ptr net = boost::dynamic_pointer_cast< irods::network >( p_ptr ); ret = net->call< bytesBuf_t* >( irods::NETWORK_OP_WRITE_HEADER, ptr, header_buf ); freeBBuf( header_buf ); if ( !ret.ok() ) { return PASS( ret ); } return SUCCESS(); } // writeMsgHeader
// =-=-=-=-=-=-=- // interface for requesting a reconnection irods::error sendReconnMsg( irods::network_object_ptr _ptr, reconnMsg_t* _msg ) { // =-=-=-=-=-=-=- // trap invalid param if ( _msg == NULL ) { return ERROR( USER__NULL_INPUT_ERR, "null msg buf" ); } // =-=-=-=-=-=-=- // pack outgoing message - alway use XML for version bytesBuf_t* recon_buf = NULL; int status = packStruct( static_cast<void*>( _msg ), &recon_buf, "ReconnMsg_PI", RodsPackTable, 0, XML_PROT ); if ( status < 0 ) { return ERROR( status, "failed to pack struct" ); } // =-=-=-=-=-=-=- // pack outgoing message - alway use XML for version irods::error ret = sendRodsMsg( _ptr, RODS_RECONNECT_T, recon_buf, NULL, NULL, 0, XML_PROT ); freeBBuf( recon_buf ); if ( !ret.ok() ) { rodsLogError( LOG_ERROR, status, "sendReconnMsg: sendRodsMsg of reconnect msg failed, status = %d", status ); } return CODE( status ); } // sendReconnMsg
int packReiAndArg (rsComm_t *rsComm, ruleExecInfo_t *rei, char *myArgv[], int myArgc, bytesBuf_t **packedReiAndArgBBuf) { int status; ruleExecInfoAndArg_t reiAndArg; if (packedReiAndArgBBuf == NULL) { rodsLog (LOG_ERROR, "packReiAndArg: NULL packedReiAndArgBBuf input"); return (SYS_INTERNAL_NULL_INPUT_ERR); } if (myArgc > 0 && (myArgv == NULL || *myArgv == NULL)) { rodsLog (LOG_ERROR, "packReiAndArg: NULL myArgv input"); return (SYS_INTERNAL_NULL_INPUT_ERR); } memset (&reiAndArg, 0, sizeof (reiAndArg)); reiAndArg.rei = rei; reiAndArg.reArg.myArgc = myArgc; reiAndArg.reArg.myArgv = myArgv; /* pack the reiAndArg */ status = packStruct ((void *) &reiAndArg, packedReiAndArgBBuf, "ReiAndArg_PI", RodsPackTable, 0, NATIVE_PROT); if (status < 0) { rodsLog (LOG_ERROR, "packReiAndArg: packStruct error. status = %d", status); return (status); } return (status); }
int packRei (rsComm_t *rsComm, ruleExecInfo_t *rei, bytesBuf_t **packedReiBBuf) { int status; if (packedReiBBuf == NULL) { return (SYS_INTERNAL_NULL_INPUT_ERR); } /* pack the rei */ status = packStruct ((void *) rei, packedReiBBuf, "Rei_PI", RodsPackTable, 0, NATIVE_PROT); if (status < 0) { rodsLog (LOG_ERROR, "packRei: packStruct error. status = %d", status); return (status); } return (status); }
int sendApiReply( rsComm_t * rsComm, int apiInx, int retVal, void * myOutStruct, bytesBuf_t * myOutBsBBuf ) { int status = 0; bytesBuf_t *outStructBBuf = NULL; bytesBuf_t *myOutStructBBuf; bytesBuf_t *rErrorBBuf = NULL; bytesBuf_t *myRErrorBBuf; //#ifndef windows_platform svrChkReconnAtSendStart( rsComm ); //#endif if ( retVal == SYS_HANDLER_DONE_NO_ERROR ) { /* not actually an error */ retVal = 0; } // =-=-=-=-=-=-=- // create a network object irods::network_object_ptr net_obj; irods::error ret = irods::network_factory( rsComm, net_obj ); if ( !ret.ok() ) { irods::log( PASS( ret ) ); return ret.code(); } irods::api_entry_table& RsApiTable = irods::get_server_api_table(); if ( RsApiTable[apiInx]->outPackInstruct != NULL && myOutStruct != NULL ) { status = packStruct( ( char * ) myOutStruct, &outStructBBuf, ( char* )RsApiTable[apiInx]->outPackInstruct, RodsPackTable, FREE_POINTER, rsComm->irodsProt ); if ( status < 0 ) { rodsLog( LOG_NOTICE, "sendApiReply: packStruct error, status = %d", status ); sendRodsMsg( net_obj, RODS_API_REPLY_T, NULL, NULL, NULL, status, rsComm->irodsProt ); svrChkReconnAtSendEnd( rsComm ); return status; } myOutStructBBuf = outStructBBuf; } else { myOutStructBBuf = NULL; } if ( RsApiTable[apiInx]->outBsFlag == 0 ) { myOutBsBBuf = NULL; } if ( rsComm->rError.len > 0 ) { status = packStruct( ( char * ) &rsComm->rError, &rErrorBBuf, "RError_PI", RodsPackTable, 0, rsComm->irodsProt ); if ( status < 0 ) { rodsLog( LOG_NOTICE, "sendApiReply: packStruct error, status = %d", status ); sendRodsMsg( net_obj, RODS_API_REPLY_T, NULL, NULL, NULL, status, rsComm->irodsProt ); svrChkReconnAtSendEnd( rsComm ); freeBBuf( outStructBBuf ); freeBBuf( rErrorBBuf ); return status; } myRErrorBBuf = rErrorBBuf; } else { myRErrorBBuf = NULL; } ret = sendRodsMsg( net_obj, RODS_API_REPLY_T, myOutStructBBuf, myOutBsBBuf, myRErrorBBuf, retVal, rsComm->irodsProt ); if ( !ret.ok() ) { int status1; irods::log( PASS( ret ) ); if ( rsComm->reconnSock > 0 ) { int savedStatus = ret.code(); boost::unique_lock< boost::mutex > boost_lock( *rsComm->thread_ctx->lock ); rodsLog( LOG_DEBUG, "sendApiReply: svrSwitchConnect. cliState = %d,agState=%d", rsComm->clientState, rsComm->agentState ); status1 = svrSwitchConnect( rsComm ); boost_lock.unlock(); if ( status1 > 0 ) { /* should not be here */ rodsLog( LOG_NOTICE, "sendApiReply: Switch connection and retry sendRodsMsg" ); ret = sendRodsMsg( net_obj, RODS_API_REPLY_T, myOutStructBBuf, myOutBsBBuf, myRErrorBBuf, retVal, rsComm->irodsProt ); if ( ret.code() >= 0 ) { rodsLog( LOG_NOTICE, "sendApiReply: retry sendRodsMsg succeeded" ); } else { status = savedStatus; } } } } svrChkReconnAtSendEnd( rsComm ); freeBBuf( outStructBBuf ); freeBBuf( rErrorBBuf ); return status; }
int rsNcGetAggInfo( rsComm_t *rsComm, ncOpenInp_t *ncOpenInp, ncAggInfo_t **ncAggInfo ) { specCollCache_t *specCollCache = NULL; collInp_t collInp; int handleInx; collEnt_t *collEnt; int status = 0; int status2 = 0; int savedStatus = 0; ncOpenInp_t childNcOpenInp; ncAggElement_t *ncAggElement = NULL; bytesBuf_t *packedBBuf = NULL; bzero( &collInp, sizeof( collInp ) ); rstrcpy( collInp.collName, ncOpenInp->objPath, MAX_NAME_LEN ); resolveLinkedPath( rsComm, collInp.collName, &specCollCache, &ncOpenInp->condInput ); collInp.flags = VERY_LONG_METADATA_FG; handleInx = irods::server_api_call ( OPEN_COLLECTION_AN, rsComm, &collInp ); if ( handleInx < 0 ) { rodsLog( LOG_ERROR, "rsNcGetAggInfo: rsOpenCollection of %s error. status = %d", collInp.collName, handleInx ); return ( handleInx ); } bzero( &childNcOpenInp, sizeof( childNcOpenInp ) ); *ncAggInfo = ( ncAggInfo_t * ) calloc( 1, sizeof( ncAggInfo_t ) ); rstrcpy( ( *ncAggInfo )->ncObjectName, ncOpenInp->objPath, MAX_NAME_LEN ); while ( ( status2 = irods::server_api_call ( READ_COLLECTION_AN, rsComm, &handleInx, &collEnt ) ) >= 0 ) { if ( collEnt->objType != DATA_OBJ_T ) { free( collEnt ); continue; } else if ( strcmp( collEnt->dataType, "netcdf" ) != 0 ) { if ( strcmp( collEnt->dataName, NC_AGG_INFO_FILE_NAME ) != 0 ) { rodsLog( LOG_NOTICE, "rsNcGetAggInfo: dataType of %s in %s is not 'netcdf' type", collEnt->dataName, collInp.collName ); savedStatus = NETCDF_INVALID_DATA_TYPE; } free( collEnt ); continue; } snprintf( childNcOpenInp.objPath, MAX_NAME_LEN, "%s/%s", collInp.collName, collEnt->dataName ); status = irods::server_api_call ( NC_GET_AGG_ELEMENT_AN, rsComm, &childNcOpenInp, &ncAggElement ); if ( status < 0 ) { rodsLogError( LOG_ERROR, status, "rsNcGetAggInfo: rsNcGetAggElement of %s error.", childNcOpenInp.objPath ); free( collEnt ); break; } else { status = addNcAggElement( ncAggElement, *ncAggInfo ); free( ncAggElement ); if ( status < 0 ) { free( collEnt ); break; } } free( collEnt ); } irods::server_api_call ( CLOSE_COLLECTION_AN, rsComm, &handleInx ); if ( status2 < 0 && status2 != CAT_NO_ROWS_FOUND && status >= 0 ) { status = status2; } if ( status >= 0 && ( ncOpenInp->mode & NC_WRITE ) != 0 ) { dataObjInp_t dataObjInp; portalOprOut_t *portalOprOut = NULL; status = packStruct( ( void * ) * ncAggInfo, &packedBBuf, "NcAggInfo_PI", RodsPackTable, 0, XML_PROT ); if ( status < 0 ) { rodsLogError( LOG_ERROR, status, "rsNcGetAggInfo: packStruct error for %s", childNcOpenInp.objPath ); return status; } /* write it */ bzero( &dataObjInp, sizeof( dataObjInp ) ); replKeyVal( &ncOpenInp->condInput, &dataObjInp.condInput ); snprintf( dataObjInp.objPath, MAX_NAME_LEN, "%s/%s", collInp.collName, NC_AGG_INFO_FILE_NAME ); dataObjInp.dataSize = packedBBuf->len; dataObjInp.oprType = PUT_OPR; addKeyVal( &dataObjInp.condInput, DATA_INCLUDED_KW, "" ); addKeyVal( &dataObjInp.condInput, FORCE_FLAG_KW, "" ); status = irods::server_api_call ( DATA_OBJ_PUT_AN, rsComm, &dataObjInp, packedBBuf, &portalOprOut ); clearBBuf( packedBBuf ); clearKeyVal( &dataObjInp.condInput ); if ( portalOprOut != NULL ) { free( portalOprOut ); } if ( status < 0 ) { rodsLogError( LOG_ERROR, status, "rsNcGetAggInfo: rsDataObjPut error for %s", dataObjInp.objPath ); } } if ( status < 0 ) { return status; } else { return savedStatus; } }
int sendStartupPack( rcComm_t *conn, int connectCnt, int reconnFlag ) { startupPack_t startupPack; int status; char *tmpStr; bytesBuf_t *startupPackBBuf = NULL; /* setup the startup pack */ startupPack.irodsProt = conn->irodsProt; startupPack.connectCnt = connectCnt; startupPack.reconnFlag = reconnFlag; rstrcpy( startupPack.proxyUser, conn->proxyUser.userName, NAME_LEN ); rstrcpy( startupPack.proxyRodsZone, conn->proxyUser.rodsZone, NAME_LEN ); rstrcpy( startupPack.clientUser, conn->clientUser.userName, NAME_LEN ); rstrcpy( startupPack.clientRodsZone, conn->clientUser.rodsZone, NAME_LEN ); rstrcpy( startupPack.relVersion, RODS_REL_VERSION, NAME_LEN ); rstrcpy( startupPack.apiVersion, RODS_API_VERSION, NAME_LEN ); if ( ( tmpStr = getenv( SP_OPTION ) ) != NULL ) { rstrcpy( startupPack.option, tmpStr, NAME_LEN ); } else { startupPack.option[0] = '\0'; } // =-=-=-=-=-=-=- // if the advanced negotiation is requested from the irodsEnv, // tack those results onto the startup pack option string rodsEnv rods_env; status = getRodsEnv( &rods_env ); if ( status >= 0 && strlen( rods_env.rodsClientServerNegotiation ) > 0 ) { strncat( startupPack.option, rods_env.rodsClientServerNegotiation, strlen( rods_env.rodsClientServerNegotiation ) ); } /* always use XML_PROT for the startupPack */ status = packStruct( ( void * ) &startupPack, &startupPackBBuf, "StartupPack_PI", RodsPackTable, 0, XML_PROT ); if ( status < 0 ) { rodsLogError( LOG_NOTICE, status, "sendStartupPack: packStruct error, status = %d", status ); return status; } irods::network_object_ptr net_obj; irods::error ret = irods::network_factory( conn, net_obj ); if ( !ret.ok() ) { irods::log( PASS( ret ) ); freeBBuf( startupPackBBuf ); return ret.code(); } ret = sendRodsMsg( net_obj, RODS_CONNECT_T, startupPackBBuf, NULL, NULL, 0, XML_PROT ); freeBBuf( startupPackBBuf ); if ( !ret.ok() ) { irods::log( PASS( ret ) ); return ret.code(); } return ret.code(); } // sendStartupPack
int main(int argc, char **argv) { int status; packItem_t *packItemHead = NULL; startupPack_t myStartupPack, *outStartupPack; rError_t myError, *outError; bytesBuf_t *packedResult; genQueryOut_t myQueryOut, *outQueryOut; char *tmpValue; int i; modDataObjMeta_t modDataObjMetaInp, *outModDataObjMeta; dataObjInfo_t dataObjInfo; keyValPair_t regParam; authCheckInp_t authCheckInp, *outAuthCheckInp; genQueryInp_t genQueryInp, *outGenQueryInp; irodsProt_t irodsProt = XML_PROT; memset (&genQueryInp, 0, sizeof (genQueryInp)); addInxVal (&genQueryInp.sqlCondInp, COL_COLL_NAME, "=xyz"); addInxIval (&genQueryInp.selectInp, COL_COLL_ID, 1); genQueryInp.maxRows = 1234567890; status = packStruct (&genQueryInp, &packedResult, "GenQueryInp_PI", NULL, 0, irodsProt); printf ("packStruct GenQueryInp_PI, status = %d\n", status); if (irodsProt == XML_PROT) writePackedRes (packedResult, "queryInp.out"); status = unpackStruct (packedResult->buf, (void **) &outGenQueryInp, "GenQueryInp_PI", NULL, irodsProt); printf ("unpackStruct of empty GenQueryInp_PI, status = %d\n", status); memset (&authCheckInp, 0, sizeof (authCheckInp)); status = packStruct (&authCheckInp, &packedResult, "authCheckInp_PI", NULL, 0, irodsProt); printf ("packStruct of empty authCheckInp_PI, status = %d\n", status); if (irodsProt == XML_PROT) writePackedRes (packedResult, "auth.out"); status = unpackStruct (packedResult->buf, (void **) &outAuthCheckInp, "authCheckInp_PI", NULL, irodsProt); printf ("unpackStruct of empty authCheckInp_PI, status = %d\n", status); memset (&dataObjInfo, 0, sizeof (dataObjInfo_t)); memset (®Param, 0, sizeof (keyValPair_t)); strcpy (dataObjInfo.objPath, "/tmp/thisIsATest"); modDataObjMetaInp.dataObjInfo = &dataObjInfo; modDataObjMetaInp.regParam = ®Param; status = packStruct (&modDataObjMetaInp, &packedResult, "ModDataObjMeta_PI", NULL, 0, irodsProt); printf ("packStruct of ModDataObjMeta_PI, status = %d\n", status); if (irodsProt == XML_PROT) writePackedRes (packedResult, "modeData.out"); status = unpackStruct (packedResult->buf, (void **) &outModDataObjMeta, "ModDataObjMeta_PI", NULL, irodsProt); printf ("unpackStruct of ModDataObjMeta_PI, status = %d\n", status); memset (&myQueryOut, 0, sizeof (myQueryOut)); /* pack and unpack empty struct */ status = packStruct (&myQueryOut, &packedResult, "GenQueryOut_PI", NULL, 0, irodsProt); printf ("packStruct empty myQueryOut status = %d\n", status); if (irodsProt == XML_PROT) writePackedRes (packedResult, "genq.out"); status = unpackStruct (packedResult->buf, (void **) &outQueryOut, "GenQueryOut_PI", NULL, irodsProt); printf ("unpackStruct empty myQueryOut status = %d\n", status); memset (&myQueryOut, 0, sizeof (myQueryOut)); myQueryOut.rowCnt = 2; myQueryOut.attriCnt = 4; myQueryOut.sqlResult[0].attriInx = 10; myQueryOut.sqlResult[0].len = 20; myQueryOut.sqlResult[0].value = tmpValue = (char *) malloc (20*2); sprintf (tmpValue, "value 0,1"); tmpValue += 20; sprintf (tmpValue, "value 0,2"); myQueryOut.sqlResult[1].attriInx = 20; myQueryOut.sqlResult[1].len = 30; myQueryOut.sqlResult[1].value = tmpValue = (char *) malloc (30*2); sprintf (tmpValue, "value 1,1"); tmpValue += 30; sprintf (tmpValue, "value 1,2"); myQueryOut.sqlResult[2].attriInx = 30; myQueryOut.sqlResult[2].len = 40; myQueryOut.sqlResult[2].value = tmpValue = (char *) malloc (40*2); sprintf (tmpValue, "value 2,1"); tmpValue += 40; sprintf (tmpValue, "value 2,2"); myQueryOut.sqlResult[3].attriInx = 40; myQueryOut.sqlResult[3].len = 50; myQueryOut.sqlResult[3].value = tmpValue = (char *) malloc (50*2); memset (tmpValue, 0, 50*2); status = packStruct (&myQueryOut, &packedResult, "GenQueryOut_PI", NULL, 0, irodsProt); printf ("packStruct status = %d\n", status); if (irodsProt == XML_PROT) writePackedRes (packedResult, "genq.out"); status = unpackStruct (packedResult->buf, (void **) &outQueryOut, "GenQueryOut_PI", NULL, irodsProt); printf ("unpackStruct status = %d\n", status); status = parsePackInstruct (TEST_PI, &packItemHead); printf ("parsePackInstruct status = %d\n", status); myStartupPack.connectCnt = 11; myStartupPack.irodsProt = XML_PROT; strcpy (myStartupPack.proxyUser, "proxyUser"); strcpy (myStartupPack.proxyRodsZone, "proxyRodsZone"); strcpy (myStartupPack.clientUser, "myclientUser"); strcpy (myStartupPack.clientRodsZone, "clientRodsZone"); strcpy (myStartupPack.relVersion, "relVersion"); strcpy (myStartupPack.apiVersion, "apiVersion"); strcpy (myStartupPack.option, "option"); status = packStruct (&myStartupPack, &packedResult, "StartupPack_PI", NULL, 0, XML_PROT); printf ("packStruct of StartupPack_PI status = %d\n", status); if (irodsProt == XML_PROT) writePackedRes (packedResult, "startup.out"); status = unpackStruct (packedResult->buf, (void **) &outStartupPack, "StartupPack_PI", NULL, irodsProt); printf ("unpackStruct of StartupPack_PI status = %d\n", status); myError.len = 3; myError.errMsg = (rErrMsg_t **) malloc (sizeof (void *) * 3); for (i = 0; i < 3; i++) { myError.errMsg[i] = (rErrMsg_t *) malloc (sizeof (rErrMsg_t)); sprintf (myError.errMsg[i]->msg, "error %d\n", i); myError.errMsg[i]->status = i; } status = packStruct (&myError, &packedResult, "RError_PI", NULL, 0, irodsProt); printf ("packStruct of RErrMsg_PI status = %d\n", status); if (irodsProt == XML_PROT) writePackedRes (packedResult, "error.out"); status = unpackStruct (packedResult->buf, (void **) &outError, "RError_PI", NULL, irodsProt); printf ("unpackStruct of RErrMsg_PI status = %d\n", status); }
int sendApiRequest( rcComm_t *conn, int apiInx, void *inputStruct, bytesBuf_t *inputBsBBuf ) { int status = 0; bytesBuf_t *inputStructBBuf = NULL; bytesBuf_t *myInputStructBBuf = NULL; cliChkReconnAtSendStart( conn ); irods::api_entry_table& RcApiTable = irods::get_client_api_table(); irods::api_entry_table::iterator itr = RcApiTable.find( apiInx ); if ( itr == RcApiTable.end() ) { rodsLogError( LOG_ERROR, SYS_UNMATCHED_API_NUM, "API Entry not found at index %d", apiInx ); return SYS_UNMATCHED_API_NUM; } if ( RcApiTable[apiInx]->inPackInstruct != NULL ) { if ( inputStruct == NULL ) { cliChkReconnAtSendEnd( conn ); return ( USER_API_INPUT_ERR ); } status = packStruct( ( void * ) inputStruct, &inputStructBBuf, ( char* )RcApiTable[apiInx]->inPackInstruct, RodsPackTable, 0, conn->irodsProt ); if ( status < 0 ) { rodsLogError( LOG_ERROR, status, "sendApiRequest: packStruct error, status = %d", status ); cliChkReconnAtSendEnd( conn ); return status; } myInputStructBBuf = inputStructBBuf; } else { myInputStructBBuf = NULL; }; if ( RcApiTable[apiInx]->inBsFlag <= 0 ) { inputBsBBuf = NULL; } irods::network_object_ptr net_obj; irods::error ret = irods::network_factory( conn, net_obj ); if ( !ret.ok() ) { irods::log( PASS( ret ) ); return ret.code(); } ret = sendRodsMsg( net_obj, RODS_API_REQ_T, myInputStructBBuf, inputBsBBuf, NULL, RcApiTable[apiInx]->apiNumber, conn->irodsProt ); if ( !ret.ok() ) { irods::log( PASS( ret ) ); if ( conn->svrVersion != NULL && conn->svrVersion->reconnPort > 0 ) { int status1; int savedStatus = ret.code() ; conn->thread_ctx->lock->lock(); status1 = cliSwitchConnect( conn ); rodsLog( LOG_DEBUG, "sendApiRequest: svrSwitchConnect. cliState = %d,agState=%d", conn->clientState, conn->agentState ); conn->thread_ctx->lock->unlock(); if ( status1 > 0 ) { /* should not be here */ rodsLog( LOG_NOTICE, "sendApiRequest: Switch connection and retry sendRodsMsg" ); ret = sendRodsMsg( net_obj, RODS_API_REQ_T, myInputStructBBuf, inputBsBBuf, NULL, RcApiTable[apiInx]->apiNumber, conn->irodsProt ); if ( !ret.ok() ) { irods::log( PASS( ret ) ); } else { status = savedStatus; } } // if status1 > 0 } // if svrVersion != NULL ... } else { // =-=-=-=-=-=-=- // be sure to pass along the return code from the // plugin call status = ret.code(); } freeBBuf( inputStructBBuf ); return ( status ); }