From 2551f51f60cb4846a1578e5b5d7ff279ccdf011e Mon Sep 17 00:00:00 2001
From: Cristina Moraru <cristina-gabriela.moraru@cern.ch>
Date: Fri, 9 Jun 2017 17:28:58 +0200
Subject: [PATCH] Fix promise usage

Signed-off-by: Cristina Moraru <cristina-gabriela.moraru@cern.ch>
---
 .../castor/tape/tapeserver/daemon/RecallTaskInjector.cpp   | 5 -----
 .../castor/tape/tapeserver/daemon/TapeReadSingleThread.cpp | 7 -------
 .../castor/tape/tapeserver/daemon/TapeReadSingleThread.hpp | 1 -
 3 files changed, 13 deletions(-)

diff --git a/tapeserver/castor/tape/tapeserver/daemon/RecallTaskInjector.cpp b/tapeserver/castor/tape/tapeserver/daemon/RecallTaskInjector.cpp
index f2731602ef..92496871b1 100644
--- a/tapeserver/castor/tape/tapeserver/daemon/RecallTaskInjector.cpp
+++ b/tapeserver/castor/tape/tapeserver/daemon/RecallTaskInjector.cpp
@@ -62,11 +62,6 @@ RecallTaskInjector::~RecallTaskInjector(){
 void RecallTaskInjector::finish(){
   cta::threading::MutexLocker ml(m_producerProtection);
   m_queue.push(Request());
-  /* Since this is the ending request, the RecallTaskInjector does not need
-   * to wait to have access to the drive
-   */
-  if (m_useRAO)
-    setPromise();
 }
 //------------------------------------------------------------------------------
 //requestInjection
diff --git a/tapeserver/castor/tape/tapeserver/daemon/TapeReadSingleThread.cpp b/tapeserver/castor/tape/tapeserver/daemon/TapeReadSingleThread.cpp
index a523f64500..f17a567ef1 100644
--- a/tapeserver/castor/tape/tapeserver/daemon/TapeReadSingleThread.cpp
+++ b/tapeserver/castor/tape/tapeserver/daemon/TapeReadSingleThread.cpp
@@ -156,12 +156,10 @@ castor::tape::tapeserver::daemon::TapeReadSingleThread::popAndRequestMoreJobs(){
     vrp = m_tasks.popGetSize();
   // If we just passed (down) the half full limit, ask for more
   // (the remaining value is after pop)
-  isLastTask = false;
   if(0 == vrp.remaining) {
     // This is a last call: if the task injector comes up empty on this
     // one, he'll call it the end.
     m_taskInjector->requestInjection(true);
-    isLastTask = true;
   } else if (vrp.remaining + 1 == m_maxFilesRequest/2) {
     // This is not a last call
     m_taskInjector->requestInjection(false);
@@ -322,11 +320,6 @@ void castor::tape::tapeserver::daemon::TapeReadSingleThread::run() {
         // This can lead the the session being marked as corrupt, so we test
         // it in the while loop
         task->execute(*rs, m_logContext, m_watchdog,m_stats,timer);
-        if (m_useRAO && isLastTask) {
-          // After the execution of all recalls, the TapeReadSingleThread
-          // passes the access to the drive to the RecallTaskInjector
-          m_taskInjector->setPromise();
-        }
         // Transmit the statistics to the watchdog thread
         m_watchdog.updateStatsWithoutDeliveryTime(m_stats);
         // The session could have been corrupted (failed positioning)
diff --git a/tapeserver/castor/tape/tapeserver/daemon/TapeReadSingleThread.hpp b/tapeserver/castor/tape/tapeserver/daemon/TapeReadSingleThread.hpp
index f9675711ec..f686faa39c 100644
--- a/tapeserver/castor/tape/tapeserver/daemon/TapeReadSingleThread.hpp
+++ b/tapeserver/castor/tape/tapeserver/daemon/TapeReadSingleThread.hpp
@@ -152,7 +152,6 @@ private:
    * Access Order
    */
   bool m_useRAO;
-  bool isLastTask;
   /// Helper virtual function to access the watchdog from parent class
   virtual void countTapeLogError(const std::string & error) { 
     m_watchdog.addToErrorCount(error);
-- 
GitLab