[mythtv] Mythfrontend hang with CVS

Leo Weppelman leo at wau.mis.ah.nl
Wed Jun 9 17:45:12 EDT 2004


On Wed, Jun 09, 2004 at 04:01:09PM -0500, Stacey Son wrote:
> Leo Weppelman wrote:
> 
> >>Thx but I have modify my patch too. Apply a patch on mediamonitor cvs 
> >>which is broken, have no sense.
> >>I should have prefer that you find what is wrong in the current cvs ;-)

OK, I left your stuff out except the remove of the close in
MythMediaDevice::unlock(). This close killed the media-change sensing.

> >Shall I combine the getfsent() nesting patch from Stacey, the patches
> >from Xavier - modified by Stacey and the stack-overflow fix by me into
> >one patch and post it? This in an effort not to do it all twice or trice?
> >
> Leo,  I am wondering if the check you added in MythCDROMLinux::unlock() 
> is necessary any more given Xavier's patches: Note that closeDevice() is 
> no longer called in MediaDevice::unlock().

Yes, the check is still needed because the endless recursion is still
there.

Attached is the combined patch that brings the mediamonitor functionality
back to the point before it broke by the ioctl-lock en FreeBSD patches.

Please have a look so we can submit it.

Leo.
-------------- next part --------------
Index: mythcdrom-freebsd.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythtv/libs/libmyth/mythcdrom-freebsd.cpp,v
retrieving revision 1.3
diff -u -r1.3 mythcdrom-freebsd.cpp
--- mythcdrom-freebsd.cpp	4 Jun 2004 04:27:08 -0000	1.3
+++ mythcdrom-freebsd.cpp	9 Jun 2004 21:34:23 -0000
@@ -74,7 +74,7 @@
 
 MediaError MythCDROMFreeBSD::unlock() 
 {
-    if (openDevice()) 
+    if (isDeviceOpen() || openDevice()) 
     { 
         // The call to the base unlock will close it if needed.
         VERBOSE( VB_ALL, "Unlocking CDROM door");
Index: mythcdrom-linux.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythtv/libs/libmyth/mythcdrom-linux.cpp,v
retrieving revision 1.1
diff -u -r1.1 mythcdrom-linux.cpp
--- mythcdrom-linux.cpp	4 Jun 2004 02:31:22 -0000	1.1
+++ mythcdrom-linux.cpp	9 Jun 2004 21:34:23 -0000
@@ -195,7 +195,7 @@
 
 MediaError MythCDROMLinux::unlock() 
 {
-    if (openDevice()) 
+    if (isDeviceOpen() || openDevice()) 
     { 
         // The call to the base unlock will close it if needed.
         VERBOSE( VB_ALL, "Unlocking CDROM door");
Index: mythmedia.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythtv/libs/libmyth/mythmedia.cpp,v
retrieving revision 1.5
diff -u -r1.5 mythmedia.cpp
--- mythmedia.cpp	24 Feb 2004 07:31:08 -0000	1.5
+++ mythmedia.cpp	9 Jun 2004 21:34:23 -0000
@@ -127,14 +127,11 @@
     return MEDIAERR_FAILED;
 }
 
-MediaError MythMediaDevice::unlock() 
+MediaError MythMediaDevice::unlock()
 { 
     m_Locked = false;
     
-    if (closeDevice())
-        return MEDIAERR_OK;
-    
-    return MEDIAERR_FAILED;
+    return MEDIAERR_OK;
 }
 
 bool MythMediaDevice::isMounted(bool Verify)
Index: mythmediamonitor.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythtv/libs/libmyth/mythmediamonitor.cpp,v
retrieving revision 1.5
diff -u -r1.5 mythmediamonitor.cpp
--- mythmediamonitor.cpp	4 Jun 2004 21:21:05 -0000	1.5
+++ mythmediamonitor.cpp	9 Jun 2004 21:34:24 -0000
@@ -82,7 +82,7 @@
     {
         perror("setfsent");
         cerr << "MediaMonitor::addFSTab - Failed to open "
-		_PATH_FSTAB
+                _PATH_FSTAB
                 " for reading." << endl;
         return false;
     }
@@ -90,7 +90,7 @@
     {
         // Add all the entries
         while ((mep = getfsent()) != NULL)
-            addDevice(mep->fs_spec);
+            (void) addDevice(mep);
         
         endfsent();
     }
@@ -109,6 +109,94 @@
     m_Devices.push_back( pDevice );
 }
 
+// Given a fstab entry to a media device determine what type of device it is 
+bool MediaMonitor::addDevice(struct fstab * mep) 
+{
+    QString devicePath( mep->fs_spec );
+    //cout << "addDevice - " << devicePath << endl;
+
+    MythMediaDevice* pDevice = NULL;
+    struct stat sbuf;
+
+    bool is_supermount = false;
+    bool is_cdrom = false;
+
+    if (mep == NULL)
+       return false;
+
+    if (stat(mep->fs_spec, &sbuf) < 0)
+       return false;   
+
+    //  Can it be mounted?  
+    if ( ! ( ((strstr(mep->fs_mntops, "owner") && 
+        (sbuf.st_mode & S_IRUSR)) || strstr(mep->fs_mntops, "user")) && 
+        (strstr(mep->fs_vfstype, MNTTYPE_ISO9660) || 
+         strstr(mep->fs_vfstype, MNTTYPE_UDF) || 
+         strstr(mep->fs_vfstype, MNTTYPE_AUTO)) ) ) 
+    {
+       if ( strstr(mep->fs_mntops, MNTTYPE_ISO9660) && 
+            strstr(mep->fs_vfstype, MNTTYPE_SUPERMOUNT) ) 
+          {
+             is_supermount = true;
+          }
+          else
+          {
+             return false;
+          }
+     }
+
+     if (strstr(mep->fs_mntops, MNTTYPE_ISO9660) || 
+         strstr(mep->fs_vfstype, MNTTYPE_ISO9660)) 
+     {
+         is_cdrom = true;
+         //cout << "Device is a CDROM" << endl;
+     }
+
+     if (!is_supermount) 
+     {
+         if (is_cdrom)
+             pDevice = MythCDROM::get(this, QString(mep->fs_spec),
+                                     is_supermount, m_AllowEject);
+     }
+     else 
+     {
+         char *dev;
+         int len = 0;
+         dev = strstr(mep->fs_mntops, SUPER_OPT_DEV);
+         dev += sizeof(SUPER_OPT_DEV)-1;
+         while (dev[len] != ',' && dev[len] != ' ' && dev[len] != 0)
+             len++;
+
+         if (dev[len] != 0) 
+         {
+             char devstr[256];
+             strncpy(devstr, dev, len);
+             devstr[len] = 0;
+             if (is_cdrom)
+                 MythCDROM::get(this, QString(devstr),
+                                is_supermount, m_AllowEject);
+         }
+         else
+             return false;   
+     }
+        
+     if (pDevice) 
+     {
+         pDevice->setMountPath(mep->fs_file);
+         VERBOSE(VB_ALL, QString("Mediamonitor: Adding %1")
+                         .arg(pDevice->getDevicePath()));
+         if (pDevice->testMedia() == MEDIAERR_OK) 
+         {
+             addDevice(pDevice);
+             return true;
+         }
+            else
+                delete pDevice;
+      }
+
+     return false;
+}
+
 // Given a path to a media device determine what type of device it is and 
 // add it to our collection.
 bool MediaMonitor::addDevice(const char* devPath ) 
@@ -116,13 +204,8 @@
     QString devicePath( devPath );
     //cout << "addDevice - " << devicePath << endl;
 
-    MythMediaDevice* pDevice = NULL;
-
     struct fstab * mep = NULL;
     char lpath[PATH_MAX];
-    struct stat sbuf;
-    bool is_supermount = false;
-    bool is_cdrom = false;
 
     // Resolve the simlink for the device.
     int len = readlink(devicePath, lpath, PATH_MAX);
@@ -134,7 +217,7 @@
     {
         perror("setfsent");
         cerr << "MediaMonitor::addDevice - Failed to open "
-		_PATH_FSTAB
+                _PATH_FSTAB
                 " for reading." << endl;
         return false;
     }
@@ -157,79 +240,13 @@
                  (len && (strcmp(lpath, mep->fs_spec) != 0)))
                 continue;
 
-            stat(mep->fs_spec, &sbuf);
-
-            if (((strstr(mep->fs_mntops, "owner") && 
-                (sbuf.st_mode & S_IRUSR)) || strstr(mep->fs_mntops, "user")) && 
-                (strstr(mep->fs_vfstype, MNTTYPE_ISO9660) || 
-                 strstr(mep->fs_vfstype, MNTTYPE_UDF) || 
-                 strstr(mep->fs_vfstype, MNTTYPE_AUTO))) 
-            {
-                break;        
-            }
-
-            if (strstr(mep->fs_mntops, MNTTYPE_ISO9660) && 
-                strstr(mep->fs_vfstype, MNTTYPE_SUPERMOUNT)) 
-            {
-                is_supermount = true;
-                break;
-            }
         }
 
         endfsent();
     }
 
     if (mep) 
