]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/dird/job.c
Make migration work with new subroutine
[bacula/bacula] / bacula / src / dird / job.c
index 607835c7c596d43c6220814d89f875498065b760..339fb408440e625d7e7a5707915fecbdcad288a7 100644 (file)
@@ -90,7 +90,7 @@ bool setup_job(JCR *jcr)
 {
    int errstat;
 
-   P(jcr->mutex);
+   jcr->lock();
    sm_check(__FILE__, __LINE__, true);
    init_msg(jcr, jcr->messages);
 
@@ -102,6 +102,9 @@ bool setup_job(JCR *jcr)
    }
    jcr->term_wait_inited = true;
 
+   create_unique_job_name(jcr, jcr->job->hdr.name);
+   set_jcr_job_status(jcr, JS_Created);
+   jcr->unlock();
 
    /*
     * Open database
@@ -124,8 +127,6 @@ bool setup_job(JCR *jcr)
    /*
     * Create Job record
     */
-   create_unique_job_name(jcr, jcr->job->hdr.name);
-   set_jcr_job_status(jcr, JS_Created);
    init_jcr_job_record(jcr);
    if (!db_create_job_record(jcr, jcr->db, &jcr->jr)) {
       Jmsg(jcr, M_FATAL, 0, "%s", db_strerror(jcr->db));
@@ -148,7 +149,6 @@ bool setup_job(JCR *jcr)
    Dmsg0(200, "Add jrc to work queue\n");
 
 
-   V(jcr->mutex);
    return true;
 
 bail_out:
@@ -156,7 +156,6 @@ bail_out:
       free_memory(jcr->fname);
       jcr->fname = NULL;
    }
-   V(jcr->mutex);
    return false;
 }
 
@@ -266,7 +265,19 @@ static void *job_thread(void *arg)
             goto bail_out;
          }
       }
-
+      /*
+       * We re-update the job start record so that the start
+       *  time is set after the run before job.  This avoids
+       *  that any files created by the run before job will
+       *  be saved twice.  They will be backed up in the current
+       *  job, but not in the next one unless they are changed.
+       *  Without this, they will be backed up in this job and
+       *  in the next job run because in that case, their date
+       *   is after the start of this run.
+       */
+      if (!db_update_job_start_record(jcr, jcr->db, &jcr->jr)) {
+         Jmsg(jcr, M_FATAL, 0, "%s", db_strerror(jcr->db));
+      }
       generate_job_event(jcr, "JobRun");
 
       switch (jcr->JobType) {
@@ -784,10 +795,6 @@ void dird_free_jcr_pointers(JCR *jcr)
       free_pool_memory(jcr->client_uname);
       jcr->client_uname = NULL;
    }
-   if (jcr->term_wait_inited) {
-      pthread_cond_destroy(&jcr->term_wait);
-      jcr->term_wait_inited = false;
-   }
    if (jcr->attr) {
       free_pool_memory(jcr->attr);
       jcr->attr = NULL;
@@ -808,6 +815,10 @@ void dird_free_jcr(JCR *jcr)
    Dmsg0(200, "Start dird free_jcr\n");
 
    dird_free_jcr_pointers(jcr);
+   if (jcr->term_wait_inited) {
+      pthread_cond_destroy(&jcr->term_wait);
+      jcr->term_wait_inited = false;
+   }
 
    /* Delete lists setup to hold storage pointers */
    if (jcr->storage) {
@@ -968,15 +979,8 @@ bool create_restore_bootstrap_file(JCR *jcr)
       free_bsr(rx.bsr);
       return false;
    }
-   if (jcr->RestoreBootstrap) {
-      free(jcr->RestoreBootstrap);
-   }
-   POOLMEM *fname = get_pool_memory(PM_MESSAGE);
-   make_unique_restore_filename(ua, &fname);
-   jcr->RestoreBootstrap = bstrdup(fname);
    free_ua_context(ua);
    free_bsr(rx.bsr);
-   free_pool_memory(fname);
    jcr->needs_sd = true;
    return true;
 }