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);
}
// ---------------------------------------------------------------
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);
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)
{
{
try
{
+ DBG << "Forcing release of handler depending on access id "
+ << accessId << std::endl;
m->second.handler->release(!eject);
m->second.desired = false;
}
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