From c90ddfd3cfe7afe959f94d22d476d4a8b3d44504 Mon Sep 17 00:00:00 2001
From: Marco van Wieringen <marco.van.wieringen@bareos.com>
Date: Tue, 11 Feb 2014 09:49:56 +0100
Subject: [PATCH] Don't continue when sd replication socket is not connected.

---
 src/stored/sd_cmds.c |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/src/stored/sd_cmds.c b/src/stored/sd_cmds.c
index 26a0fe6..7995ff4 100644
--- a/src/stored/sd_cmds.c
+++ b/src/stored/sd_cmds.c
@@ -249,7 +249,15 @@ bool do_listen_run(JCR *jcr)
    Dmsg3(50, "Auth=%d canceled=%d errstat=%d\n", jcr->authenticated,
          job_canceled(jcr), errstat);
    V(mutex);
-   Dmsg2(800, "Auth fail or cancel for jid=%d %p\n", jcr->JobId, jcr);
+
+   if (!jcr->authenticated || !jcr->store_bsock) {
+      Dmsg2(800, "Auth fail or cancel for jid=%d %p\n", jcr->JobId, jcr);
+
+      /*
+       * After a listen cmd we are done e.g. return false.
+       */
+      return false;
+   }
 
    Dmsg1(120, "Start run Job=%s\n", jcr->Job);
 
-- 
1.7.3.2

