Add variable timeouts.

After mounting or unmounting a filesystem, flush cache, so we don't keep
stale cache around.

RageFileDriverDirect::Remount could (and should) flush its own cache when
changing root (since the cache represents the old root).  However, calling
Remount doesn't indicate that the filesystem has actually changed, so if
the root isn't actually changing (Remount("/mnt") on a filesystem already
pointing to /mnt), the driver can't be expected to flush.  (Remount also
currently doesn't go through Timeout, and we need to flush on unmount,
too.)  So, take the cheap way out and just flush through FILEMAN.
This commit is contained in:
Glenn Maynard
2005-05-22 01:36:08 +00:00
parent b850a8ea50
commit 4c8c5bea37
2 changed files with 17 additions and 8 deletions
+15 -6
View File
@@ -568,7 +568,7 @@ void MemoryCardManager::UnlockCards()
}
/* Called just before reading or writing to the memory card. Should block. */
void MemoryCardManager::MountCard( PlayerNumber pn )
void MemoryCardManager::MountCard( PlayerNumber pn, int iTimeout )
{
LOG->Trace( "MemoryCardManager::MountCard(%i)", pn );
if( GetCardState(pn) != MEMORY_CARD_STATE_READY )
@@ -583,7 +583,7 @@ void MemoryCardManager::MountCard( PlayerNumber pn )
if( bStartingMemoryCardAccess )
{
/* We're starting to do stuff to the memory cards. */
this->PauseMountingThread();
this->PauseMountingThread( iTimeout );
}
if( !g_pWorker->Mount( &m_Device[pn] ) )
@@ -609,13 +609,18 @@ void MemoryCardManager::MountCard( PlayerNumber pn )
/* We just created a worker thread. Reset the timeout, or those threads
* won't time out. This is a hack; we should really be creating the timeout
* driver on startup. */
this->PauseMountingThread();
this->PauseMountingThread( iTimeout );
}
else
{
/* It's already mounted. We don't want to unmount the timeout FS. Instead, just
* move the target. */
pDriver->Remount( m_Device[pn].sOsMountDir );
/* Flush mountpoints pointing to what we've mounted. */
FILEMAN->FlushDirCache( MEM_CARD_MOUNT_POINT[pn] );
FILEMAN->FlushDirCache( MEM_CARD_MOUNT_POINT_INTERNAL[pn] );
FILEMAN->ReleaseFileDriver( pDriver );
}
}
@@ -634,6 +639,10 @@ void MemoryCardManager::UnmountCard( PlayerNumber pn )
/* Leave our own filesystem drivers mounted. Unmount the kernel mount. */
g_pWorker->Unmount( &m_Device[pn] );
/* Flush mountpoints pointing to what we've unmounted. */
FILEMAN->FlushDirCache( MEM_CARD_MOUNT_POINT[pn] );
FILEMAN->FlushDirCache( MEM_CARD_MOUNT_POINT_INTERNAL[pn] );
m_bMounted[pn] = false;
/* Unpause the mounting thread when we unmount the last drive. */
@@ -684,13 +693,13 @@ CString MemoryCardManager::GetName( PlayerNumber pn ) const
return m_Device[pn].sName;
}
void MemoryCardManager::PauseMountingThread()
void MemoryCardManager::PauseMountingThread( int iTimeout )
{
g_pWorker->SetMountThreadState( ThreadedMemoryCardWorker::paused );
/* Start the timeout period. */
g_pWorker->SetTimeout( 10 );
RageFileDriverTimeout::SetTimeout( 10 );
g_pWorker->SetTimeout( iTimeout );
RageFileDriverTimeout::SetTimeout( iTimeout );
}
void MemoryCardManager::UnPauseMountingThread()