From: Kern Sibbald Date: Sun, 22 Apr 2007 19:08:57 +0000 (+0000) Subject: Implement socket level heartbeat (tcp_keepidle) X-Git-Tag: Release-7.0.0~6531 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=ba04dcc67cdf85fbec6f5fe1b6c7a86041f95e3a;p=bacula%2Fbacula Implement socket level heartbeat (tcp_keepidle) git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@4597 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/src/console/console.c b/bacula/src/console/console.c index 34064f774f..f62b155ce9 100644 --- a/bacula/src/console/console.c +++ b/bacula/src/console/console.c @@ -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); diff --git a/bacula/src/console/console_conf.c b/bacula/src/console/console_conf.c index a65dfb841d..c675eadd21 100644 --- a/bacula/src/console/console_conf.c +++ b/bacula/src/console/console_conf.c @@ -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. @@ -46,6 +25,27 @@ (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} }; diff --git a/bacula/src/console/console_conf.h b/bacula/src/console/console_conf.h index 58f4cb23ec..308ebb82c4 100644 --- a/bacula/src/console/console_conf.h +++ b/bacula/src/console/console_conf.h @@ -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. @@ -32,6 +25,13 @@ (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 */ }; diff --git a/bacula/src/dird/dird_conf.c b/bacula/src/dird/dird_conf.c index 43fe648a4e..022dff20ef 100644 --- a/bacula/src/dird/dird_conf.c +++ b/bacula/src/dird/dird_conf.c @@ -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}, diff --git a/bacula/src/dird/dird_conf.h b/bacula/src/dird/dird_conf.h index 0364f5b5fe..2ba9f5afcc 100644 --- a/bacula/src/dird/dird_conf.h +++ b/bacula/src/dird/dird_conf.h @@ -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 */ diff --git a/bacula/src/dird/fd_cmds.c b/bacula/src/dird/fd_cmds.c index 785d6794b8..0f6ef13500 100644 --- a/bacula/src/dird/fd_cmds.c +++ b/bacula/src/dird/fd_cmds.c @@ -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 } diff --git a/bacula/src/dird/msgchan.c b/bacula/src/dird/msgchan.c index 997f1447a1..c03460aea5 100644 --- a/bacula/src/dird/msgchan.c +++ b/bacula/src/dird/msgchan.c @@ -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. @@ -42,6 +25,23 @@ (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) { diff --git a/bacula/src/filed/filed_conf.c b/bacula/src/filed/filed_conf.c index 416f9ecc84..67dc659765 100644 --- a/bacula/src/filed/filed_conf.c +++ b/bacula/src/filed/filed_conf.c @@ -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. @@ -48,6 +25,29 @@ (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}, diff --git a/bacula/src/filed/filed_conf.h b/bacula/src/filed/filed_conf.h index 4a3fd1c6c8..1e2c9a3c51 100644 --- a/bacula/src/filed/filed_conf.h +++ b/bacula/src/filed/filed_conf.h @@ -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. @@ -32,6 +25,13 @@ (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 */ diff --git a/bacula/src/filed/job.c b/bacula/src/filed/job.c index 55ec529734..eb0af2470f 100644 --- a/bacula/src/filed/job.c +++ b/bacula/src/filed/job.c @@ -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); diff --git a/bacula/src/jcr.h b/bacula/src/jcr.h index c07e305e8a..f31ca4ccca 100644 --- a/bacula/src/jcr.h +++ b/bacula/src/jcr.h @@ -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. @@ -35,6 +25,16 @@ (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_ diff --git a/bacula/src/lib/bnet.c b/bacula/src/lib/bnet.c index c92bdc7ab4..bdf380bdc5 100644 --- a/bacula/src/lib/bnet.c +++ b/bacula/src/lib/bnet.c @@ -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) { diff --git a/bacula/src/lib/protos.h b/bacula/src/lib/protos.h index 4c3dd934ca..5862349bdc 100644 --- a/bacula/src/lib/protos.h +++ b/bacula/src/lib/protos.h @@ -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, diff --git a/bacula/src/qt-console/bat_conf.cpp b/bacula/src/qt-console/bat_conf.cpp index 88457be53f..29f2489068 100644 --- a/bacula/src/qt-console/bat_conf.cpp +++ b/bacula/src/qt-console/bat_conf.cpp @@ -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} }; diff --git a/bacula/src/qt-console/bat_conf.h b/bacula/src/qt-console/bat_conf.h index 5a583d465f..34020550e6 100644 --- a/bacula/src/qt-console/bat_conf.h +++ b/bacula/src/qt-console/bat_conf.h @@ -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. @@ -32,6 +25,13 @@ (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 */ }; diff --git a/bacula/src/qt-console/console/console.cpp b/bacula/src/qt-console/console/console.cpp index 2b4e649c71..ac90518935 100644 --- a/bacula/src/qt-console/console/console.cpp +++ b/bacula/src/qt-console/console/console.cpp @@ -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"); diff --git a/bacula/technotes-2.1 b/bacula/technotes-2.1 index f94e655a2a..53bceac559 100644 --- a/bacula/technotes-2.1 +++ b/bacula/technotes-2.1 @@ -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.