]> git.sur5r.net Git - bacula/bacula/commitdiff
Implement socket level heartbeat (tcp_keepidle)
authorKern Sibbald <kern@sibbald.com>
Sun, 22 Apr 2007 19:08:57 +0000 (19:08 +0000)
committerKern Sibbald <kern@sibbald.com>
Sun, 22 Apr 2007 19:08:57 +0000 (19:08 +0000)
git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@4597 91ce42f0-d328-0410-95d8-f526ca767f89

20 files changed:
bacula/src/console/console.c
bacula/src/console/console_conf.c
bacula/src/console/console_conf.h
bacula/src/dird/dird_conf.c
bacula/src/dird/dird_conf.h
bacula/src/dird/fd_cmds.c
bacula/src/dird/msgchan.c
bacula/src/filed/filed_conf.c
bacula/src/filed/filed_conf.h
bacula/src/filed/job.c
bacula/src/gnome2-console/console.c
bacula/src/jcr.h
bacula/src/lib/bnet.c
bacula/src/lib/protos.h
bacula/src/qt-console/bat_conf.cpp
bacula/src/qt-console/bat_conf.h
bacula/src/qt-console/console/console.cpp
bacula/src/tray-monitor/tray-monitor.c
bacula/src/wx-console/console_thread.cpp
bacula/technotes-2.1

index 34064f774fd2dce0329fdba578cf3d4eb6755371..f62b155ce9ca5a80857485971ec1bdd216120df5 100644 (file)
@@ -345,6 +345,7 @@ int main(int argc, char *argv[])
    bool no_signals = false;
    bool test_config = false;
    JCR jcr;
+   utime_t heart_beat;
 
    setlocale(LC_ALL, "");
    bindtextdomain("bacula", LOCALEDIR);
@@ -556,7 +557,14 @@ try_again:
       }
    }
 
