From 1e99c8e8fb2c309d684a43ed4e606e867ddd507c Mon Sep 17 00:00:00 2001
From: Eric Cano <Eric.Cano@cern.ch>
Date: Fri, 17 Nov 2017 18:39:05 +0100
Subject: [PATCH] Fixed error condition when polling a gone agent.

---
 objectstore/AgentWatchdog.hpp | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/objectstore/AgentWatchdog.hpp b/objectstore/AgentWatchdog.hpp
index 64d3f2f3be..f0201b2ec0 100644
--- a/objectstore/AgentWatchdog.hpp
+++ b/objectstore/AgentWatchdog.hpp
@@ -31,7 +31,14 @@ public:
   }
   
   bool checkAlive() {
-    uint64_t newHeartBeatCount = readHeartbeat();
+    uint64_t newHeartBeatCount;
+    try { 
+      newHeartBeatCount = readHeartbeat();
+    } catch (Backend::NoSuchObject &) {
+      // The agent could be gone. This is not an error. Mark it as alive,
+      // and will be trimmed later.
+      return true;
+    }        
     auto timer = m_timer.secs();
     if (newHeartBeatCount == m_heartbeatCounter && timer > m_timeout)
       return false;
-- 
GitLab