From 1193d2468e7bb110c146aace9c6b24e7d7ac6184 Mon Sep 17 00:00:00 2001 From: Gavin Hurlbut Date: Sun, 1 Jan 2012 17:37:17 -0800 Subject: [PATCH] Do not keep trying to mount when it fails Refs #10221 If a USB stick (or other removable drive) is attached to the frontend, and the user running the frontend is not able to mount it with "mount /dev/sdc1" or the like, we do not want to keep trying (twice a second!) to mount it. There's no purpose to that other than extra load, and filling log files with useless crap. --- mythtv/libs/libmythbase/mythhdd.cpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/mythtv/libs/libmythbase/mythhdd.cpp b/mythtv/libs/libmythbase/mythhdd.cpp index 285ab49e53f..4d8630f9a78 100644 --- a/mythtv/libs/libmythbase/mythhdd.cpp +++ b/mythtv/libs/libmythbase/mythhdd.cpp @@ -33,6 +33,9 @@ MythHDD::MythHDD(QObject *par, const char *DevicePath, */ MythMediaStatus MythHDD::checkMedia(void) { + if (m_Status == MEDIASTAT_ERROR) + return m_Status; + if (isMounted()) { // A lazy way to present volume name for the user to eject. @@ -40,8 +43,9 @@ MythMediaStatus MythHDD::checkMedia(void) m_VolumeID = m_MountPath; // device is mounted, trigger event - if (MEDIASTAT_MOUNTED != m_Status) + if (m_Status != MEDIASTAT_MOUNTED) m_Status = MEDIASTAT_NOTMOUNTED; + return setStatus(MEDIASTAT_MOUNTED); } @@ -51,15 +55,16 @@ MythMediaStatus MythHDD::checkMedia(void) case MEDIASTAT_NOTMOUNTED: // a removable device was just plugged in try to mount it. LOG(VB_MEDIA, LOG_INFO, "MythHDD::checkMedia try mounting " + m_DevicePath); + if (mount()) - { - m_Status = MEDIASTAT_NOTMOUNTED; return setStatus(MEDIASTAT_MOUNTED); - } - return m_Status; + + return setStatus(MEDIASTAT_ERROR); + case MEDIASTAT_MOUNTED: // device was mounted and someone unmounted it. - return m_Status = setStatus(MEDIASTAT_NOTMOUNTED); + return setStatus(MEDIASTAT_NOTMOUNTED); + default: // leave device state as is return m_Status;