Пример #1
0
int
chkAndResetRule( rsComm_t *rsComm ) {
//    char *configDir;
//    char rulesFileName[MAX_NAME_LEN];
    int status = 0;
    uint mtime;

//    configDir = getConfigDir();
//    snprintf( rulesFileName, MAX_NAME_LEN, "%s/reConfigs/core.re",
//              configDir );

    std::string re_full_path;
    irods::error ret = irods::get_full_path_for_config_file( "core.re", re_full_path );
    if ( !ret.ok() ) {
        irods::log( PASS( ret ) );
        return ret.code();
    }

    path p( re_full_path );
    if ( !exists( p ) ) {
        status = UNIX_FILE_STAT_ERR - errno;
        rodsLog( LOG_ERROR,
                 "chkAndResetRule: unable to read rule config file %s, status = %d",
                 re_full_path.c_str(), status );
        return ( status );
    }

    mtime = ( uint ) last_write_time( p );

    if ( CoreIrbTimeStamp == 0 ) {
        /* first time */
        CoreIrbTimeStamp = mtime;
        return ( 0 );
    }

    if ( mtime > CoreIrbTimeStamp ) {
        /* file has been changed */
        rodsLog( LOG_NOTICE,
                 "chkAndResetRule: reconf file %s has been changed. re-initializing",
                 re_full_path.c_str() );
        CoreIrbTimeStamp = mtime;
        clearCoreRule();
        /* The shared memory cache may have already been updated, do not force reload */
        status = initRuleEngine( RULE_ENGINE_TRY_CACHE, NULL, reRuleStr, reFuncMapStr, reVariableMapStr );
        if ( status < 0 ) {
            rodsLog( LOG_ERROR,
                     "chkAndResetRule: initRuleEngine error, status = %d", status );
        }
    }
    return status;
}
Пример #2
0
int
initAgent( int processType, rsComm_t *rsComm ) {
    int status;
    rsComm_t myComm;
    ruleExecInfo_t rei;

    initProcLog();

    status = initServerInfo( rsComm );
    if ( status < 0 ) {
        rodsLog( LOG_ERROR,
                 "initAgent: initServerInfo error, status = %d",
                 status );
        return status;
    }

    initL1desc();
    initSpecCollDesc();
    status = initFileDesc();
    if ( status < 0 ) {
        rodsLog( LOG_ERROR,
                 "initAgent: initFileDesc error, status = %d",
                 status );
        return status;
    }
#ifdef TAR_STRUCT_FILE
//    initStructFileDesc ();
//    initTarSubFileDesc ();
#endif
    status = initRuleEngine( processType, rsComm, reRuleStr, reVariableMapStr, reFuncMapStr );
    if ( status < 0 ) {
        rodsLog( LOG_ERROR,
                 "initAgent: initRuleEngine error, status = %d", status );
        return status;
    }

    memset( &rei, 0, sizeof( rei ) );
    rei.rsComm = rsComm;

    if ( ProcessType == AGENT_PT ) {
        status = applyRule( "acChkHostAccessControl", NULL, &rei,
                            NO_SAVE_REI );

        if ( status < 0 ) {
            rodsLog( LOG_ERROR,
                     "initAgent: acChkHostAccessControl error, status = %d",
                     status );
            return status;
        }
    }

    /* Initialize the global quota */

    GlobalQuotaLimit = RESC_QUOTA_UNINIT;
    GlobalQuotaOverrun = 0;
    RescQuotaPolicy = RESC_QUOTA_UNINIT;

#ifndef windows_platform
    if ( rsComm->reconnFlag == RECONN_TIMEOUT ) {
        rsComm->reconnSock = svrSockOpenForInConn( rsComm, &rsComm->reconnPort,
                             &rsComm->reconnAddr, SOCK_STREAM );
        if ( rsComm->reconnSock < 0 ) {
            rsComm->reconnPort = 0;
            rsComm->reconnAddr = NULL;
        }
        else {
            rsComm->cookie = ( int )( getRandomInt() >> 1 );
        }
        try {
            rsComm->thread_ctx->lock      = new boost::mutex;
            rsComm->thread_ctx->cond      = new boost::condition_variable;
            rsComm->thread_ctx->reconnThr = new boost::thread( reconnManager, rsComm );
        }
        catch ( boost::thread_resource_error& ) {
            rodsLog( LOG_ERROR, "boost encountered thread_resource_error." );
            return SYS_THREAD_RESOURCE_ERR;
        }
    }
Пример #3
0
int
chkAndResetRule (rsComm_t *rsComm)
{
    char *configDir;
    char rulesFileName[MAX_NAME_LEN];
#ifndef USE_BOOST_FS
    struct stat statbuf;
#endif
    int status;
    ruleExecInfo_t rei;
    uint mtime;

    configDir = getConfigDir ();
#ifdef RULE_ENGINE_N
    snprintf (rulesFileName, MAX_NAME_LEN, "%s/reConfigs/core.re",
      configDir);
#else
    snprintf (rulesFileName, MAX_NAME_LEN, "%s/reConfigs/core.irb", 
      configDir); 
#endif
#ifdef USE_BOOST_FS
        path p (rulesFileName);
        if (!exists (p)) {
#else
    status = stat (rulesFileName, &statbuf);

    if (status != 0) {
#endif
	status = UNIX_FILE_STAT_ERR - errno;
        rodsLog (LOG_ERROR,
          "chkAndResetRule: unable to read rule config file %s, status = %d",
	  rulesFileName, status);
	return (status);
    }

#ifdef USE_BOOST_FS
    mtime = (uint) last_write_time (p);
#else
    mtime = (uint) statbuf.st_mtime;
#endif

    if (CoreIrbTimeStamp == 0) {
	/* first time */
	CoreIrbTimeStamp = mtime;
	return (0);
    }

    if (mtime > CoreIrbTimeStamp) {
	/* file has been changed */
        rodsLog (LOG_NOTICE,
          "chkAndResetRule: reconf file %s has been changed. re-initializing",
	  rulesFileName);
	CoreIrbTimeStamp = mtime;
	rei.rsComm = rsComm;
	clearCoreRule();
#ifdef RULE_ENGINE_N
	/* The shared memory cache may have already been updated, do not force reload */
	status = initRuleEngine(RULE_ENGINE_TRY_CACHE, NULL, reRuleStr, reFuncMapStr, reVariableMapStr);
#else
	msiAdmClearAppRuleStruct (&rei);
	status = initRuleEngine(NULL, reRuleStr, reFuncMapStr, reVariableMapStr);
#endif
        if (status < 0) {
            rodsLog (LOG_ERROR,
              "chkAndResetRule: initRuleEngine error, status = %d", status);
        }
    }
    return status;
}