From: Kern Sibbald Date: Sat, 25 Oct 2003 16:55:17 +0000 (+0000) Subject: Fix DiskToCatalog seg fault X-Git-Tag: Release-1.34.0~359 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=4391516641bbc00bac24d1e53da173c95ed54f27;p=bacula%2Fbacula Fix DiskToCatalog seg fault git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@784 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/kernstodo b/bacula/kernstodo index 9770ef2b3d..f161f4a27c 100644 --- a/bacula/kernstodo +++ b/bacula/kernstodo @@ -38,6 +38,8 @@ For 1.33 Testing/Documentation: For 1.32c For 1.33 +- Automatically create pools, but instead of looking for what + in in Job records, walk through the pool resources. - Check and double check tree code, why does it take so long? - Upgrade to cygwin 1.5 - Fix time difference problem between Bacula and Client diff --git a/bacula/src/cats/sql_find.c b/bacula/src/cats/sql_find.c index 0939ce9e36..0e39ab2c3e 100644 --- a/bacula/src/cats/sql_find.c +++ b/bacula/src/cats/sql_find.c @@ -160,7 +160,8 @@ db_find_last_jobid(JCR *jcr, B_DB *mdb, char *Name, JOB_DBR *jr) db_lock(mdb); if (jr->Level == L_VERIFY_CATALOG) { Mmsg(&mdb->cmd, -"SELECT JobId FROM Job WHERE Type='V' AND Level='%c' AND Name='%s' AND " +"SELECT JobId FROM Job WHERE Type='V' AND Level='%c' AND " +" JobStatus='T' AND Name='%s' AND " "ClientId=%u ORDER BY StartTime DESC LIMIT 1", L_VERIFY_INIT, jr->Name, jr->ClientId); } else if (jr->Level == L_VERIFY_VOLUME_TO_CATALOG || @@ -170,8 +171,8 @@ db_find_last_jobid(JCR *jcr, B_DB *mdb, char *Name, JOB_DBR *jr) "SELECT JobId FROM Job WHERE Type='B' AND JobStatus='T' AND " "Name='%s' ORDER BY StartTime DESC LIMIT 1", Name); } else { - Mmsg(&mdb->cmd, -"SELECT JobId FROM Job WHERE Type='B' AND " + Mmsg(&mdb->cmd, +"SELECT JobId FROM Job WHERE Type='B' AND JobStatus='T' AND " "ClientId=%u ORDER BY StartTime DESC LIMIT 1", jr->ClientId); } } else { diff --git a/bacula/src/dird/verify.c b/bacula/src/dird/verify.c index fe868f6b36..f009332510 100644 --- a/bacula/src/dird/verify.c +++ b/bacula/src/dird/verify.c @@ -70,6 +70,10 @@ int do_verify(JCR *jcr) JobId_t verify_jobid = 0; int stat; + memset(&verify_jr, 0, sizeof(verify_jr)); + if (!jcr->verify_jr) { + jcr->verify_jr = &verify_jr; + } if (!get_or_create_client_record(jcr)) { goto bail_out; } @@ -133,7 +137,6 @@ int do_verify(JCR *jcr) if (jcr->JobLevel == L_VERIFY_CATALOG || jcr->JobLevel == L_VERIFY_VOLUME_TO_CATALOG || jcr->JobLevel == L_VERIFY_DISK_TO_CATALOG) { - memset(&verify_jr, 0, sizeof(verify_jr)); verify_jr.JobId = verify_jobid; if (!db_get_job_record(jcr, jcr->db, &verify_jr)) { Jmsg(jcr, M_FATAL, 0, _("Could not get job record for previous Job. ERR=%s"), @@ -207,7 +210,6 @@ int do_verify(JCR *jcr) jcr->fileset = jcr->job->verify_job->fileset; } Dmsg2(100, "ClientId=%u JobLevel=%c\n", verify_jr.ClientId, jcr->JobLevel); - jcr->verify_jr = &verify_jr; /* * OK, now connect to the File daemon @@ -404,7 +406,7 @@ static void verify_cleanup(JCR *jcr, int TermCode) jobstatus_to_ascii(jcr->FDJobStatus, fd_term_msg, sizeof(fd_term_msg)); if (jcr->JobLevel == L_VERIFY_VOLUME_TO_CATALOG) { - jobstatus_to_ascii(jcr->SDJobStatus, sd_term_msg, sizeof(sd_term_msg)); + jobstatus_to_ascii(jcr->SDJobStatus, sd_term_msg, sizeof(sd_term_msg)); Jmsg(jcr, msg_type, 0, _("Bacula " VERSION " (" LSMDATE "): %s\n\ JobId: %d\n\ Job: %s\n\ diff --git a/bacula/src/lib/util.c b/bacula/src/lib/util.c index 3e335fb4f1..29ff4bae37 100644 --- a/bacula/src/lib/util.c +++ b/bacula/src/lib/util.c @@ -145,7 +145,8 @@ int pm_strcpy(POOLMEM **pm, char *str) */ void jobstatus_to_ascii(int JobStatus, char *msg, int maxlen) { - char *termstat, jstat[2]; + char *termstat; + char buf[100]; switch (JobStatus) { case JS_Terminated: @@ -165,9 +166,12 @@ void jobstatus_to_ascii(int JobStatus, char *msg, int maxlen) termstat = _("Verify differences"); break; default: - jstat[0] = last_job.JobStatus; - jstat[1] = 0; - termstat = jstat; + if (JobStatus == 0) { + buf[0] = 0; + } else { + bsnprintf(buf, sizeof(buf), _("Unknown Job termination status=%d"), JobStatus); + } + termstat = buf; break; } bstrncpy(msg, termstat, maxlen);