-    {
-        if (strstr(mep->fs_mntops, MNTTYPE_ISO9660) || 
-            strstr(mep->fs_vfstype, MNTTYPE_ISO9660)) 
-        {
-            is_cdrom = true;
-            //cout << "Device is a CDROM" << endl;
-        }
-
-        if (!is_supermount) 
-        {
-            if (is_cdrom)
-                pDevice = MythCDROM::get(this, QString(mep->fs_spec),
-                                         is_supermount, m_AllowEject);
-        }
-        else 
-        {
-            char *dev;
-            int len = 0;
-            dev = strstr(mep->fs_mntops, SUPER_OPT_DEV);
-            dev += sizeof(SUPER_OPT_DEV)-1;
-            while (dev[len] != ',' && dev[len] != ' ' && dev[len] != 0)
-                len++;
-
-            if (dev[len] != 0) 
-            {
-                char devstr[256];
-                strncpy(devstr, dev, len);
-                devstr[len] = 0;
-                if (is_cdrom)
-                    MythCDROM::get(this, QString(devstr),
-                                   is_supermount, m_AllowEject);
-            }
-            else
-                return false;   
-        }
-        
-        if (pDevice) 
-        {
-            pDevice->setMountPath(mep->fs_file);
-            VERBOSE(VB_ALL, QString("Mediamonitor: Adding %1")
-                            .arg(pDevice->getDevicePath()));
-            if (pDevice->testMedia() == MEDIAERR_OK) 
-            {
-                addDevice(pDevice);
-                return true;
-            }
-            else
-                delete pDevice;
-        }
-    }
+       return addDevice(mep); 
 
     return false;
 }
Index: mythmediamonitor.h
===================================================================
RCS file: /var/lib/mythcvs/mythtv/libs/libmyth/mythmediamonitor.h,v
retrieving revision 1.2
diff -u -r1.2 mythmediamonitor.h
--- mythmediamonitor.h	4 Jun 2004 02:31:22 -0000	1.2
+++ mythmediamonitor.h	9 Jun 2004 21:34:24 -0000
@@ -5,6 +5,7 @@
 #include <qvaluelist.h>
 #include <qguardedptr.h>
 #include <qthread.h>
+#include <fstab.h>
 
 const int kMediaEventType = 30042;
 
@@ -48,6 +49,7 @@
     bool addFSTab(void);
     void addDevice(MythMediaDevice* pDevice);
     bool addDevice(const char* dev);
+    bool addDevice(struct fstab* mep);
 
     bool isActive(void) const { return m_Active; }
     void checkDevices(void);


More information about the mythtv-dev mailing list