]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/dird/job.c
Apply Eric's next-beta.patch that enables 64 bit FileIds and
[bacula/bacula] / bacula / src / dird / job.c
index c3ab10c3b1a07fe6cf0a8ad31e50341a079c329a..d70e589226f920e607ffb869910b9cd01b979180 100644 (file)
@@ -173,6 +173,8 @@ bool setup_job(JCR *jcr)
        jcr->JobId, jcr->Job, jcr->jr.JobType, jcr->jr.JobLevel);
 
    generate_daemon_event(jcr, "JobStart");
+   new_plugins(jcr);                  /* instantiate plugins for this jcr */
+   generate_plugin_event(jcr, bEventJobStart);
 
    if (job_canceled(jcr)) {
       goto bail_out;
@@ -228,6 +230,7 @@ bool setup_job(JCR *jcr)
    }
 
    generate_job_event(jcr, "JobInit");
+   generate_plugin_event(jcr, bEventJobInit);
    Dsm_check(1);
    return true;
 
@@ -300,6 +303,7 @@ static void *job_thread(void *arg)
       Jmsg(jcr, M_FATAL, 0, "%s", db_strerror(jcr->db));
    }
    generate_job_event(jcr, "JobRun");
+   generate_plugin_event(jcr, bEventJobRun);
 
    switch (jcr->get_JobType()) {
    case JT_BACKUP:
@@ -351,6 +355,7 @@ static void *job_thread(void *arg)
    }
 
    generate_daemon_event(jcr, "JobEnd");
+   generate_plugin_event(jcr, bEventJobEnd);
    Dmsg1(50, "======== End Job stat=%c ==========\n", jcr->JobStatus);
    sm_check(__FILE__, __LINE__, true);
    return NULL;
@@ -855,6 +860,7 @@ void update_job_end_record(JCR *jcr)
    jcr->jr.JobStatus = jcr->JobStatus;
    jcr->jr.JobFiles = jcr->JobFiles;
    jcr->jr.JobBytes = jcr->JobBytes;
+   jcr->jr.ReadBytes = jcr->ReadBytes;
    jcr->jr.VolSessionId = jcr->VolSessionId;
    jcr->jr.VolSessionTime = jcr->VolSessionTime;
    jcr->jr.JobErrors = jcr->Errors;
@@ -1026,6 +1032,8 @@ void dird_free_jcr(JCR *jcr)
    if (jcr->JobId != 0)
       write_state_file(director->working_directory, "bacula-dir", get_first_port_host_order(director->DIRaddrs));
 
+   free_plugins(jcr);                 /* release instantiated plugins */
+
    Dmsg0(200, "End dird free_jcr\n");
 }
 
@@ -1357,20 +1365,25 @@ bool create_restore_bootstrap_file(JCR *jcr)
    rx.JobIds = (char *)"";                       
    rx.bsr->JobId = jcr->previous_jr.JobId;
    ua = new_ua_context(jcr);
-   complete_bsr(ua, rx.bsr);
+   if (!complete_bsr(ua, rx.bsr)) {
+      goto bail_out;
+   }
    rx.bsr->fi = new_findex();
    rx.bsr->fi->findex = 1;
    rx.bsr->fi->findex2 = jcr->previous_jr.JobFiles;
    jcr->ExpectedFiles = write_bsr_file(ua, rx);
    if (jcr->ExpectedFiles == 0) {
-      free_ua_context(ua);
-      free_bsr(rx.bsr);
-      return false;
+      goto bail_out;
    }
    free_ua_context(ua);
    free_bsr(rx.bsr);
    jcr->needs_sd = true;
    return true;
+
+bail_out:
+   free_ua_context(ua);
+   free_bsr(rx.bsr);
+   return false;
 }
 
 /* TODO: redirect command ouput to job log */