]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/dird/backup.c
Add code for starting multiple migrations
[bacula/bacula] / bacula / src / dird / backup.c
index 79e041602e3ac70963bc87674c5171f77f49cc3b..292857a20732ed5488875015b1984f393f36071f 100644 (file)
@@ -170,27 +170,27 @@ bool do_backup(JCR *jcr)
    Dmsg0(150, "Storage daemon connection OK\n");
 
    if (!bnet_fsend(jcr->store_bsock, "run")) {
-      return false;
+      goto bail_out;
    }
 
    set_jcr_job_status(jcr, JS_WaitFD);
    if (!connect_to_file_daemon(jcr, 10, FDConnectTimeout, 1)) {
-      return false;
+      goto bail_out;
    }
 
    set_jcr_job_status(jcr, JS_Running);
    fd = jcr->file_bsock;
 
    if (!send_include_list(jcr)) {
-      return false;
+      goto bail_out;
    }
 
    if (!send_exclude_list(jcr)) {
-      return false;
+      goto bail_out;
    }
 
    if (!send_level_command(jcr)) {
-      return false;
+      goto bail_out;
    }
 
    /*
@@ -212,18 +212,18 @@ bool do_backup(JCR *jcr)
 
    bnet_fsend(fd, storaddr, store->address, store->SDDport, tls_need);
    if (!response(jcr, fd, OKstore, "Storage", DISPLAY_ERROR)) {
-      return false;
+      goto bail_out;
    }
 
 
    if (!send_run_before_and_after_commands(jcr)) {
-      return false;
+      goto bail_out;
    }
 
    /* Send backup command */
    bnet_fsend(fd, backupcmd);
    if (!response(jcr, fd, OKbackup, "backup", DISPLAY_ERROR)) {
-      return false;
+      goto bail_out;
    }
 
    /* Pickup Job termination data */
@@ -233,6 +233,14 @@ bool do_backup(JCR *jcr)
       return true;
    }     
    return false;
+
+/* Come here only after starting SD thread */
+bail_out:
+   set_jcr_job_status(jcr, JS_ErrorTerminated);
+   Dmsg1(400, "wait for sd. use=%d\n", jcr->use_count());
+   wait_for_storage_daemon_termination(jcr);
+   Dmsg1(400, "after wait for sd. use=%d\n", jcr->use_count());
+   return false;
 }