]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
Fix #7168 About incorrect start time displayed for canceled jobs not yet running
authorEric Bollengier <eric@baculasystems.com>
Tue, 15 Dec 2020 14:52:32 +0000 (15:52 +0100)
committerEric Bollengier <eric@baculasystems.com>
Thu, 24 Mar 2022 08:02:58 +0000 (09:02 +0100)
All the jobs that are canceled while they are still in the run queue (duplicate)
are not reporting the start time correctly.

Example:

  Scheduled time:         10-Dec-2020 13:15:01
  Start time:             01-Jan-1970 01:00:00
  End time:               10-Dec-2020 13:15:01
  Elapsed time:           50 years 11 months 26 days 13 hours 15 mins 1 sec

The fix will display an empty start time

  Scheduled time:         10-Dec-2020 13:15:01
  Start time:
  End time:               10-Dec-2020 13:15:01
  Elapsed time:           1 sec

bacula/src/dird/admin.c
bacula/src/dird/backup.c
bacula/src/dird/mac.c
bacula/src/dird/restore.c
bacula/src/dird/verify.c
bacula/src/lib/btime.c
bacula/src/lib/btime.h

index e05cb2af0d730a8536596965ab662cbb3ee93726..08f296cff073b2180dbcc0637bdb56adac0d155a 100644 (file)
@@ -103,9 +103,9 @@ void admin_cleanup(JCR *jcr, int TermCode)
       sprintf(term_code, _("Inappropriate term code: %c\n"), jcr->JobStatus);
       break;
    }
-   bstrftimes(schedt, sizeof(schedt), jcr->jr.SchedTime);
-   bstrftimes(sdt, sizeof(sdt), jcr->jr.StartTime);
-   bstrftimes(edt, sizeof(edt), jcr->jr.EndTime);
+   bstrftimes_na(schedt, sizeof(schedt), jcr->jr.SchedTime);
+   bstrftimes_na(sdt, sizeof(sdt), jcr->jr.StartTime);
+   bstrftimes_na(edt, sizeof(edt), jcr->jr.EndTime);
 
 
    Jmsg(jcr, msg_type, 0, _("Bacula " VERSION " (" LSMDATE "): %s\n"
index 32ee45406c993694b3449bf53121fe71283dab20..65d1ba05496e9e281cda6a16355d1c1fb86b104a 100644 (file)
@@ -983,11 +983,11 @@ void backup_cleanup(JCR *jcr, int TermCode)
          Mmsg(term_msg, _("Inappropriate term code: %c\n"), jcr->JobStatus);
          break;
    }
-   bstrftimes(schedt, sizeof(schedt), jcr->jr.SchedTime);
-   bstrftimes(sdt, sizeof(sdt), jcr->jr.StartTime);
-   bstrftimes(edt, sizeof(edt), jcr->jr.EndTime);
+   bstrftimes_na(schedt, sizeof(schedt), jcr->jr.SchedTime);
+   bstrftimes_na(sdt, sizeof(sdt), jcr->jr.StartTime);
+   bstrftimes_na(edt, sizeof(edt), jcr->jr.EndTime);
    RunTime = jcr->jr.EndTime - jcr->jr.StartTime;
-   if (RunTime <= 0) {
+   if (jcr->jr.StartTime == 0 || RunTime <= 0) {
       RunTime = 1;
    }
    kbps = ((double)jcr->jr.JobBytes) / (1000.0 * (double)RunTime);
index d40d198ac7f8151b77c4bc809a12cd0ad900e28a..f49b8508e6aabcd29964ac49aac86e86e8764c27 100644 (file)
@@ -869,10 +869,10 @@ void mac_cleanup(JCR *jcr, int TermCode, int writeTermCode)
    }
 
    Mmsg(term_code, term_msg.c_str(), jcr->get_OperationName(), jcr->get_ActionName(0));
-   bstrftimes(sdt, sizeof(sdt), jcr->jr.StartTime);
-   bstrftimes(edt, sizeof(edt), jcr->jr.EndTime);
+   bstrftimes_na(sdt, sizeof(sdt), jcr->jr.StartTime);
+   bstrftimes_na(edt, sizeof(edt), jcr->jr.EndTime);
    RunTime = jcr->jr.EndTime - jcr->jr.StartTime;
-   if (RunTime <= 0) {
+   if (jcr->jr.StartTime == 0 || RunTime <= 0) {
       RunTime = 1;
    }
    kbps = (double)jcr->SDJobBytes / (1000.0 * (double)RunTime);
index 0f2c058c317d8a90fd52b6bc51e557a958a55717..f5e562ddb9e5962d21032d6a7ac45281f2d41599 100644 (file)
@@ -703,11 +703,11 @@ void restore_cleanup(JCR *jcr, int TermCode)
       sprintf(term_code, _("Inappropriate term code: %c\n"), TermCode);
       break;
    }
-   bstrftimes(sdt, sizeof(sdt), jcr->jr.StartTime);
-   bstrftimes(edt, sizeof(edt), jcr->jr.EndTime);
+   bstrftimes_na(sdt, sizeof(sdt), jcr->jr.StartTime);
+   bstrftimes_na(edt, sizeof(edt), jcr->jr.EndTime);
 
    RunTime = jcr->jr.EndTime - jcr->jr.StartTime;
-   if (RunTime <= 0) {
+   if (jcr->jr.StartTime == 0 || RunTime <= 0) {
       RunTime = 1;
    }
    kbps = (double)jcr->jr.JobBytes / (1000.0 * (double)RunTime);
index 6100255ef24714fb40ecee9187ede16caad2379b..287f584bafe2ea8578dfd9a8379aafdcb1734771 100644 (file)
@@ -496,9 +496,12 @@ void verify_cleanup(JCR *jcr, int TermCode)
                 _("Inappropriate term code: %d %c\n"), TermCode, TermCode);
       break;
    }
