diff --git a/stepmania/src/arch/MemoryCard/MemoryCardDriverThreaded_Linux.cpp b/stepmania/src/arch/MemoryCard/MemoryCardDriverThreaded_Linux.cpp index 9fe5c49557..2945c799dc 100644 --- a/stepmania/src/arch/MemoryCard/MemoryCardDriverThreaded_Linux.cpp +++ b/stepmania/src/arch/MemoryCard/MemoryCardDriverThreaded_Linux.cpp @@ -133,23 +133,32 @@ void MemoryCardDriverThreaded_Linux::MountThreadMain() LOG->Warn( "Failed to open \"%s\": %s", USB_DEVICE_LIST_FILE, strerror(errno) ); return; } - + vector vDevicesLastSeen; while( !m_bShutdown ) { - pollfd pfd = { fd, POLLIN, 0 }; - int ret = poll( &pfd, 1, 100 ); - switch( ret ) + if( m_bReset ) { - case 1: - // file changed. Fall through. - break; - case 0: // no change. Poll again. - continue; - case -1: - LOG->Warn( "Error polling" ); - continue; + // force all to be re-detected + vDevicesLastSeen.clear(); + m_bReset = false; + } + else + { + pollfd pfd = { fd, POLLIN, 0 }; + int ret = poll( &pfd, 1, 100 ); + switch( ret ) + { + case 1: + // file changed. Fall through. + break; + case 0: // no change. Poll again. + continue; + case -1: + LOG->Warn( "Error polling" ); + continue; + } } // TRICKY: We're waiting for a change in the USB device list, but @@ -245,6 +254,7 @@ void MemoryCardDriverThreaded_Linux::MountThreadMain() MemoryCardDriverThreaded_Linux::MemoryCardDriverThreaded_Linux() { + m_bReset = false; this->StartThread(); } @@ -650,6 +660,8 @@ void MemoryCardDriverThreaded_Linux::ResetUsbStorage() ExecuteCommand( "rmmod usb-storage" ); ExecuteCommand( "modprobe usb-storage" ); + m_bReset = true; + // let the mounting thread re-mount everything } diff --git a/stepmania/src/arch/MemoryCard/MemoryCardDriverThreaded_Linux.h b/stepmania/src/arch/MemoryCard/MemoryCardDriverThreaded_Linux.h index d7344b4368..1fe23ff709 100644 --- a/stepmania/src/arch/MemoryCard/MemoryCardDriverThreaded_Linux.h +++ b/stepmania/src/arch/MemoryCard/MemoryCardDriverThreaded_Linux.h @@ -14,6 +14,8 @@ public: protected: virtual void MountThreadMain(); virtual void Mount( UsbStorageDevice* pDevice, CString sMountPoint ); + + bool m_bReset; }; #endif