- Removed deprecated reattach() method
authorMarius Tomaschewski <mt@suse.de>
Mon, 13 Mar 2006 16:21:53 +0000 (16:21 +0000)
committerMarius Tomaschewski <mt@suse.de>
Mon, 13 Mar 2006 16:21:53 +0000 (16:21 +0000)
- Added a paranoia check to close() ...

zypp/media/MediaManager.cc
zypp/media/MediaManager.h

index 33067c8..7dbe91f 100644 (file)
@@ -237,6 +237,32 @@ namespace zypp
 
       ManagedMedia &ref( m_impl->findMM(accessId));
 
+      //
+      // The MediaISO handler internally requests an accessId
+      // of a "parent" handler providing the iso file.
+      // The parent handler accessId is private to MediaISO,
+      // but the attached media source may be shared reference.
+      // This means, that if the accessId belongs to a handler
+      // that is _not_ shared, close was used on uninitialized
+      // accessId variable (or the accessId was guessed).
+      //
+      ManagedMediaMap::iterator m(m_impl->mediaMap.begin());
+      for( ; m != m_impl->mediaMap.end(); ++m)
+      {
+        if( m->second.handler->dependsOnParent(accessId))
+        {
+          if( !ref.handler->isSharedMedia())
+          {
+            ERR << "close attempt on a private id detected "
+                << "-- uninitialized access id variable?!"
+                << std::endl;
+            ZYPP_THROW(MediaIsSharedException(
+              m->second.handler->url().asString()
+            ));
+          }
+        }
+      }
+
       ref.handler->close();
       m_impl->mediaMap.erase(accessId);
     }
@@ -344,31 +370,6 @@ namespace zypp
 
     // ---------------------------------------------------------------
     void
-    MediaManager::reattach(MediaAccessId   accessId,
-                           const Pathname &attach_point,
-                           bool            temporary)
-    {
-      MutexLock glock(g_Mutex);
-
-      ManagedMedia &ref( m_impl->findMM(accessId));
-
-      ManagedMediaMap::iterator m(m_impl->mediaMap.begin());
-      for( ; m != m_impl->mediaMap.end(); ++m)
-      {
-        // don't allow a reattach if it is the
-        // source for an loop mounted ISO file
-        if( m->second.handler->dependsOnParent(accessId))
-        {
-          ZYPP_THROW(MediaIsSharedException(
-            m->second.handler->url().asString()
-          ));
-        }
-      }
-      return ref.handler->reattach(attach_point, temporary);
-    }
-
-    // ---------------------------------------------------------------
-    void
     MediaManager::release(MediaAccessId accessId, bool eject)
     {
       MutexLock glock(g_Mutex);
@@ -377,6 +378,11 @@ namespace zypp
 
       if( eject)
       {
+        //
+        // release MediaISO handlers, that are using the one
+        // specified with accessId, because it provides the
+        // iso file and it will disappear now (forced release).
+        //
         ManagedMediaMap::iterator m(m_impl->mediaMap.begin());
         for( ; m != m_impl->mediaMap.end(); ++m)
         {
@@ -384,6 +390,8 @@ namespace zypp
           {
             try
             {
+              DBG << "Forcing release of handler depending on access id "
+                  << accessId << std::endl;
               m->second.handler->release(!eject);
               m->second.desired  = false;
             }
index d78afb0..874c6f6 100644 (file)
@@ -479,30 +479,6 @@ namespace zypp
       attach(MediaAccessId accessId, bool next = false);
 
       /**
-       * Reattach to a new attach point.
-       *
-       * \deprecated This function will be removed, because the
-       * reattach function has race conditions (e.g. open file
-       * in the old attach point). Use setAttachPrefix() instead.
-       *
-       * \param accessId A media access Id.
-       * \param attach_point A new attach point directory.
-       * \param temporary    Whether to reattach to a temporary
-       *      attach point bellow of \p attach_point and cleanup
-       *      it on release (temporary=true), or use the provided
-       *      directory as attach point without to cleanup it on
-       *      release (temporary=false, default behaviour).
-       * \throws MediaNotOpenException
-       * \throws MediaNotSupportedException
-       */
-      private:
-      void
-      reattach(MediaAccessId   accessId,
-               const Pathname &attach_point,
-               bool            temporary = false) ZYPP_DEPRECATED;
-      public:
-
-      /**
        * Release the attached media and optionally eject.
        *
        * If the \p eject parameter is set to true and there