]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/dird/restore.c
Add heap stats to Dir and SD -- eliminate #ifdefs
[bacula/bacula] / bacula / src / dird / restore.c
index 73e5c6b8e8cf477c5585f52eb71a22473d776506..e8b0da28f21723595d820602008ae5e0dacbdbf8 100644 (file)
@@ -19,7 +19,7 @@
  */
 
 /*
-   Copyright (C) 2000-2003 Kern Sibbald and John Walker
+   Copyright (C) 2000-2004 Kern Sibbald and John Walker
 
    This program is free software; you can redistribute it and/or
    modify it under the terms of the GNU General Public License as
@@ -73,8 +73,7 @@ int do_restore(JCR *jcr)
    }
 
    memset(&rjr, 0, sizeof(rjr));
-   jcr->jr.Level = 'F';            /* Full restore */
-   jcr->jr.StartTime = jcr->start_time;
+   jcr->jr.JobLevel = L_FULL;        /* Full restore */
    if (!db_update_job_start_record(jcr, jcr->db, &jcr->jr)) {
       Jmsg(jcr, M_ERROR, 0, "%s", db_strerror(jcr->db));
       restore_cleanup(jcr, JS_ErrorTerminated);
@@ -226,7 +225,8 @@ int do_restore(JCR *jcr)
 
    /* Send restore command */
    char replace, *where;
-
+   char empty = '\0';
+   
    if (jcr->replace != 0) {
       replace = jcr->replace;
    } else if (jcr->job->replace != 0) {
@@ -239,7 +239,7 @@ int do_restore(JCR *jcr)
    } else if (jcr->job->RestoreWhere) {
       where = jcr->job->RestoreWhere; /* no override take from job */
    } else {
-      where = "";                     /* None */
+      where = ∅                /* None */
    }
    jcr->prefix_links = jcr->job->PrefixLinks;
    bash_spaces(where);
@@ -265,9 +265,9 @@ int do_restore(JCR *jcr)
 static void restore_cleanup(JCR *jcr, int TermCode)
 {
    char sdt[MAX_TIME_LENGTH], edt[MAX_TIME_LENGTH];
-   char ec1[30], ec2[30];
+   char ec1[30], ec2[30], ec3[30];
    char term_code[100], fd_term_msg[100], sd_term_msg[100];
-   char *term_msg;
+   const char *term_msg;
    int msg_type;
    double kbps;
 
@@ -279,7 +279,11 @@ static void restore_cleanup(JCR *jcr, int TermCode)
    msg_type = M_INFO;                /* by default INFO message */
    switch (TermCode) {
    case JS_Terminated:
-      term_msg = _("Restore OK");
+      if (jcr->ExpectedFiles > jcr->jr.JobFiles) {
+         term_msg = _("Restore OK -- warning file count mismatch");
+      } else {
+         term_msg = _("Restore OK");
+      }
       break;
    case JS_FatalError:
    case JS_ErrorTerminated:
@@ -287,14 +291,18 @@ static void restore_cleanup(JCR *jcr, int TermCode)
       msg_type = M_ERROR;         /* Generate error message */
       if (jcr->store_bsock) {
         bnet_sig(jcr->store_bsock, BNET_TERMINATE);
-        pthread_cancel(jcr->SD_msg_chan);
+        if (jcr->SD_msg_chan) {
+           pthread_cancel(jcr->SD_msg_chan);
+        }
       }
       break;
    case JS_Canceled:
       term_msg = _("Restore Canceled");
       if (jcr->store_bsock) {
         bnet_sig(jcr->store_bsock, BNET_TERMINATE);
-        pthread_cancel(jcr->SD_msg_chan);
+        if (jcr->SD_msg_chan) {
+           pthread_cancel(jcr->SD_msg_chan);
+        }
       }
       break;
    default:
@@ -322,10 +330,11 @@ Job:                    %s\n\
 Client:                 %s\n\
 Start time:             %s\n\
 End time:               %s\n\
+Files Expected:         %s\n\
 Files Restored:         %s\n\
 Bytes Restored:         %s\n\
 Rate:                   %.1f KB/s\n\
-Non-fatal FD Errors:    %d\n\
+FD Errors:              %d\n\
 FD termination status:  %s\n\
 SD termination status:  %s\n\
 Termination:            %s\n\n"),
@@ -335,8 +344,9 @@ Termination:            %s\n\n"),
        jcr->client->hdr.name,
        sdt,
        edt,
-       edit_uint64_with_commas((uint64_t)jcr->jr.JobFiles, ec1),
-       edit_uint64_with_commas(jcr->jr.JobBytes, ec2),
+       edit_uint64_with_commas((uint64_t)jcr->ExpectedFiles, ec1),
+       edit_uint64_with_commas((uint64_t)jcr->jr.JobFiles, ec2),
+       edit_uint64_with_commas(jcr->jr.JobBytes, ec3),
        (float)kbps,
        jcr->Errors,
        fd_term_msg,