This patch corrects a Bacula crash after a "list nextvol" followed
by "list media".
It can be applied to 1.36.0 with:
cd <bacula-source>
patch -p0 <1.36.0-list.patch
make
make install
Index: src/dird/ua_output.c
===================================================================
RCS file: /cvsroot/bacula/bacula/src/dird/ua_output.c,v
retrieving revision 1.47
diff -u -r1.47 ua_output.c
--- src/dird/ua_output.c 19 Sep 2004 18:56:24 -0000 1.47
+++ src/dird/ua_output.c 13 Nov 2004 10:26:08 -0000
@@ -42,11 +42,11 @@
extern FILE *con_fd;
extern brwlock_t con_lock;
-
/* Imported functions */
/* Forward referenced functions */
static int do_list_cmd(UAContext *ua, const char *cmd, e_list_type llist);
+static bool list_nextvol(UAContext *ua);
/*
* Turn auto display of console messages on/off
@@ -401,58 +401,7 @@
/* List next volume */
} else if (strcasecmp(ua->argk[i], _("nextvol")) == 0 ||
strcasecmp(ua->argk[i], _("nextvolume")) == 0) {
- JOB *job;
- JCR *jcr = ua->jcr;
- POOL *pool;
- RUN *run;
- time_t runtime;
- bool found = false;
-
- i = find_arg_with_value(ua, "job");
- if (i <= 0) {
- if ((job = select_job_resource(ua)) == NULL) {
- return 1;
- }
- } else {
- job = (JOB *)GetResWithName(R_JOB, ua->argv[i]);
- if (!job) {
- Jmsg(jcr, M_ERROR, 0, _("%s is not a job name.\n"), ua->argv[i]);
- if ((job = select_job_resource(ua)) == NULL) {
- return 1;
- }
- }
- }
- for (run=NULL; (run = find_next_run(run, job, runtime)); ) {
- pool = run ? run->pool : NULL;
- if (!complete_jcr_for_job(jcr, job, pool)) {
- return 1;
- }
-
- if (!find_next_volume_for_append(jcr, &mr, 0)) {
- bsendmsg(ua, _("Could not find next Volume.\n"));
- if (jcr->db) {
- db_close_database(jcr, jcr->db);
- jcr->db = NULL;
- }
- return 1;
- } else {
- bsendmsg(ua, _("The next Volume to be used by Job \"%s\" will be %s\n"),
- job->hdr.name, mr.VolumeName);
- found = true;
- }
- if (jcr->db) {
- db_close_database(jcr, jcr->db);
- jcr->db = NULL;
- }
- }
- if (jcr->db) {
- db_close_database(jcr, jcr->db);
- jcr->db = NULL;
- }
- if (!found) {
- bsendmsg(ua, _("Could not find next Volume.\n"));
- }
- return 1;
+ list_nextvol(ua);
} else {
bsendmsg(ua, _("Unknown list keyword: %s\n"), NPRT(ua->argk[i]));
}
@@ -460,6 +409,57 @@
return 1;
}
+static bool list_nextvol(UAContext *ua)
+{
+ JOB *job;
+ JCR *jcr = ua->jcr;
+ POOL *pool;
+ RUN *run;
+ time_t runtime;
+ bool found = false;
+ MEDIA_DBR mr;
+
+ memset(&mr, 0, sizeof(mr));
+ int i = find_arg_with_value(ua, "job");
+ if (i <= 0) {
+ if ((job = select_job_resource(ua)) == NULL) {
+ return false;
+ }
+ } else {
+ job = (JOB *)GetResWithName(R_JOB, ua->argv[i]);
+ if (!job) {
+ Jmsg(jcr, M_ERROR, 0, _("%s is not a job name.\n"), ua->argv[i]);
+ if ((job = select_job_resource(ua)) == NULL) {
+ return false;
+ }
+ }
+ }
+ for (run=NULL; (run = find_next_run(run, job, runtime)); ) {
+ pool = run ? run->pool : NULL;
+ if (!complete_jcr_for_job(jcr, job, pool)) {
+ return false;
+ }
+
+ if (!find_next_volume_for_append(jcr, &mr, 0)) {
+ bsendmsg(ua, _("Could not find next Volume.\n"));
+ } else {
+ bsendmsg(ua, _("The next Volume to be used by Job \"%s\" will be %s\n"),
+ job->hdr.name, mr.VolumeName);
+ found = true;
+ }
+ if (jcr->db && jcr->db != ua->db) {
+ db_close_database(jcr, jcr->db);
+ jcr->db = NULL;
+ }
+ }
+ if (!found) {
+ bsendmsg(ua, _("Could not find next Volume.\n"));
+ return false;
+ }
+ return true;
+}
+
+
/*
* For a given job, we examine all his run records
* to see if it is scheduled today or tomorrow.
syntax highlighted by Code2HTML, v. 0.9.1