-   UA_sock = bnet_connect(NULL, 5, 15, "Director daemon", dir->address,
+   if (dir->heartbeat_interval) {
+      heart_beat = dir->heartbeat_interval;
+   } else if (cons) {
+      heart_beat = cons->heartbeat_interval;
+   } else {
+      heart_beat = 0;
+   }
+   UA_sock = bnet_connect(NULL, 5, 15, heart_beat, "Director daemon", dir->address,
                           NULL, dir->DIRport, 0);
    if (UA_sock == NULL) {
       terminate_console(0);
index a65dfb841dc21cfca82b8a8616f47a742d11997b..c675eadd21c324faf61f7b5048bcacb684bfba14 100644 (file)
@@ -1,28 +1,7 @@
-/*
- *   Main configuration file parser for Bacula User Agent
- *    some parts may be split into separate files such as
- *    the schedule configuration (sch_config.c).
- *
- *   Note, the configuration file parser consists of three parts
- *
- *   1. The generic lexical scanner in lib/lex.c and lib/lex.h
- *
- *   2. The generic config  scanner in lib/parse_config.c and
- *      lib/parse_config.h.
- *      These files contain the parser code, some utility
- *      routines, and the common store routines (name, int,
- *      string).
- *
- *   3. The daemon specific file, which contains the Resource
- *      definitions as well as any specific store routines
- *      for the resource records.
- *
- *     Kern Sibbald, January MM, September MM
- */
 /*
    Bacula® - The Network Backup Solution
 
-   Copyright (C) 2000-2006 Free Software Foundation Europe e.V.
+   Copyright (C) 2000-2007 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.
    (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
    Switzerland, email:ftf@fsfeurope.org.
 */
+/*
+ *   Main configuration file parser for Bacula User Agent
+ *    some parts may be split into separate files such as
+ *    the schedule configuration (sch_config.c).
+ *
+ *   Note, the configuration file parser consists of three parts
+ *
+ *   1. The generic lexical scanner in lib/lex.c and lib/lex.h
+ *
+ *   2. The generic config  scanner in lib/parse_config.c and
+ *      lib/parse_config.h.
+ *      These files contain the parser code, some utility
+ *      routines, and the common store routines (name, int,
+ *      string).
+ *
+ *   3. The daemon specific file, which contains the Resource
+ *      definitions as well as any specific store routines
+ *      for the resource records.
+ *
+ *     Kern Sibbald, January MM, September MM
+ */
 
 #include "bacula.h"
 #include "console_conf.h"
@@ -95,6 +95,7 @@ static RES_ITEM cons_items[] = {
    {"tlscertificate", store_dir,       ITEM(res_cons.tls_certfile), 0, 0, 0},
    {"tlskey",         store_dir,       ITEM(res_cons.tls_keyfile), 0, 0, 0},
    {"director",       store_str,       ITEM(res_cons.director), 0, 0, 0},
+   {"heartbeatinterval", store_time, ITEM(res_cons.heartbeat_interval), 0, ITEM_DEFAULT, 0},
    {NULL, NULL, {0}, 0, 0, 0}
 };
 
@@ -112,6 +113,7 @@ static RES_ITEM dir_items[] = {
    {"tlscacertificatedir", store_dir,  ITEM(res_dir.tls_ca_certdir), 0, 0, 0},
    {"tlscertificate", store_dir,       ITEM(res_dir.tls_certfile), 0, 0, 0},
    {"tlskey",         store_dir,       ITEM(res_dir.tls_keyfile), 0, 0, 0},
+   {"heartbeatinterval", store_time, ITEM(res_dir.heartbeat_interval), 0, ITEM_DEFAULT, 0},
    {NULL, NULL, {0}, 0, 0, 0}
 };
 
index 58f4cb23ecb17aabf17c534c8d0d09eb73e6db32..308ebb82c4c6109dbc7778399efd337777cdb9f8 100644 (file)
@@ -1,14 +1,7 @@
-/*
- * Bacula User Agent specific configuration and defines
- *
- *     Kern Sibbald, Sep MM
- *
- *     Version $Id$
- */
 /*
    Bacula® - The Network Backup Solution
 
-   Copyright (C) 2000-2006 Free Software Foundation Europe e.V.
+   Copyright (C) 2000-2007 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.
    (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
    Switzerland, email:ftf@fsfeurope.org.
 */
+/*
+ * Bacula User Agent specific configuration and defines
+ *
+ *     Kern Sibbald, Sep MM
+ *
+ *     Version $Id$
+ */
 
 /*
  * Resource codes -- they must be sequential for indexing
@@ -71,6 +71,7 @@ struct CONRES {
    char *tls_certfile;                /* TLS Client Certificate File */
    char *tls_keyfile;                 /* TLS Client Key File */
    char *director;                    /* bind to director */
+   utime_t heartbeat_interval;        /* Interval to send heartbeats to Dir */
 
    TLS_CONTEXT *tls_ctx;              /* Shared TLS Context */
 };
@@ -87,6 +88,7 @@ struct DIRRES {
    char *tls_ca_certdir;              /* TLS CA Certificate Directory */
    char *tls_certfile;                /* TLS Client Certificate File */
    char *tls_keyfile;                 /* TLS Client Key File */
+   utime_t heartbeat_interval;        /* Interval to send heartbeats to Dir */
 
    TLS_CONTEXT *tls_ctx;              /* Shared TLS Context */
 };
index 43fe648a4e4440eefe1263dda002ccb810df583a..022dff20ef79134148f2de507e4b0cecb4e40741 100644 (file)
@@ -121,6 +121,7 @@ static RES_ITEM dir_items[] = {
    {"password",    store_password, ITEM(res_dir.password), 0, ITEM_REQUIRED, 0},
    {"fdconnecttimeout", store_time,ITEM(res_dir.FDConnectTimeout), 0, ITEM_DEFAULT, 60 * 30},
    {"sdconnecttimeout", store_time,ITEM(res_dir.SDConnectTimeout), 0, ITEM_DEFAULT, 60 * 30},
+   {"heartbeatinterval", store_time, ITEM(res_dir.heartbeat_interval), 0, ITEM_DEFAULT, 0},
    {"tlsenable",            store_bool,      ITEM(res_dir.tls_enable), 0, 0, 0},
    {"tlsrequire",           store_bool,      ITEM(res_dir.tls_require), 0, 0, 0},
    {"tlsverifypeer",        store_bool,      ITEM(res_dir.tls_verify_peer), 0, ITEM_DEFAULT, true},
@@ -182,6 +183,7 @@ static RES_ITEM cli_items[] = {
    {"catalog",  store_res,        ITEM(res_client.catalog),  R_CATALOG, ITEM_REQUIRED, 0},
    {"fileretention", store_time,  ITEM(res_client.FileRetention), 0, ITEM_DEFAULT, 60*60*24*60},
    {"jobretention",  store_time,  ITEM(res_client.JobRetention),  0, ITEM_DEFAULT, 60*60*24*180},
+   {"heartbeatinterval", store_time, ITEM(res_client.heartbeat_interval), 0, ITEM_DEFAULT, 0},
    {"autoprune", store_bool,      ITEM(res_client.AutoPrune), 0, ITEM_DEFAULT, true},
    {"maximumconcurrentjobs", store_pint, ITEM(res_client.MaxConcurrentJobs), 0, ITEM_DEFAULT, 1},
    {"tlsenable",            store_bool,      ITEM(res_client.tls_enable), 0, 0, 0},
@@ -210,6 +212,7 @@ static RES_ITEM store_items[] = {
    {"mediatype",   store_strname,  ITEM(res_store.media_type), 0, ITEM_REQUIRED, 0},
    {"autochanger", store_bool,     ITEM(res_store.autochanger), 0, ITEM_DEFAULT, 0},
    {"enabled",     store_bool,     ITEM(res_store.enabled),     0, ITEM_DEFAULT, true},
+   {"heartbeatinterval", store_time, ITEM(res_store.heartbeat_interval), 0, ITEM_DEFAULT, 0},
    {"maximumconcurrentjobs", store_pint, ITEM(res_store.MaxConcurrentJobs), 0, ITEM_DEFAULT, 1},
    {"sddport", store_pint, ITEM(res_store.SDDport), 0, 0, 0}, /* deprecated */
    {"tlsenable",            store_bool,      ITEM(res_store.tls_enable), 0, 0, 0},
index 0364f5b5fe52c7f5f9e3749999e269cf18cde37b..2ba9f5afcc796318e577d70112ee9253401dc1d9 100644 (file)
@@ -116,6 +116,7 @@ public:
    uint32_t MaxConcurrentJobs;        /* Max concurrent jobs for whole director */
    utime_t FDConnectTimeout;          /* timeout for connect in seconds */
    utime_t SDConnectTimeout;          /* timeout in seconds */
+   utime_t heartbeat_interval;        /* Interval to send heartbeats */
    char *tls_ca_certfile;             /* TLS CA Certificate File */
    char *tls_ca_certdir;              /* TLS CA Certificate Directory */
    char *tls_certfile;                /* TLS Server Certificate File */
@@ -245,6 +246,7 @@ public:
    int   FDport;                      /* Where File daemon listens */
    utime_t FileRetention;             /* file retention period in seconds */
    utime_t JobRetention;              /* job retention period in seconds */
+   utime_t heartbeat_interval;        /* Interval to send heartbeats */
    char *address;
    char *password;
    CAT *catalog;                      /* Catalog resource */
@@ -293,6 +295,7 @@ public:
    bool enabled;                      /* Set if device is enabled */
    bool  autochanger;                 /* set if autochanger */
    int64_t StorageId;                 /* Set from Storage DB record */
+   utime_t heartbeat_interval;        /* Interval to send heartbeats */
    int  drives;                       /* number of drives in autochanger */
 
    /* Methods */
index 785d6794b8e1c16fd108aa06b01ae8cb15bbe219..0f6ef13500bb35bb1ffc14e5fd997d5f57e931bd 100644 (file)
@@ -79,9 +79,16 @@ int connect_to_file_daemon(JCR *jcr, int retry_interval, int max_retry_time,
 {
    BSOCK   *fd;
    char ed1[30];
+   utime_t heart_beat;
+
+   if (jcr->client->heartbeat_interval) {
+      heart_beat = jcr->client->heartbeat_interval;
+   } else {           
+      heart_beat = director->heartbeat_interval;
+   }
 
    if (!jcr->file_bsock) {
-      fd = bnet_connect(jcr, retry_interval, max_retry_time,
+      fd = bnet_connect(jcr, retry_interval, max_retry_time, heart_beat,
            _("File daemon"), jcr->client->address,
            NULL, jcr->client->FDport, verbose);
       if (fd == NULL) {
@@ -556,7 +563,7 @@ int send_runscripts_commands(JCR *jcr)
             }
          }
          /* TODO : we have to play with other client */
-        /*
+         /*
            else {
            send command to an other client
            }
index 997f1447a1384b7d6edcfd35b01754369cf1c7ec..c03460aea5502eb483ca8623c0b76327fc0380ba 100644 (file)
@@ -1,24 +1,7 @@
-/*
- *
- *   Bacula Director -- msgchan.c -- handles the message channel
- *    to the Storage daemon and the File daemon.
- *
- *     Kern Sibbald, August MM
- *
- *    This routine runs as a thread and must be thread reentrant.
- *
- *  Basic tasks done here:
- *    Open a message channel with the Storage daemon
- *      to authenticate ourself and to pass the JobId.
- *    Create a thread to interact with the Storage daemon
- *      who returns a job status and requests Catalog services, etc.
- *
- *   Version $Id$
- */
 /*
    Bacula® - The Network Backup Solution
 
-   Copyright (C) 2000-2006 Free Software Foundation Europe e.V.
+   Copyright (C) 2000-20076 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.
    (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
    Switzerland, email:ftf@fsfeurope.org.
 */
+/*
+ *
+ *   Bacula Director -- msgchan.c -- handles the message channel
+ *    to the Storage daemon and the File daemon.
+ *
+ *     Kern Sibbald, August MM
+ *
+ *    This routine runs as a thread and must be thread reentrant.
+ *
+ *  Basic tasks done here:
+ *    Open a message channel with the Storage daemon
+ *      to authenticate ourself and to pass the JobId.
+ *    Create a thread to interact with the Storage daemon
+ *      who returns a job status and requests Catalog services, etc.
+ *
+ *   Version $Id$
+ */
 
 #include "bacula.h"
 #include "dird.h"
@@ -78,6 +78,7 @@ bool connect_to_storage_daemon(JCR *jcr, int retry_interval,
 {
    BSOCK *sd;
    STORE *store;
+   utime_t heart_beat;    
 
    if (jcr->store_bsock) {
       return true;                    /* already connected */
@@ -90,12 +91,18 @@ bool connect_to_storage_daemon(JCR *jcr, int retry_interval,
       store = jcr->rstore;
    }
 
+   if (store->heartbeat_interval) {
+      heart_beat = store->heartbeat_interval;
+   } else {           
+      heart_beat = director->heartbeat_interval;
+   }
+
    /*
     *  Open message channel with the Storage daemon
     */
    Dmsg2(100, "bnet_connect to Storage daemon %s:%d\n", store->address,
       store->SDport);
-   sd = bnet_connect(jcr, retry_interval, max_retry_time,
+   sd = bnet_connect(jcr, retry_interval, max_retry_time, heart_beat,
           _("Storage daemon"), store->address,
           NULL, store->SDport, verbose);
    if (sd == NULL) {
index 416f9ecc846e117996164330d7fb1f03edfd46f5..67dc6597650baec9fc5657377569ba2e58cccf67 100644 (file)
@@ -1,30 +1,7 @@
-/*
- *   Main configuration file parser for Bacula File Daemon (Client)
- *    some parts may be split into separate files such as
- *    the schedule configuration (sch_config.c).
- *
- *   Note, the configuration file parser consists of three parts
- *
- *   1. The generic lexical scanner in lib/lex.c and lib/lex.h
- *
- *   2. The generic config  scanner in lib/parse_config.c and
- *      lib/parse_config.h.
- *      These files contain the parser code, some utility
- *      routines, and the common store routines (name, int,
- *      string).
- *
- *   3. The daemon specific file, which contains the Resource
- *      definitions as well as any specific store routines
- *      for the resource records.
- *
- *     Kern Sibbald, September MM
- *
- *   Version $Id$
- */
 /*
    Bacula® - The Network Backup Solution
 
-   Copyright (C) 2000-2006 Free Software Foundation Europe e.V.
+   Copyright (C) 2000-2007 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.
    (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
    Switzerland, email:ftf@fsfeurope.org.
 */
+/*
+ *   Main configuration file parser for Bacula File Daemon (Client)
+ *    some parts may be split into separate files such as
+ *    the schedule configuration (sch_config.c).
+ *
+ *   Note, the configuration file parser consists of three parts
+ *
+ *   1. The generic lexical scanner in lib/lex.c and lib/lex.h
+ *
+ *   2. The generic config  scanner in lib/parse_config.c and
+ *      lib/parse_config.h.
+ *      These files contain the parser code, some utility
+ *      routines, and the common store routines (name, int,
+ *      string).
+ *
+ *   3. The daemon specific file, which contains the Resource
+ *      definitions as well as any specific store routines
+ *      for the resource records.
+ *
+ *     Kern Sibbald, September MM
+ *
+ *   Version $Id$
+ */
 
 #include "bacula.h"
 #include "filed.h"
@@ -98,8 +98,8 @@ static RES_ITEM cli_items[] = {
    {"scriptsdirectory",  store_dir,  ITEM(res_client.scripts_directory),  0, 0, 0},
    {"maximumconcurrentjobs", store_pint,  ITEM(res_client.MaxConcurrentJobs), 0, ITEM_DEFAULT, 10},
    {"messages",      store_res, ITEM(res_client.messages), R_MSGS, 0, 0},
-   {"heartbeatinterval", store_time, ITEM(res_client.heartbeat_interval), 0, ITEM_DEFAULT, 0},
    {"sdconnecttimeout", store_time,ITEM(res_client.SDConnectTimeout), 0, ITEM_DEFAULT, 60 * 30},
+   {"heartbeatinterval", store_time, ITEM(res_client.heartbeat_interval), 0, ITEM_DEFAULT, 0},
    {"maximumnetworkbuffersize", store_pint, ITEM(res_client.max_network_buffer_size), 0, 0, 0},
 #ifdef DATA_ENCRYPTION
    {"pkisignatures",         store_bool,    ITEM(res_client.pki_sign), 0, ITEM_DEFAULT, 0},
index 4a3fd1c6c8daa8a00ac07e719aa47cf5c7b49a8c..1e2c9a3c51aa56a481f5027f2bd6261c5dc72889 100644 (file)
@@ -1,14 +1,7 @@
-/*
- * Bacula File Daemon specific configuration
- *
- *     Kern Sibbald, Sep MM
- *
- *   Version $Id$
- */
 /*
    Bacula® - The Network Backup Solution
 
-   Copyright (C) 2000-2006 Free Software Foundation Europe e.V.
+   Copyright (C) 2000-2007 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.
    (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
    Switzerland, email:ftf@fsfeurope.org.
 */
+/*
+ * Bacula File Daemon specific configuration
+ *
+ *     Kern Sibbald, Sep MM
+ *
+ *   Version $Id$
+ */
 
 /*
  * Resource codes -- they must be sequential for indexing
@@ -81,8 +81,8 @@ struct CLIENT {
    char *scripts_directory;
    MSGS *messages;                    /* daemon message handler */
    int MaxConcurrentJobs;
-   utime_t heartbeat_interval;        /* Interval to send heartbeats to Dir */
    utime_t SDConnectTimeout;          /* timeout in seconds */
+   utime_t heartbeat_interval;        /* Interval to send heartbeats */
    uint32_t max_network_buffer_size;  /* max network buf size */
    bool pki_sign;                     /* Enable Data Integrity Verification via Digital Signatures */
    bool pki_encrypt;                  /* Enable Data Encryption */
index 55ec529734a63334c043da810f148b8d50eacdce..eb0af2470fba1f1aeeb31f4cf113c0a24d0169f3 100644 (file)
@@ -1,7 +1,7 @@
 /*
    Bacula® - The Network Backup Solution
 
-   Copyright (C) 2000-2006 Free Software Foundation Europe e.V.
+   Copyright (C) 2000-2007 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.
@@ -1265,8 +1265,8 @@ static int storage_cmd(JCR *jcr)
    Dmsg3(110, "Open storage: %s:%d ssl=%d\n", jcr->stored_addr, stored_port, enable_ssl);
    /* Open command communications with Storage daemon */
    /* Try to connect for 1 hour at 10 second intervals */
-   sd = bnet_connect(jcr, 10, (int)me->SDConnectTimeout, _("Storage daemon"),
-                     jcr->stored_addr, NULL, stored_port, 1);
+   sd = bnet_connect(jcr, 10, (int)me->SDConnectTimeout, me->heartbeat_interval,
+                      _("Storage daemon"), jcr->stored_addr, NULL, stored_port, 1);
    if (sd == NULL) {
       Jmsg(jcr, M_FATAL, 0, _("Failed to connect to Storage daemon: %s:%d\n"),
           jcr->stored_addr, stored_port);
index 0b0d0424b1bd76d36650a238076177286d3f1c7a..c75cc09798c1b3ac4977ad751426234f44aaedd9 100644 (file)
@@ -554,7 +554,7 @@ int connect_to_director(gpointer data)
    }
 
 
-   UA_sock = bnet_connect(NULL, 5, 15, _("Director daemon"), dir->address,
+   UA_sock = bnet_connect(NULL, 5, 15, 0, _("Director daemon"), dir->address,
                           NULL, dir->DIRport, 0);
    if (UA_sock == NULL) {
       return 0;
index c07e305e8a6d30f42f0dc962fc23773aab205416..f31ca4cccafa820bbac4dccddd992d3adede2cdf 100644 (file)
@@ -1,17 +1,7 @@
-/*
- * Bacula JCR Structure definition for Daemons and the Library
- *  This definition consists of a "Global" definition common
- *  to all daemons and used by the library routines, and a
- *  daemon specific part that is enabled with #defines.
- *
- * Kern Sibbald, Nov MM
- *
- *   Version $Id$
- */
 /*
    Bacula® - The Network Backup Solution
 
-   Copyright (C) 2000-2006 Free Software Foundation Europe e.V.
+   Copyright (C) 2000-2007 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.
    (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
    Switzerland, email:ftf@fsfeurope.org.
 */
+/*
+ * Bacula JCR Structure definition for Daemons and the Library
+ *  This definition consists of a "Global" definition common
+ *  to all daemons and used by the library routines, and a
+ *  daemon specific part that is enabled with #defines.
+ *
+ * Kern Sibbald, Nov MM
+ *
+ *   Version $Id$
+ */
 
 
 #ifndef __JCR_H_
index c92bdc7ab42cdaa64092f665960a1d5e29385605..bdf380bdc566849a1bc60e8250094424a434d9b4 100644 (file)
@@ -555,8 +555,8 @@ dlist *bnet_host2ipaddrs(const char *host, int family, const char **errstr)
  * Returns BSOCK * pointer on success
  *
  */
-static BSOCK *bnet_open(JCR * jcr, const char *name, char *host, char *service,
-                        int port, int *fatal)
+static BSOCK *bnet_open(JCR *jcr, const char *name, char *host, char *service,
+                        int port, utime_t heart_beat, int *fatal)
 {
    int sockfd = -1;
    dlist *addr_list;
@@ -604,6 +604,17 @@ static BSOCK *bnet_open(JCR * jcr, const char *name, char *host, char *service,
          Qmsg1(jcr, M_WARNING, 0, _("Cannot set SO_KEEPALIVE on socket: %s\n"),
                be.strerror());
       }
+#if defined(TCP_KEEPIDLE)
+      if (heart_beat) {
+         int opt = heart_beat
+         if (setsockopt(sockfd, IPPROTO_IP, TCP_KEEPIDLE, (sockopt_val_t)&opt, sizeof(opt)) < 0) {
+            berrno be;
+            Qmsg1(jcr, M_WARNING, 0, _("Cannot set SO_KEEPALIVE on socket: %s\n"),
+                  be.strerror());
+         }
+      }
+#endif
+
       /* connect to server */
       if (connect(sockfd, ipaddr->get_sockaddr(), ipaddr->get_sockaddr_len()) < 0) {
          save_errno = errno;
@@ -638,6 +649,7 @@ static BSOCK *bnet_open(JCR * jcr, const char *name, char *host, char *service,
  * Try to connect to host for max_retry_time at retry_time intervals.
  */
 BSOCK *bnet_connect(JCR * jcr, int retry_interval, utime_t max_retry_time,
+                    utime_t heart_beat,
                     const char *name, char *host, char *service, int port,
                     int verbose)
 {
@@ -647,7 +659,7 @@ BSOCK *bnet_connect(JCR * jcr, int retry_interval, utime_t max_retry_time,
    time_t begin_time = time(NULL);
    time_t now;
 
-   for (i = 0; (bsock = bnet_open(jcr, name, host, service, port, &fatal)) == NULL;
+   for (i = 0; (bsock = bnet_open(jcr, name, host, service, port, heart_beat, &fatal)) == NULL;
         i -= retry_interval) {
       berrno be;
       if (fatal || (jcr && job_canceled(jcr))) {
@@ -747,9 +759,8 @@ bool bnet_set_buffer_size(BSOCK * bs, uint32_t size, int rw)
    uint32_t dbuf_size, start_size;
 #if defined(IP_TOS) && defined(IPTOS_THROUGHPUT)
    int opt;
-
    opt = IPTOS_THROUGHPUT;
-   setsockopt(bs->fd, IPPROTO_IP, IP_TOS, (sockopt_val_t) & opt, sizeof(opt));
+   setsockopt(bs->fd, IPPROTO_IP, IP_TOS, (sockopt_val_t)&opt, sizeof(opt));
 #endif
 
    if (size != 0) {
index 4c3dd934cad300847ba3d77250edbc5bd5d98b0c..5862349bdca4532fcba97480495583bb7439447c 100644 (file)
@@ -88,7 +88,8 @@ bool       bnet_tls_server       (TLS_CONTEXT *ctx, BSOCK *bsock,
 bool       bnet_tls_client       (TLS_CONTEXT *ctx, BSOCK *bsock,
                                   alist *verify_list);
 BSOCK *    bnet_connect          (JCR *jcr, int retry_interval,
-               utime_t max_retry_time, const char *name, char *host, char *service,
+               utime_t max_retry_time, utime_t heart_beat, 
+               const char *name, char *host, char *service,
                int port, int verbose);
 void       bnet_close            (BSOCK *bsock);
 BSOCK *    init_bsock            (JCR *jcr, int sockfd, const char *who, const char *ip,
index 88457be53f87d15d8a85909e42eaaf21edb010cf..29f2489068870aa2215a17e691d78801e3ca1ff8 100644 (file)
@@ -88,6 +88,7 @@ static RES_ITEM dir_items[] = {
    {"tlscacertificatedir", store_dir,  ITEM(dir_res.tls_ca_certdir), 0, 0, 0},
    {"tlscertificate", store_dir,       ITEM(dir_res.tls_certfile), 0, 0, 0},
    {"tlskey",         store_dir,       ITEM(dir_res.tls_keyfile), 0, 0, 0},
+   {"heartbeatinterval", store_time, ITEM(dir_res.heartbeat_interval), 0, ITEM_DEFAULT, 0},
    {NULL, NULL, {0}, 0, 0, 0}
 };
 
@@ -101,6 +102,7 @@ static RES_ITEM con_items[] = {
    {"tlscacertificatedir", store_dir,  ITEM(con_res.tls_ca_certdir), 0, 0, 0},
    {"tlscertificate", store_dir,       ITEM(con_res.tls_certfile), 0, 0, 0},
    {"tlskey",         store_dir,       ITEM(con_res.tls_keyfile), 0, 0, 0},
+   {"heartbeatinterval", store_time, ITEM(con_res.heartbeat_interval), 0, ITEM_DEFAULT, 0},
    {NULL, NULL, {0}, 0, 0, 0}
 };
 
index 5a583d465fe1570d03ae36ca8b476ef149860144..34020550e69e6365525a76e9fd6f5a6f8dc4451a 100644 (file)
@@ -1,14 +1,7 @@
-/*
- * Bacula Adminstration Tool (bat) 
- *
- *     Kern Sibbald, March 2002
- *
- *     Version $Id$
- */
 /*
    Bacula® - The Network Backup Solution
 
-   Copyright (C) 2002-2006 Free Software Foundation Europe e.V.
+   Copyright (C) 2002-2007 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.
    (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
    Switzerland, email:ftf@fsfeurope.org.
 */
+/*
+ * Bacula Adminstration Tool (bat) 
+ *
+ *     Kern Sibbald, March 2002
+ *
+ *     Version $Id$
+ */
 
 #ifndef _BAT_CONF_H_
 #define _BAT_CONF_H_
@@ -72,6 +72,7 @@ struct DIRRES {
    char *tls_ca_certdir;              /* TLS CA Certificate Directory */
    char *tls_certfile;                /* TLS Client Certificate File */
    char *tls_keyfile;                 /* TLS Client Key File */
+   utime_t heartbeat_interval;        /* Dir heartbeat interval */
 
    TLS_CONTEXT *tls_ctx;              /* Shared TLS Context */
 
@@ -96,6 +97,7 @@ struct CONRES {
    char *tls_ca_certdir;              /* TLS CA Certificate Directory */
    char *tls_certfile;                /* TLS Client Certificate File */
    char *tls_keyfile;                 /* TLS Client Key File */
+   utime_t heartbeat_interval;        /* Dir heartbeat interval */
 
    TLS_CONTEXT *tls_ctx;              /* Shared TLS Context */
 };
index 2b4e649c71d8cecf42bd66478193222a39acf8da..ac90518935ace2e0182fe13ea90ddbe30841b869 100644 (file)
@@ -85,6 +85,7 @@ void Console::terminate()
 void Console::connect()
 {
    JCR jcr;
+   utime_t heart_beat;
 
    m_textEdit = textEdit;   /* our console screen */
 
@@ -110,7 +111,16 @@ void Console::connect()
    CONRES *cons = (CONRES *)GetNextRes(R_CONSOLE, (RES *)NULL);
    UnlockRes();
 
-   m_sock = bnet_connect(NULL, 5, 15, _("Director daemon"), m_dir->address,
+   if (m_dir->heartbeat_interval) {
+      heart_beat = m_dir->heartbeat_interval;
+   } else if (cons) {
+      heart_beat = cons->heartbeat_interval;
+   } else {
+      heart_beat = 0;
+   }        
+
+   m_sock = bnet_connect(NULL, 5, 15, heart_beat,
+                          _("Director daemon"), m_dir->address,
                           NULL, m_dir->DIRport, 0);
    if (m_sock == NULL) {
       mainWin->set_status("Connection failed");
index 0baf511675280e2bb2497be4a537b1ba3c77a258..a20e9ca9a2af64914c8e252a291a44bf58b8fed7 100644 (file)
@@ -871,21 +871,21 @@ int docmd(monitoritem* item, const char* command, GSList** list)
          dird = (DIRRES*)item->resource;
          trayMessage(_("Connecting to Director %s:%d\n"), dird->address, dird->DIRport);
          changeStatusMessage(item, _("Connecting to Director %s:%d"), dird->address, dird->DIRport);
-         item->D_sock = bnet_connect(NULL, 0, 0, _("Director daemon"), dird->address, NULL, dird->DIRport, 0);
+         item->D_sock = bnet_connect(NULL, 0, 0, 0, _("Director daemon"), dird->address, NULL, dird->DIRport, 0);
          jcr.dir_bsock = item->D_sock;
          break;
       case R_CLIENT:
          filed = (CLIENT*)item->resource;
          trayMessage(_("Connecting to Client %s:%d\n"), filed->address, filed->FDport);
          changeStatusMessage(item, _("Connecting to Client %s:%d"), filed->address, filed->FDport);
-         item->D_sock = bnet_connect(NULL, 0, 0, _("File daemon"), filed->address, NULL, filed->FDport, 0);
+         item->D_sock = bnet_connect(NULL, 0, 0, 0, _("File daemon"), filed->address, NULL, filed->FDport, 0);
          jcr.file_bsock = item->D_sock;
          break;
       case R_STORAGE:
          stored = (STORE*)item->resource;
          trayMessage(_("Connecting to Storage %s:%d\n"), stored->address, stored->SDport);
          changeStatusMessage(item, _("Connecting to Storage %s:%d"), stored->address, stored->SDport);
-         item->D_sock = bnet_connect(NULL, 0, 0, _("Storage daemon"), stored->address, NULL, stored->SDport, 0);
+         item->D_sock = bnet_connect(NULL, 0, 0, 0, _("Storage daemon"), stored->address, NULL, stored->SDport, 0);
          jcr.store_bsock = item->D_sock;
          break;
       default:
index ef5c59f9ea4d3ffd97632ca5421d73b0c4df6047..29dc080efcde983053e415d2c6649e3ddeda0469 100644 (file)
@@ -417,7 +417,7 @@ void* console_thread::Entry() {
    }
 
 
-   UA_sock = bnet_connect(&jcr, 3, 3, wxString(_("Director daemon")).mb_str(*wxConvCurrent),
+   UA_sock = bnet_connect(&jcr, 3, 3, 0, wxString(_("Director daemon")).mb_str(*wxConvCurrent),
       dir->address, NULL, dir->DIRport, 0);
       
    if (UA_sock == NULL) {
index f94e655a2a6592b36d84c886231ab9c54f212de6..53bceac55915d0116db7332742ff516ab572b80f 100644 (file)
@@ -2,6 +2,7 @@
 
 General:
 22Apr07
+kes  Implement socket level heartbeat (tcp_keepidle)
 ebl  Commit File relocation patch
 kes  Make bat have 'make install' target.
 kes  Warn during install if old gnome-console binary found.