diff --git a/tapeserver/castor/tape/tapeserver/daemon/TapeReadSingleThread.cpp b/tapeserver/castor/tape/tapeserver/daemon/TapeReadSingleThread.cpp index 01a56e877b585af2f9be98f64a5d2ee72ec8c537..abe1924951cb2860818cb0c8e5bd737248f01426 100644 --- a/tapeserver/castor/tape/tapeserver/daemon/TapeReadSingleThread.cpp +++ b/tapeserver/castor/tape/tapeserver/daemon/TapeReadSingleThread.cpp @@ -67,10 +67,15 @@ castor::tape::tapeserver::daemon::TapeReadSingleThread::TapeCleaning::~TapeClean // First check that a tape is actually present in the drive. We can get here // after failing to mount (library error) in which case there is nothing to // do (and trying to unmount will only lead to a failure.) + // We give time to the drive for settling after a mount which might have + // just happened. If we time out, then we will simply find no tape in the + // drive, which is a fine situation (so timeout exceptions are discarded). + // Other exception, where we failed to access the drive somehow are at passed + // through. const uint32_t waitMediaInDriveTimeout = 60; try { m_this.m_drive.waitUntilReady(waitMediaInDriveTimeout); - } catch (cta::exception::Exception &) {} + } catch (cta::exception::TimeOut &) {} if (!m_this.m_drive.hasTapeInPlace()) { m_this.m_logContext.log(cta::log::INFO, "TapeReadSingleThread: No tape to unload"); goto done; diff --git a/tapeserver/castor/tape/tapeserver/daemon/TapeWriteSingleThread.hpp b/tapeserver/castor/tape/tapeserver/daemon/TapeWriteSingleThread.hpp index 380f62f389446c915b91f322cca9bbb0aa5e6eb8..b44e5907ffbf5b88c17a2f5e8ec828773c6a0285 100644 --- a/tapeserver/castor/tape/tapeserver/daemon/TapeWriteSingleThread.hpp +++ b/tapeserver/castor/tape/tapeserver/daemon/TapeWriteSingleThread.hpp @@ -120,7 +120,7 @@ private: const uint32_t waitMediaInDriveTimeout = 60; try { m_this.m_drive.waitUntilReady(waitMediaInDriveTimeout); - } catch (cta::exception::Exception &) {} + } catch (cta::exception::TimeOut &) {} if (!m_this.m_drive.hasTapeInPlace()) { m_this.m_logContext.log(cta::log::INFO, "TapeReadSingleThread: No tape to unload"); goto done; diff --git a/tapeserver/castor/tape/tapeserver/drive/DriveGeneric.cpp b/tapeserver/castor/tape/tapeserver/drive/DriveGeneric.cpp index df2197a5592cd0fdce14eb3eac96f3b2581a7a4f..2268b51e6352abb1e69a1d9d3e3bab4514059269 100644 --- a/tapeserver/castor/tape/tapeserver/drive/DriveGeneric.cpp +++ b/tapeserver/castor/tape/tapeserver/drive/DriveGeneric.cpp @@ -1178,7 +1178,7 @@ void drive::DriveGeneric::waitUntilReady(const uint32_t timeoutSecond) { std::string("Could not read drive status: ") + m_SCSIInfo.nst_dev); if(GMT_ONLINE(mtInfo.mt_gstat)==0) { - cta::exception::Exception ex; + cta::exception::TimeOut ex; ex.getMessage() << "Tape drive empty after waiting " << timeoutSecond << " seconds."; throw ex; diff --git a/tapeserver/castor/tape/tapeserver/drive/DriveGeneric.hpp b/tapeserver/castor/tape/tapeserver/drive/DriveGeneric.hpp index 656b2f135c82adfe10581c744762014547ba133d..ff887739203b4a0f8323dab98cf0dd7ff43ec07d 100644 --- a/tapeserver/castor/tape/tapeserver/drive/DriveGeneric.hpp +++ b/tapeserver/castor/tape/tapeserver/drive/DriveGeneric.hpp @@ -154,6 +154,8 @@ namespace drive { * at least timeoutSeconds or any errors occurred. We consider any not GOOD * SCSI replay with sense keys not equals to NotReady or UnitAttention as * errors. + * This method will pass through any exception encountered, and will throw + * a TimeOut exception if not tape is found after timeout. * * This method will at least query the tape drive once. * diff --git a/tapeserver/castor/tape/tapeserver/drive/DriveInterface.hpp b/tapeserver/castor/tape/tapeserver/drive/DriveInterface.hpp index cfd81c215c5285b18c83f48ab3dc817dbab935e9..b24b7421889689817913238a9e1f960dde9d1a27 100644 --- a/tapeserver/castor/tape/tapeserver/drive/DriveInterface.hpp +++ b/tapeserver/castor/tape/tapeserver/drive/DriveInterface.hpp @@ -31,6 +31,7 @@ #include "tapeserver/castor/tape/tapeserver/SCSI/Structures.hpp" #include "tapeserver/castor/tape/tapeserver/system/Wrapper.hpp" #include "common/exception/Exception.hpp" +#include "common/exception/TimeOut.hpp" /** * Class wrapping the tape server. Has to be templated (and hence fully in .hh)