]> git.sur5r.net Git - bacula/bacula/commitdiff
Fix seg fault in jobq.c
authorKern Sibbald <kern@sibbald.com>
Tue, 22 Jul 2014 12:12:32 +0000 (14:12 +0200)
committerKern Sibbald <kern@sibbald.com>
Sat, 26 Jul 2014 08:47:08 +0000 (10:47 +0200)
bacula/src/dird/jobq.c

index f28c68124c6420f4cc15b5d9fb7b9d38c386f085..ddd33bea159601a993b6a5cba1b134b6c6eb659e 100644 (file)
@@ -460,7 +460,9 @@ void *jobq_server(void *arg)
          if (jcr->acquired_resource_locks) {
             dec_read_store(jcr);
             dec_write_store(jcr);
-            jcr->client->NumConcurrentJobs--;
+            if (jcr->client) {
+               jcr->client->NumConcurrentJobs--;
+            }
             jcr->job->NumConcurrentJobs--;
             jcr->acquired_resource_locks = false;
          }
@@ -772,14 +774,16 @@ static bool acquire_resources(JCR *jcr)
       return false;
    }
 
-   if (jcr->client->NumConcurrentJobs < jcr->client->MaxConcurrentJobs) {
-      jcr->client->NumConcurrentJobs++;
-   } else {
-      /* Back out previous locks */
-      dec_write_store(jcr);
-      dec_read_store(jcr);
-      jcr->setJobStatus(JS_WaitClientRes);
-      return false;
+   if (jcr->client) {
+      if (jcr->client->NumConcurrentJobs < jcr->client->MaxConcurrentJobs) {
+         jcr->client->NumConcurrentJobs++;
+      } else {
+         /* Back out previous locks */
+         dec_write_store(jcr);
+         dec_read_store(jcr);
+         jcr->setJobStatus(JS_WaitClientRes);
+         return false;
+      }
    }
    if (jcr->job->NumConcurrentJobs < jcr->job->MaxConcurrentJobs) {
       jcr->job->NumConcurrentJobs++;
@@ -787,7 +791,9 @@ static bool acquire_resources(JCR *jcr)
       /* Back out previous locks */
       dec_write_store(jcr);
       dec_read_store(jcr);
-      jcr->client->NumConcurrentJobs--;
+      if (jcr->client) {
+         jcr->client->NumConcurrentJobs--;
+      }
       jcr->setJobStatus(JS_WaitJobRes);
       return false;
    }