]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/dird/msgchan.c
Fix line I accidently truncated
[bacula/bacula] / bacula / src / dird / msgchan.c
index 3980b3af4dd6c4731d9b176aee34987207f01218..31d47dab9fcc072cbea02a61252da779c9827567 100644 (file)
@@ -199,11 +199,6 @@ bool start_storage_daemon_job(JCR *jcr, alist *rstore, alist *wstore)
       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 
@@ -215,15 +210,24 @@ bool start_storage_daemon_job(JCR *jcr, alist *rstore, alist *wstore)
     */
    /* 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) {
@@ -246,8 +250,11 @@ bool start_storage_daemon_job(JCR *jcr, alist *rstore, alist *wstore)
 
    /* 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);
@@ -255,6 +262,7 @@ bool start_storage_daemon_job(JCR *jcr, alist *rstore, alist *wstore)
          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) {
@@ -294,7 +302,7 @@ bool start_storage_daemon_job(JCR *jcr, alist *rstore, alist *wstore)
  * 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;
@@ -310,9 +318,12 @@ int start_storage_daemon_message_thread(JCR *jcr)
    /* 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)