From aada2351a912200728d49b55f54dccc852023ef5 Mon Sep 17 00:00:00 2001
From: Michael Davis <michael.davis@cern.ch>
Date: Wed, 6 Jun 2018 17:12:19 +0200
Subject: [PATCH] [lpa_stream] Adds scoping around locks

---
 scheduler/OStoreDB/QueueItor.cpp | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/scheduler/OStoreDB/QueueItor.cpp b/scheduler/OStoreDB/QueueItor.cpp
index 80f80f5ed0..c876cff7b6 100644
--- a/scheduler/OStoreDB/QueueItor.cpp
+++ b/scheduler/OStoreDB/QueueItor.cpp
@@ -34,10 +34,11 @@ getQueueJobs()
    // In this case, we ignore the error and move on.
    try {
       JobQueue osaq(m_jobQueuesQueueIt->address, m_objectStore);
-      objectstore::ScopedSharedLock ostpl(osaq);
+      {
+         objectstore::ScopedSharedLock ostpl(osaq);
          osaq.fetch();
          m_jobQueue = osaq.dumpJobs();
-      ostpl.release();
+      }
       m_jobQueueIt = m_jobQueue.begin();
    } catch(...) {
       // Force an increment to the next queue
@@ -56,10 +57,11 @@ QueueItor(objectstore::Backend &objectStore, const std::string &queue_id) :
    m_jobQueueIt(m_jobQueue.begin())
 {
    objectstore::RootEntry re(m_objectStore);
-   objectstore::ScopedSharedLock rel(re);
+   {
+      objectstore::ScopedSharedLock rel(re);
       re.fetch();
       m_jobQueuesQueue = re.dumpArchiveQueues();
-   rel.release();
+   }
 
    // Set queue iterator to the first queue in the list
    m_jobQueuesQueueIt = m_jobQueuesQueue.begin();
@@ -146,10 +148,11 @@ QueueItor(objectstore::Backend &objectStore, const std::string &queue_id) :
    m_jobQueueIt(m_jobQueue.begin())
 {
    objectstore::RootEntry re(m_objectStore);
-   objectstore::ScopedSharedLock rel(re);
+   {
+      objectstore::ScopedSharedLock rel(re);
       re.fetch();
       m_jobQueuesQueue = re.dumpRetrieveQueues();
-   rel.release();
+   }
 
    // Find the first queue
    m_jobQueuesQueueIt = m_jobQueuesQueue.begin();
-- 
GitLab