]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/dird/jobq.c
ebl Add comments
[bacula/bacula] / bacula / src / dird / jobq.c
old mode 100755 (executable)
new mode 100644 (file)
index 6246fcd..d811bda
@@ -20,7 +20,7 @@
 /*
    Bacula® - The Network Backup Solution
 
-   Copyright (C) 2003-2006 Free Software Foundation Europe e.V.
+   Copyright (C) 2003-2007 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.
@@ -495,7 +495,6 @@ void *jobq_server(void *arg)
          if (jcr->job->RescheduleOnError &&
              jcr->JobStatus != JS_Terminated &&
              jcr->JobStatus != JS_Canceled &&
-             jcr->job->RescheduleTimes > 0 &&
              jcr->JobType == JT_BACKUP &&
              (jcr->job->RescheduleTimes == 0 ||
               jcr->reschedule_count < jcr->job->RescheduleTimes)) {
@@ -559,10 +558,6 @@ void *jobq_server(void *arg)
             Dmsg0(2300, "Back from running new job.\n");
          }
          /* Clean up and release old jcr */
-         if (jcr->db) {
-            db_close_database(jcr, jcr->db);
-            jcr->db = NULL;
-         }
          Dmsg2(2300, "====== Termination job=%d use_cnt=%d\n", jcr->JobId, jcr->use_count());
          jcr->SDJobStatus = 0;
          V(jq->mutex);                /* release internal lock */
@@ -687,13 +682,14 @@ static bool acquire_resources(JCR *jcr)
    jcr->acquired_resource_locks = false;
    if (jcr->rstore) {
       Dmsg1(200, "Rstore=%s\n", jcr->rstore->name());
-      /* 
-       * Let only one Restore/verify job run at a time regardless
-       *   of MaxConcurrentJobs.
-       */ 
-      if (jcr->rstore->NumConcurrentJobs == 0) {
+      if (jcr->rstore->NumConcurrentJobs == 0 &&
+          jcr->rstore->NumConcurrentJobs < jcr->rstore->MaxConcurrentJobs) {
+         /* Simple case, first job */
          jcr->rstore->NumConcurrentJobs = 1;
          Dmsg0(200, "Set rncj=1\n");
+      } else if (jcr->rstore->NumConcurrentJobs < jcr->rstore->MaxConcurrentJobs) {
+         jcr->rstore->NumConcurrentJobs++;
+         Dmsg1(200, "Inc rncj=%d\n", jcr->rstore->NumConcurrentJobs);
       } else {
          Dmsg1(200, "Fail rncj=%d\n", jcr->rstore->NumConcurrentJobs);
          set_jcr_job_status(jcr, JS_WaitStoreRes);
@@ -704,7 +700,7 @@ static bool acquire_resources(JCR *jcr)
    if (jcr->wstore) {
       Dmsg1(200, "Wstore=%s\n", jcr->wstore->name());
       if (jcr->rstore == jcr->wstore) {           /* deadlock */
-         jcr->rstore->NumConcurrentJobs = 0;      /* back out rstore */
+         jcr->rstore->NumConcurrentJobs--;        /* back out rstore */
          Jmsg(jcr, M_FATAL, 0, _("Job canceled. Attempt to read and write same device.\n"
             "    Read storage \"%s\" (From %s) -- Write storage \"%s\" (From %s)\n"), 
             jcr->rstore->name(), jcr->rstore_source, jcr->wstore->name(), jcr->wstore_source);
@@ -720,7 +716,7 @@ static bool acquire_resources(JCR *jcr)
          jcr->wstore->NumConcurrentJobs++;
          Dmsg1(200, "Inc wncj=%d\n", jcr->wstore->NumConcurrentJobs);
       } else if (jcr->rstore) {
-         jcr->rstore->NumConcurrentJobs = 0;      /* back out rstore */
+         jcr->rstore->NumConcurrentJobs--;        /* back out rstore */
          Dmsg1(200, "Fail wncj=%d\n", jcr->wstore->NumConcurrentJobs);
          skip_this_jcr = true;
       } else {
@@ -742,7 +738,7 @@ static bool acquire_resources(JCR *jcr)
          Dmsg1(200, "Dec wncj=%d\n", jcr->wstore->NumConcurrentJobs);
       }
       if (jcr->rstore) {
-         jcr->rstore->NumConcurrentJobs = 0;
+         jcr->rstore->NumConcurrentJobs--;  
          Dmsg1(200, "Dec rncj=%d\n", jcr->rstore->NumConcurrentJobs);
       }
       set_jcr_job_status(jcr, JS_WaitClientRes);
@@ -757,7 +753,7 @@ static bool acquire_resources(JCR *jcr)
          Dmsg1(200, "Dec wncj=%d\n", jcr->wstore->NumConcurrentJobs);
       }
       if (jcr->rstore) {
-         jcr->rstore->NumConcurrentJobs = 0;
+         jcr->rstore->NumConcurrentJobs--;
          Dmsg1(200, "Dec rncj=%d\n", jcr->rstore->NumConcurrentJobs);
       }
       jcr->client->NumConcurrentJobs--;