From: Kern Sibbald Date: Fri, 3 Dec 2004 21:00:19 +0000 (+0000) Subject: - Add user supplied patch to add inet_aton() of old Solaris X-Git-Tag: Release-7.0.0~9053 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=6626b6b08f100d80d291bc5b7b8a5a25716e340d;p=bacula%2Fbacula - Add user supplied patch to add inet_aton() of old Solaris systems. - Require pools to match before allowing multiple simultaneous accesses to same storage resource. - Add patch supplied by Martin to correct buffer overrun in bsnprintf() with no library snprintf(). git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@1738 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/kernstodo b/bacula/kernstodo index 14ebef85a8..29e7a2db57 100644 --- a/bacula/kernstodo +++ b/bacula/kernstodo @@ -40,6 +40,7 @@ Regression tests: 1.37 Possibilities: +- Browse generations of files. - Add offline command to Bacula console. - I've seen an error when my catalog's File table fills up. I then have to recreate the File table with a larger maximum row diff --git a/bacula/src/dird/jobq.c b/bacula/src/dird/jobq.c index 12e2c434c1..dd92d6ff31 100755 --- a/bacula/src/dird/jobq.c +++ b/bacula/src/dird/jobq.c @@ -40,6 +40,7 @@ #include "bacula.h" #include "dird.h" +extern JCR *jobs; /* Forward referenced functions */ extern "C" void *jobq_server(void *arg); @@ -47,6 +48,8 @@ extern "C" void *sched_wait(void *arg); static int start_server(jobq_t *jq); + + /* * Initialize a job queue * @@ -544,6 +547,7 @@ void *jobq_server(void *arg) for ( ; je; ) { /* je is current job item on the queue, jn is the next one */ JCR *jcr = je->jcr; + bool skip_this_jcr = false; jobq_item_t *jn = (jobq_item_t *)jq->waiting_jobs->next(je); Dmsg3(300, "Examining Job=%d JobPri=%d want Pri=%d\n", jcr->JobId, jcr->JobPriority, Priority); @@ -560,14 +564,40 @@ void *jobq_server(void *arg) jcr->store->MaxConcurrentJobs = 1; } else { set_jcr_job_status(jcr, JS_WaitStoreRes); - je = jn; + je = jn; /* point to next waiting job */ continue; } + /* We are not doing a Restore or Verify */ + } else if (jcr->store->NumConcurrentJobs == 0 && + jcr->store->NumConcurrentJobs < jcr->store->MaxConcurrentJobs) { + /* Simple case, first job */ + jcr->store->NumConcurrentJobs = 1; } else if (jcr->store->NumConcurrentJobs < jcr->store->MaxConcurrentJobs) { - jcr->store->NumConcurrentJobs++; - } else { + /* + * At this point, we already have at least one Job running + * for this Storage daemon, so we must ensure that there + * is no Volume conflict. In general, it should be OK, if + * all Jobs pull from the same Pool, so we check the Pools. + */ + JCR *njcr; + lock_jcr_chain(); + for (njcr=jobs; njcr; njcr=njcr->next) { + if (njcr->JobId == 0 || njcr == jcr) { + continue; + } + if (njcr->pool != jcr->pool) { + skip_this_jcr = true; + break; + } + } + unlock_jcr_chain(); + if (!skip_this_jcr) { + jcr->store->NumConcurrentJobs++; + } + } + if (skip_this_jcr) { set_jcr_job_status(jcr, JS_WaitStoreRes); - je = jn; + je = jn; /* point to next waiting job */ continue; } @@ -580,7 +610,7 @@ void *jobq_server(void *arg) jcr->store->MaxConcurrentJobs = jcr->saveMaxConcurrentJobs; } set_jcr_job_status(jcr, JS_WaitClientRes); - je = jn; + je = jn; /* point to next waiting job */ continue; } if (jcr->job->NumConcurrentJobs < jcr->job->MaxConcurrentJobs) { @@ -593,7 +623,7 @@ void *jobq_server(void *arg) } jcr->client->NumConcurrentJobs--; set_jcr_job_status(jcr, JS_WaitJobRes); - je = jn; + je = jn; /* Point to next waiting job */ continue; } /* Got all locks, now remove it from wait queue and append it @@ -603,7 +633,7 @@ void *jobq_server(void *arg) jq->waiting_jobs->remove(je); jq->ready_jobs->append(je); Dmsg1(300, "moved JobId=%d from wait to ready queue\n", je->jcr->JobId); - je = jn; + je = jn; /* Point to next waiting job */ } /* end for loop */ break; } /* end while loop */ diff --git a/bacula/src/lib/bnet.c b/bacula/src/lib/bnet.c index 54df1e66aa..bf8fe9d457 100644 --- a/bacula/src/lib/bnet.c +++ b/bacula/src/lib/bnet.c @@ -54,6 +54,19 @@ extern time_t watchdog_time; #endif +#ifdef HAVE_OLD_SOCKOPT +int inet_aton(const char *cp, struct in_addr *inp) +{ + struct in_addr inaddr; + + if((inaddr.s_addr = inet_addr(cp)) != INADDR_NONE) { + inp->s_addr = inaddr.s_addr; + return 1; + } + return 0; +} +#endif + /* * Read a nbytes from the network. * It is possible that the total bytes require in several diff --git a/bacula/src/lib/bsys.c b/bacula/src/lib/bsys.c index b0d6cb240c..088faad840 100644 --- a/bacula/src/lib/bsys.c +++ b/bacula/src/lib/bsys.c @@ -150,15 +150,16 @@ int bvsnprintf(char *str, int32_t size, const char *format, va_list ap) #else - int len; + int len, buflen; char *buf; - buf = get_memory(BIG_BUF); + buflen = size > BIG_BUF ? size : BIG_BUF; + buf = get_memory(buflen); len = vsprintf(buf, format, ap); - if (len >= BIG_BUF) { + if (len >= buflen) { Emsg0(M_ABORT, 0, _("Buffer overflow.\n")); } - memcpy(str, buf, size); - str[size-1] = 0; + memcpy(str, buf, len); + str[len] = 0; /* len excludes the null */ free_memory(buf); return len; #endif diff --git a/bacula/src/lib/jcr.c b/bacula/src/lib/jcr.c index ebbfd79275..596232df07 100755 --- a/bacula/src/lib/jcr.c +++ b/bacula/src/lib/jcr.c @@ -43,7 +43,7 @@ int num_jobs_run; dlist *last_jobs = NULL; const int max_last_jobs = 10; -static JCR *jobs = NULL; /* pointer to JCR chain */ +JCR *jobs = NULL; /* pointer to JCR chain */ static brwlock_t lock; /* lock for last jobs and JCR chain */ void init_last_jobs_list() diff --git a/bacula/src/version.h b/bacula/src/version.h index 0dcfe754d6..a17049247a 100644 --- a/bacula/src/version.h +++ b/bacula/src/version.h @@ -1,8 +1,8 @@ /* */ #undef VERSION #define VERSION "1.37.1" -#define BDATE "02 December 2004" -#define LSMDATE "02Dec04" +#define BDATE "03 December 2004" +#define LSMDATE "03Dec04" /* Debug flags */ #undef DEBUG