]> git.sur5r.net Git - bacula/bacula/commitdiff
Eliminate heartbeat error messages. Fixes bug #1925
authorKern Sibbald <kern@sibbald.com>
Sat, 8 Sep 2012 10:20:53 +0000 (12:20 +0200)
committerKern Sibbald <kern@sibbald.com>
Sat, 8 Sep 2012 10:20:53 +0000 (12:20 +0200)
bacula/src/filed/heartbeat.c

index b27e8998b94105d3e20c61343af37e2fbf3ba5b5..f39566bbd0e4e421be871ed9256b642b45731d78 100644 (file)
@@ -1,7 +1,7 @@
 /*
    Bacula® - The Network Backup Solution
 
-   Copyright (C) 2003-2008 Free Software Foundation Europe e.V.
+   Copyright (C) 2003-2012 Free Software Foundation Europe e.V.
 
    The main author of Bacula is Kern Sibbald, with contributions from
    many others, a complete list can be found in the file AUTHORS.
@@ -32,8 +32,6 @@
  *
  *    Kern Sibbald, May MMIII
  *
- *   Version $Id$
- *
  */
 
 #include "bacula.h"
@@ -67,26 +65,34 @@ extern "C" void *sd_heartbeat_thread(void *arg)
    jcr->hb_bsock = sd;
    jcr->hb_started = true;
    jcr->hb_dir_bsock = dir;
+   dir->m_suppress_error_msgs = true;
+   sd->m_suppress_error_msgs = true;
 
    /* Hang reading the socket to the SD, and every time we get
-    *   a heartbeat or we get a wait timeout (1 minute), we
+    *   a heartbeat or we get a wait timeout (5 seconds), we
     *   check to see if we need to send a heartbeat to the
     *   Director.
     */
-   for ( ; !is_bnet_stop(sd); ) {
+   while (!sd->is_stop()) {
       n = bnet_wait_data_intr(sd, WAIT_INTERVAL);
+      if (n < 0 || sd->is_stop()) {
+         break;
+      }
       if (me->heartbeat_interval) {
          now = time(NULL);
          if (now-last_heartbeat >= me->heartbeat_interval) {
-            bnet_sig(dir, BNET_HEARTBEAT);
+            dir->signal(BNET_HEARTBEAT);
+            if (dir->is_stop()) {
+               break;
+            }
             last_heartbeat = now;
          }
       }
-      if (n < 0 || is_bnet_stop(sd)) {
-         break;
-      }
-      if (n == 1) {                   /* input waiting */
-         sd->recv();                  /* read it -- probably heartbeat from sd */
+      if (n == 1) {               /* input waiting */
+         sd->recv();              /* read it -- probably heartbeat from sd */
+         if (sd->is_stop()) {
+            break;
+         }
          if (sd->msglen <= 0) {
             Dmsg1(100, "Got BNET_SIG %d from SD\n", sd->msglen);
          } else {
@@ -170,14 +176,18 @@ extern "C" void *dir_heartbeat_thread(void *arg)
 
    jcr->hb_bsock = dir;
    jcr->hb_started = true;
+   dir->m_suppress_error_msgs = true;
 
-   for ( ; !is_bnet_stop(dir); ) {
+   while (!dir->is_stop()) {
       time_t now, next;
 
       now = time(NULL);
       next = now - last_heartbeat;
       if (next >= me->heartbeat_interval) {
          dir->signal(BNET_HEARTBEAT);
+         if (dir->is_stop()) {
+            break;
+         }
          last_heartbeat = now;
       }
       bmicrosleep(next, 0);