From: James Harper Date: Wed, 20 May 2009 00:14:13 +0000 (+0000) Subject: Fix race in director job start which was allowing the number of concurrent jobs to... X-Git-Tag: Release-3.0.2~218 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=07197703a94cdac1ccb41128a7a464df7be2dbd3;p=bacula%2Fbacula Fix race in director job start which was allowing the number of concurrent jobs to exceed the maximum git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@8848 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/src/dird/jobq.c b/bacula/src/dird/jobq.c index d08d6bcde1..8e93945ac9 100644 --- a/bacula/src/dird/jobq.c +++ b/bacula/src/dird/jobq.c @@ -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;