void delayClearResources( int resources ) { /*if((resources & RESC_RULE_INDEX) && ruleEngineConfig.ruleIndexStatus == INITIALIZED) { listAppendNoRegion(hashtablesToClear, ruleEngineConfig.ruleIndex); ruleEngineConfig.ruleIndexStatus = UNINITIALIZED; } if((resources & RESC_COND_INDEX) && ruleEngineConfig.condIndexStatus == INITIALIZED) { listAppendNoRegion(hashtableToClear, ruleEngineConfig.condIndex); ruleEngineConfig.condIndexStatus = UNINITIALIZED; }*/ delayClearRegion( APP, app ); delayClearRegion( SYS, sys ); delayClearRegion( CORE, core ); delayClearRegion( EXT, ext ); delayClearRuleSet( APP, app ); delayClearRuleSet( CORE, core ); delayClearRuleSet( EXT, ext ); delayClearFuncDescIndex( APP, app ); delayClearFuncDescIndex( SYS, sys ); delayClearFuncDescIndex( CORE, core ); delayClearFuncDescIndex( EXT, ext ); if ( ( resources & RESC_CACHE ) && ruleEngineConfig.cacheStatus == INITIALIZED ) { listAppendNoRegion( &memoryToFree, ruleEngineConfig.address ); ruleEngineConfig.cacheStatus = UNINITIALIZED; } }
fileCache_t *addFileCache( int iFd, char *objPath, char *localPath, char *cachePath, int mode, rodsLong_t fileSize, cacheState_t state ) { uint cachedTime = time( 0 ); fileCache_t *fileCache, *swapCache; if ( state == NO_FILE_CACHE ) { return newFileCache( iFd, objPath, localPath, cachePath, cachedTime, mode, fileSize, state ); } else { fileCache = newFileCache( iFd, objPath, localPath, cachePath, cachedTime, mode, fileSize, state ); LOCK_STRUCT( *FileCacheList ); if ( _listSize( FileCacheList ) >= NUM_NEWLY_CREATED_SLOT ) { ListNode *node = FileCacheList->list->head; swapCache = ( fileCache_t * ) node->value; listRemoveNoRegion( FileCacheList->list, node ); UNLOCK_STRUCT( *FileCacheList ); ifuseFileCacheSwapOut( swapCache ); LOCK_STRUCT( *FileCacheList ); listAppendNoRegion( FileCacheList->list, fileCache ); } UNLOCK_STRUCT( *FileCacheList ); return fileCache; } }
void connManager() { time_t curTime; iFuseConn_t *tmpIFuseConn; ListNode *node; List *TimeOutList = newListNoRegion(); while ( 1 ) { curTime = time( NULL ); /* exceed high water mark for number of connection ? */ if ( listSize( ConnectedConn ) > HIGH_NUM_CONN ) { LOCK_STRUCT( *ConnectedConn ); int disconnTarget = _listSize( ConnectedConn ) - HIGH_NUM_CONN; node = ConnectedConn->list->head; while ( node != NULL ) { tmpIFuseConn = ( iFuseConn_t * ) node->value; if ( tmpIFuseConn->inuseCnt == 0 && tmpIFuseConn->pendingCnt == 0 && curTime - tmpIFuseConn->actTime > IFUSE_CONN_TIMEOUT ) { listAppendNoRegion( TimeOutList, tmpIFuseConn ); } node = node->next; } UNLOCK_STRUCT( *ConnectedConn ); node = TimeOutList->head; int disconned = 0; while ( node != NULL && disconned < disconnTarget ) { tmpIFuseConn = ( iFuseConn_t * ) node->value; LOCK_STRUCT( *tmpIFuseConn ); if ( tmpIFuseConn->inuseCnt == 0 && tmpIFuseConn->pendingCnt == 0 && curTime - tmpIFuseConn->actTime > IFUSE_CONN_TIMEOUT ) { removeFromConcurrentList2( FreeConn, tmpIFuseConn ); removeFromConcurrentList2( ConnectedConn, tmpIFuseConn ); if ( tmpIFuseConn->status == 0 ) { /* no struct is referring to it, we can unlock it and free it */ UNLOCK_STRUCT( *tmpIFuseConn ); /* rodsLog(LOG_ERROR, "[FREE IFUSE CONN] %s:%d %p", __FILE__, __LINE__, tmpIFuseConn); */ _freeIFuseConn( tmpIFuseConn ); } else { /* set to timed out */ _ifuseDisconnect( tmpIFuseConn ); UNLOCK_STRUCT( *tmpIFuseConn ); } disconned ++; } else { UNLOCK_STRUCT( *tmpIFuseConn ); } node = node->next; } clearListNoRegion( TimeOutList ); } notifyWait( &connReqWait.mutex, &connReqWait.cond ); timeoutWait( &ConnManagerLock, &ConnManagerCond, CONN_MANAGER_SLEEP_TIME ); } deleteListNoRegion( TimeOutList ); }
/*#define FUSE_DEBUG 0*/ void addToConcurrentList(concurrentList_t *l, void *v) { LOCK_STRUCT(*l); listAppendNoRegion(l->list, v); UNLOCK_STRUCT(*l); }
void connManager() { time_t curTime; iFuseConn_t *tmpIFuseConn; ListNode *node; List *TimeOutList = newListNoRegion(); while ( 1 ) { curTime = time( NULL ); /* exceed high water mark for number of connection ? */ if ( listSize( ConnectedConn ) > HIGH_NUM_CONN ) { LOCK_STRUCT( *ConnectedConn ); int disconnTarget = _listSize( ConnectedConn ) - HIGH_NUM_CONN; node = ConnectedConn->list->head; while ( node != NULL ) { tmpIFuseConn = ( iFuseConn_t * ) node->value; if ( tmpIFuseConn->inuseCnt == 0 && tmpIFuseConn->pendingCnt == 0 && curTime - tmpIFuseConn->actTime > IFUSE_CONN_TIMEOUT ) { listAppendNoRegion( TimeOutList, tmpIFuseConn ); } node = node->next; } UNLOCK_STRUCT( *ConnectedConn ); node = TimeOutList->head; int disconned = 0; while ( node != NULL && disconned < disconnTarget ) { tmpIFuseConn = ( iFuseConn_t * ) node->value; LOCK_STRUCT( *tmpIFuseConn ); if ( tmpIFuseConn->inuseCnt == 0 && tmpIFuseConn->pendingCnt == 0 && curTime - tmpIFuseConn->actTime > IFUSE_CONN_TIMEOUT ) { removeFromConcurrentList2( FreeConn, tmpIFuseConn ); removeFromConcurrentList2( ConnectedConn, tmpIFuseConn ); if ( tmpIFuseConn->status == 0 ) { /* no struct is referring to it, we can unlock it and free it */ UNLOCK_STRUCT( *tmpIFuseConn ); /* rodsLog(LOG_ERROR, "[FREE IFUSE CONN] %s:%d %p", __FILE__, __LINE__, tmpIFuseConn); */ _freeIFuseConn( tmpIFuseConn ); } else { /* set to timed out */ _ifuseDisconnect( tmpIFuseConn ); UNLOCK_STRUCT( *tmpIFuseConn ); } disconned ++; } else { UNLOCK_STRUCT( *tmpIFuseConn ); } node = node->next; } clearListNoRegion( TimeOutList ); } while ( listSize( ConnectedConn ) <= MAX_NUM_CONN || listSize( FreeConn ) != 0 ) { /* signal one in the wait queue */ connReqWait_t *myConnReqWait = ( connReqWait_t * ) removeFirstElementOfConcurrentList( ConnReqWaitQue ); /* if there is no conn req left, exit loop */ if ( myConnReqWait == NULL ) { break; } myConnReqWait->state = 1; notifyTimeoutWait( &myConnReqWait->mutex, &myConnReqWait->cond ); } #if 0 rodsSleep( CONN_MANAGER_SLEEP_TIME, 0 ); #else timeoutWait( &ConnManagerLock, &ConnManagerCond, CONN_MANAGER_SLEEP_TIME ); #endif } deleteListNoRegion( TimeOutList ); }