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; }
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; }