]> git.sur5r.net Git - bacula/bacula/commitdiff
Fix race in director job start which was allowing the number of concurrent jobs to...
authorJames Harper <james.harper@bendigoit.com.au>
Wed, 20 May 2009 00:14:13 +0000 (00:14 +0000)
committerJames Harper <james.harper@bendigoit.com.au>
Wed, 20 May 2009 00:14:13 +0000 (00:14 +0000)
git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@8848 91ce42f0-d328-0410-95d8-f526ca767f89

bacula/src/dird/jobq.c

index d08d6bcde13be3c5d632917334ee18e6f424502d..8e93945ac944bdc035f91736cdbc364faf5af81d 100644 (file)
@@ -358,8 +358,10 @@ static int start_server(jobq_t *jq)
       Dmsg0(2300, "Create worker thread\n");
       /* No idle threads so create a new one */
       set_thread_concurrency(jq->max_workers + 1);
+      jq->num_workers++;
       if ((stat = pthread_create(&id, &jq->attr, jobq_server, (void *)jq)) != 0) {
          berrno be;
+         jq->num_workers--;
          Jmsg1(NULL, M_ERROR, 0, _("pthread_create: ERR=%s\n"), be.bstrerror(stat));
          return stat;
       }
@@ -386,7 +388,6 @@ void *jobq_server(void *arg)
    set_jcr_in_tsd(INVALID_JCR);
    Dmsg0(2300, "Start jobq_server\n");
    P(jq->mutex);
-   jq->num_workers++;
 
    for (;;) {
       struct timeval tv;