-   bstrftimes(sdt, sizeof(sdt), jcr->jr.StartTime);
-   bstrftimes(edt, sizeof(edt), jcr->jr.EndTime);
+   bstrftimes_na(sdt, sizeof(sdt), jcr->jr.StartTime);
+   bstrftimes_na(edt, sizeof(edt), jcr->jr.EndTime);
    RunTime = jcr->jr.EndTime - jcr->jr.StartTime;
+   if (jcr->jr.StartTime == 0 || RunTime <= 0) {
+      RunTime = 1;
+   }
    if (jcr->verify_job) {
       Name = jcr->verify_job->hdr.name;
    } else {
index 50020483445ebaa42ad2819e484bc7a5b1efc977..3933012919592e7a4cae1fe8e4e5b31a133658e2 100644 (file)
@@ -65,6 +65,15 @@ char *bstrftime(char *dt, int maxlen, utime_t utime)
    return dt;
 }
 
+char *bstrftimes_na(char *dt, int maxlen, utime_t utime)
+{
+   if (utime == 0) {
+      return bstrncpy(dt, "", maxlen);
+   } else {
+      return bstrftimes(dt, maxlen, utime);
+   }
+}
+
 /* Formatted time for user display: dd-Mon-yyyy hh:mm:ss */
 char *bstrftimes(char *dt, int maxlen, utime_t utime)
 {
index 8a618d851743cbfaa21f56099dbdb47dfa566b81..3e3579515f892af844fc882e1fbabf0c9a685c0f 100644 (file)
@@ -43,6 +43,7 @@ char *bstrftime_nc(char *dt, int maxlen, utime_t tim);
 char *bstrftime_dn(char *dt, int maxlen, utime_t tim);
 char *bstrftime_c(char *dt, int maxlen, utime_t utime);
 utime_t str_to_utime(char *str);
+char *bstrftimes_na(char *dt, int maxlen, utime_t utime);
 
 
 /* =========================================================== */