-/*
- *
- * 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"
{
BSOCK *sd;
STORE *store;
+ utime_t heart_beat;
if (jcr->store_bsock) {
return true; /* already connected */
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) {
return 0;
}
- pm_strcpy(pool_type, jcr->pool->pool_type);
- pm_strcpy(pool_name, jcr->pool->hdr.name);
- bash_spaces(pool_type);
- bash_spaces(pool_name);
-
/*
* We have two loops here. The first comes from the
* Storage = associated with the Job, and we need
*/
/* Do read side of storage daemon */
if (ok && rstore) {
+ /* For the moment, only migrate has rpool */
+ if (jcr->JobType == JT_MIGRATE) {
+ pm_strcpy(pool_type, jcr->rpool->pool_type);
+ pm_strcpy(pool_name, jcr->rpool->name());
+ } else {
+ pm_strcpy(pool_type, jcr->pool->pool_type);
+ pm_strcpy(pool_name, jcr->pool->name());
+ }
+ bash_spaces(pool_type);
+ bash_spaces(pool_name);
foreach_alist(storage, rstore) {
Dmsg1(100, "Rstore=%s\n", storage->name());
- pm_strcpy(store_name, storage->name());
bash_spaces(store_name);
pm_strcpy(media_type, storage->media_type);
bash_spaces(media_type);
bnet_fsend(sd, use_storage, store_name.c_str(), media_type.c_str(),
pool_name.c_str(), pool_type.c_str(), 0, copy, stripe);
-
+ Dmsg1(100, "rstore >stored: %s", sd->msg);
DEVICE *dev;
/* Loop over alternative storage Devices until one is OK */
foreach_alist(dev, storage->device) {
/* Do write side of storage daemon */
if (ok && wstore) {
+ pm_strcpy(pool_type, jcr->pool->pool_type);
+ pm_strcpy(pool_name, jcr->pool->name());
+ bash_spaces(pool_type);
+ bash_spaces(pool_name);
foreach_alist(storage, wstore) {
- Dmsg1(100, "Wstore=%s\n", storage->name());
pm_strcpy(store_name, storage->name());
bash_spaces(store_name);
pm_strcpy(media_type, storage->media_type);
bnet_fsend(sd, use_storage, store_name.c_str(), media_type.c_str(),
pool_name.c_str(), pool_type.c_str(), 1, copy, stripe);
+ Dmsg1(100, "wstore >stored: %s", sd->msg);
DEVICE *dev;
/* Loop over alternative storage Devices until one is OK */
foreach_alist(dev, storage->device) {
" Storage daemon didn't accept Device \"%s\" command.\n"),
device_name.c_str());
}
+ } else {
+ Jmsg(jcr, M_INFO, 0, _("Using Device \"%s\"\n"), device_name.c_str());
}
return ok;
}
* Start a thread to handle Storage daemon messages and
* Catalog requests.
*/
-int start_storage_daemon_message_thread(JCR *jcr)
+bool start_storage_daemon_message_thread(JCR *jcr)
{
int status;
pthread_t thid;
/* Wait for thread to start */
while (jcr->SD_msg_chan == 0) {
bmicrosleep(0, 50);
+ if (job_canceled(jcr) || jcr->sd_msg_thread_done) {
+ return false;
+ }
}
Dmsg1(100, "SD msg_thread started. use=%d\n", jcr->use_count());
- return 1;
+ return true;
}
extern "C" void msg_thread_cleanup(void *arg)