]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/stored/spool.c
Correct dvd code that breaks tape labeling
[bacula/bacula] / bacula / src / stored / spool.c
index 5923279c02cf3437c9b4799f136b710f72825bc4..f64d0c0930a5419b7faa5d27a13468d067544d0a 100644 (file)
@@ -62,21 +62,31 @@ enum {
    RB_OK
 };
 
-void list_spool_stats(BSOCK *bs)
+void list_spool_stats(void sendit(const char *msg, int len, void *sarg), void *arg)
 {
-   char ed1[30], ed2[30];
+   char *msg, ed1[30], ed2[30];
+   int len;
+
+   msg = (char *)get_pool_memory(PM_MESSAGE);
+
    if (spool_stats.data_jobs || spool_stats.max_data_size) {
-      bnet_fsend(bs, _("Data spooling: %u active jobs, %s bytes; %u total jobs, %s max bytes/job.\n"),
+      len = Mmsg(msg, _("Data spooling: %u active jobs, %s bytes; %u total jobs, %s max bytes/job.\n"),
          spool_stats.data_jobs, edit_uint64_with_commas(spool_stats.data_size, ed1),
          spool_stats.total_data_jobs,
          edit_uint64_with_commas(spool_stats.max_data_size, ed2));
+
+      sendit(msg, len, arg);
    }
    if (spool_stats.attr_jobs || spool_stats.max_attr_size) {
-      bnet_fsend(bs, _("Attr spooling: %u active jobs, %s bytes; %u total jobs, %s max bytes.\n"),
+      len = Mmsg(msg, _("Attr spooling: %u active jobs, %s bytes; %u total jobs, %s max bytes.\n"),
          spool_stats.attr_jobs, edit_uint64_with_commas(spool_stats.attr_size, ed1),
          spool_stats.total_attr_jobs,
          edit_uint64_with_commas(spool_stats.max_attr_size, ed2));
+   
+      sendit(msg, len, arg);
    }
+
+   free_pool_memory(msg);
 }
 
 bool begin_data_spool(DCR *dcr)
@@ -237,7 +247,8 @@ static bool despool_data(DCR *dcr, bool commit)
    Dmsg1(800, "read/write block size = %d\n", block->buf_len);
    lseek(rdcr->spool_fd, 0, SEEK_SET); /* rewind */
 
-   time_t despool_start = time(NULL);
+   /* Add run time, to get current wait time */
+   time_t despool_start = time(NULL) - jcr->run_time;
 
    for ( ; ok; ) {
       if (job_canceled(jcr)) {
@@ -259,14 +270,16 @@ static bool despool_data(DCR *dcr, bool commit)
       Dmsg3(800, "Write block ok=%d FI=%d LI=%d\n", ok, block->FirstIndex, block->LastIndex);
    }
 
-   time_t despool_elapsed = time(NULL) - despool_start;
+   /* Subtracting run_time give us elapsed time - wait_time since we started despooling */
+   time_t despool_elapsed = time(NULL) - despool_start - jcr->run_time;
 
-   if (despool_elapsed == 0)
+   if (despool_elapsed <= 0) {
       despool_elapsed = 1;
+   }
 
    Jmsg(dcr->jcr, M_INFO, 0, _("Despooling elapsed time = %02d:%02d:%02d, Transfer rate = %s bytes/second\n"),
          despool_elapsed / 3600, despool_elapsed % 3600 / 60, despool_elapsed % 60,
-         edit_uint64_with_commas(jcr->dcr->job_spool_size / despool_elapsed, ec1));
+         edit_uint64_with_suffix(jcr->dcr->job_spool_size / despool_elapsed, ec1));
 
    dcr->block = block;                /* reset block */