]> git.sur5r.net Git - bacula/bacula/commitdiff
See kes-1.33; restore fixes, cleanups, must update regress
authorKern Sibbald <kern@sibbald.com>
Wed, 24 Dec 2003 20:26:29 +0000 (20:26 +0000)
committerKern Sibbald <kern@sibbald.com>
Wed, 24 Dec 2003 20:26:29 +0000 (20:26 +0000)
git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@948 91ce42f0-d328-0410-95d8-f526ca767f89

18 files changed:
bacula/ReleaseNotes
bacula/kernstodo
bacula/src/dird/job.c
bacula/src/dird/jobq.c
bacula/src/dird/sql_cmds.c
bacula/src/dird/ua_restore.c
bacula/src/dird/ua_status.c
bacula/src/filed/status.c
bacula/src/lib/alist.c
bacula/src/lib/dlist.c
bacula/src/lib/dlist.h
bacula/src/lib/htable.c
bacula/src/lib/htable.h
bacula/src/lib/jcr.c
bacula/src/lib/watchdog.c
bacula/src/stored/status.c
bacula/src/stored/stored_conf.c
bacula/src/version.h

index f633048a07f13142b93a3f3b34b4cde9b6df388d..a3b0b1964092b9c45563e23ed5b2d9a9350437c7 100644 (file)
@@ -1,7 +1,7 @@
 
           Release Notes for Bacula 1.33
 
-  Bacula code: Total files = 271 Total lines = 82,422 (*.h *.c *.in)
+  Bacula code: Total files = 281 Total lines = 83,612 (*.h *.c *.in)
 
 Most Significant Changes since 1.32d
 - Implement "update slots scan" that reads the volume label(s).
index 8bfbd778e2bbd80a019045beb61e607bdbf13435..557c2e54932cf3da9bac8ab36629e64a3aa35853 100644 (file)
@@ -55,16 +55,13 @@ For 1.33 Testing/Documentation:
 - Add subsections to the Disaster Recovery index section.
                 
 For 1.33
+- Release SQLite 2.8.8
 - If a tape is recycled while it is mounted, Stanislav Tvrudy must do an
   additional mount to deblock the job.
-- Notes for integrating Nic's code:
-  - Most likely jcr crash is the free_jcr(). The ref count was not incremented
-    in the watchdog call to cancel_job() as it is in the UA -- see
-    dird/job.c.
-  - The ua->jcr = control_jcr in job_monitor_watchdog() dird/job.c doesn't
-    look right.
-  - Add: fd->timer_start = 0;   /* turn off timer */
-    just before "fd->timed_out = TRUE;"in lib/jcr.c jcr_timeout_check.
+- Notes for final checking of Nic's code:
+  Could I get you to double check the switch () statements in the
+  job_check_maxwaittime and job_check_maxruntime functions in
+  src/dird/job.c?
 - In restore, provide option for limiting to a particular Pool.
 - In restore, list FileSets that only have different base names --
   i.e. any FileSet with the same name should be treated as the same.
index 1d3fd12096251f74e4319a9930eca6ebddcf410b..4e7e4d9a3b93aaa5e28250541b8201383fe3f11d 100644 (file)
@@ -124,6 +124,10 @@ static void job_monitor_watchdog(watchdog_t *self)
    unlock_jcr_chain();
 }
 
+/*
+ * Check if the maxwaittime has expired and it is possible
+ *  to cancel the job.
+ */
 static bool job_check_maxwaittime(JCR *control_jcr, JCR *jcr)
 {
    bool cancel = false;
@@ -140,41 +144,42 @@ static bool job_check_maxwaittime(JCR *control_jcr, JCR *jcr)
          "checking status\n",
         jcr->JobId, jcr->Job, jcr->job->MaxWaitTime);
    switch (jcr->JobStatus) {
-      case JS_Created:
-      case JS_Blocked:
+   case JS_Created:
+   case JS_Blocked:
+   case JS_WaitFD:
+   case JS_WaitSD:
+   case JS_WaitStoreRes:
+   case JS_WaitClientRes:
+   case JS_WaitJobRes:
+   case JS_WaitPriority:
+   case JS_WaitMaxJobs:
+   case JS_WaitStartTime:
+      cancel = true;
+      Dmsg0(200, "JCR blocked in #1\n");
+      break;
+   case JS_Running:
+      Dmsg0(200, "JCR running, checking SD status\n");
+      switch (jcr->SDJobStatus) {
+      case JS_WaitMount:
+      case JS_WaitMedia:
       case JS_WaitFD:
-      case JS_WaitSD:
-      case JS_WaitStoreRes:
-      case JS_WaitClientRes:
-      case JS_WaitJobRes:
-      case JS_WaitPriority:
-      case JS_WaitMaxJobs:
-      case JS_WaitStartTime:
         cancel = true;
-         Dmsg0(200, "JCR blocked in #1\n");
-        break;
-      case JS_Running:
-         Dmsg0(200, "JCR running, checking SD status\n");
-        switch (jcr->SDJobStatus) {
-           case JS_WaitMount:
-           case JS_WaitMedia:
-           case JS_WaitFD:
-              cancel = true;
-               Dmsg0(200, "JCR blocked in #2\n");
-              break;
-           default:
-               Dmsg0(200, "JCR not blocked in #2\n");
-              break;
-        }
-        break;
-      case JS_Terminated:
-      case JS_ErrorTerminated:
-      case JS_Canceled:
-         Dmsg0(200, "JCR already dead in #3\n");
+         Dmsg0(200, "JCR blocked in #2\n");
         break;
       default:
-         Emsg1(M_ABORT, 0, _("Unhandled job status code %d\n"),
-              jcr->JobStatus);
+         Dmsg0(200, "JCR not blocked in #2\n");
+        break;
+      }
+      break;
+   case JS_Terminated:
+   case JS_ErrorTerminated:
+   case JS_Canceled:
+   case JS_FatalError:
+      Dmsg0(200, "JCR already dead in #3\n");
+      break;
+   default:
+      Jmsg1(jcr, M_ERROR, 0, _("Unhandled job status code %d\n"),
+           jcr->JobStatus);
    }
    Dmsg3(200, "MaxWaitTime result: %scancel JCR %p (%s)\n",
          cancel ? "" : "do not ", jcr, jcr->job);
@@ -182,6 +187,10 @@ static bool job_check_maxwaittime(JCR *control_jcr, JCR *jcr)
    return cancel;
 }
 
+/*
+ * Check if maxruntime has expired and if the job can be
+ *   canceled.
+ */
 static bool job_check_maxruntime(JCR *control_jcr, JCR *jcr)
 {
    bool cancel = false;
@@ -196,27 +205,29 @@ static bool job_check_maxruntime(JCR *control_jcr, JCR *jcr)
    }
 
    switch (jcr->JobStatus) {
-      case JS_Created:
-      case JS_Blocked:
-      case JS_WaitFD:
-      case JS_WaitSD:
-      case JS_WaitStoreRes:
-      case JS_WaitClientRes:
-      case JS_WaitJobRes:
-      case JS_WaitPriority:
-      case JS_WaitMaxJobs:
-      case JS_WaitStartTime:
-      case JS_Running:
-        cancel = true;
-        break;
-      case JS_Terminated:
-      case JS_ErrorTerminated:
-      case JS_Canceled:
-        cancel = false;
-        break;
-      default:
-         Emsg1(M_ABORT, 0, _("Unhandled job status code %d\n"),
-              jcr->JobStatus);
+   case JS_Created:
+   case JS_Running:
+   case JS_Blocked:
+   case JS_WaitFD:
+   case JS_WaitSD:
+   case JS_WaitStoreRes:
+   case JS_WaitClientRes:
+   case JS_WaitJobRes:
+   case JS_WaitPriority:
+   case JS_WaitMaxJobs:
+   case JS_WaitStartTime:
+   case JS_Differences:
+      cancel = true;
+      break;
+   case JS_Terminated:
+   case JS_ErrorTerminated:
+   case JS_Canceled:
+   case JS_FatalError:
+      cancel = false;
+      break;
+   default:
+      Jmsg1(jcr, M_ERROR, 0, _("Unhandled job status code %d\n"),
+           jcr->JobStatus);
    }
 
    Dmsg3(200, "MaxRunTime result: %scancel JCR %p (%s)\n",
index b5026918aaf4c6cccadaa8fdfe98eace6be2c961..1d98d955352ffe2ecef4d4167da6704b9253c105 100755 (executable)
@@ -233,7 +233,7 @@ int jobq_add(jobq_t *jq, JCR *jcr)
       Dmsg1(100, "Prepended job=%d to ready queue\n", jcr->JobId);
    } else {
       /* Add this job to the wait queue in priority sorted order */
-      for (li=NULL; (li=(jobq_item_t *)jq->waiting_jobs->next(li)); ) {
+      foreach_dlist (li, jq->waiting_jobs) {
          Dmsg2(100, "waiting item jobid=%d priority=%d\n",
            li->jcr->JobId, li->jcr->JobPriority);
         if (li->jcr->JobPriority > jcr->JobPriority) {
@@ -283,7 +283,7 @@ int jobq_remove(jobq_t *jq, JCR *jcr)
       return stat;
    }
 
-   for (item=NULL; (item=(jobq_item_t *)jq->waiting_jobs->next(item)); ) {
+   foreach_dlist (item, jq->waiting_jobs) {
       if (jcr == item->jcr) {
         found = true;
         break;
index 59265c37784610d61edf6eb7260bc4e62bea3218..610aa8a9d1735f0b41d4870db5eaea67b6fecfe6 100644 (file)
@@ -223,13 +223,14 @@ char *uar_create_temp1 =
 
 char *uar_last_full =
    "INSERT INTO temp1 SELECT Job.JobId,JobTdate "
-   "FROM Client,Job,JobMedia,Media WHERE Client.ClientId=%u "
+   "FROM Client,Job,JobMedia,Media,FileSet WHERE Client.ClientId=%u "
    "AND Job.ClientId=%u "
    "AND Job.StartTime<'%s' "
    "AND Level='F' AND JobStatus='T' "
    "AND JobMedia.JobId=Job.JobId "
    "AND JobMedia.MediaId=Media.MediaId "
-   "AND Job.FileSetId=%u "
+   "AND Job.FileSetId=FileSet.FileSetId "
+   "AND FileSet.FileSet='%s' "
    "ORDER BY Job.JobTDate DESC LIMIT 1";
 
 char *uar_full = 
@@ -245,13 +246,14 @@ char *uar_inc_dec =
    "INSERT INTO temp SELECT Job.JobId,Job.JobTDate,Job.ClientId,"
    "Job.Level,Job.JobFiles,Job.StartTime,Media.VolumeName,JobMedia.StartFile,"
    "Job.VolSessionId,Job.VolSessionTime "
-   "FROM Job,JobMedia,Media "
+   "FROM Job,JobMedia,Media,FileSet "
    "WHERE Job.JobTDate>%s AND Job.StartTime<'%s' "
    "AND Job.ClientId=%u "
    "AND JobMedia.JobId=Job.JobId "
    "AND JobMedia.MediaId=Media.MediaId "
    "AND Job.Level IN ('I', 'D') AND JobStatus='T' "
-   "AND Job.FileSetId=%u ";
+   "AND Job.FileSetId=FileSet.FileSetId "
+   "AND FileSet.FileSet='%s' ";
 
 char *uar_list_temp = 
    "SELECT JobId,Level,JobFiles,StartTime,VolumeName,StartFile,"
@@ -263,12 +265,12 @@ char *uar_sel_jobid_temp = "SELECT JobId FROM temp";
 
 char *uar_sel_all_temp1 = "SELECT * FROM temp1";
 
-/* Select filesets for this Client */
+/* Select FileSet names for this Client */
 char *uar_sel_fileset = 
-   "SELECT DISTINCT FileSet.FileSetId,FileSet.FileSet,FileSet.CreateTime FROM Job,"
+   "SELECT DISTINCT FileSet.FileSet FROM Job,"
    "Client,FileSet WHERE Job.FileSetId=FileSet.FileSetId "
    "AND Job.ClientId=%u AND Client.ClientId=%u "
-   "ORDER BY FileSet.CreateTime";
+   "ORDER BY FileSet.FileSet";
 
 /* Find MediaType used by this Job */
 char *uar_mediatype =
index 4657662a301ac0b18120e6e9cdc211922f0a542f..36733d0ab2bf6968794de1f106cd19be4bd7f6f8 100644 (file)
@@ -131,8 +131,7 @@ int restore_cmd(UAContext *ua, char *cmd)
    }
 
    if (!open_db(ua)) {
-      free_rx(&rx);
-      return 0;
+      goto bail_out;
    }
 
    /* Ensure there is at least one Restore Job */
@@ -150,8 +149,7 @@ int restore_cmd(UAContext *ua, char *cmd)
       bsendmsg(ua, _(
          "No Restore Job Resource found. You must create at least\n"
          "one before running this command.\n"));
-      free_rx(&rx);
-      return 0;
+      goto bail_out;
    }
 
    /* 
@@ -162,8 +160,7 @@ int restore_cmd(UAContext *ua, char *cmd)
     */
    switch (user_select_jobids_or_files(ua, &rx)) {
    case 0:
-      free_rx(&rx);
-      return 0;                      /* error */
+      goto bail_out;
    case 1:                           /* select by jobid */
       build_directory_tree(ua, &rx);
       break;
@@ -174,16 +171,14 @@ int restore_cmd(UAContext *ua, char *cmd)
    if (rx.bsr->JobId) {
       if (!complete_bsr(ua, rx.bsr)) {  /* find Vol, SessId, SessTime from JobIds */
          bsendmsg(ua, _("Unable to construct a valid BSR. Cannot continue.\n"));
-        free_rx(&rx);
-        return 0;
+        goto bail_out;
       }
       write_bsr_file(ua, rx.bsr);
       bsendmsg(ua, _("\n%u file%s selected to be restored.\n\n"), rx.selected_files,
          rx.selected_files==1?"":"s");
    } else {
       bsendmsg(ua, _("No files selected to be restored.\n"));
-      free_rx(&rx);
-      return 0;
+      goto bail_out;
    }
 
    if (rx.restore_jobs == 1) {
@@ -192,12 +187,14 @@ int restore_cmd(UAContext *ua, char *cmd)
       job = select_restore_job_resource(ua);
    }
    if (!job) {
-      bsendmsg(ua, _("No Restore Job resource found!\n"));
-      free_rx(&rx);
-      return 0;
+      goto bail_out;
    }
 
    get_client_name(ua, &rx);
+   if (!rx.ClientName) {
+      bsendmsg(ua, _("No Restore Job resource found!\n"));
+      goto bail_out;
+   }
 
    /* Build run command */
    if (rx.where) {
@@ -222,6 +219,11 @@ int restore_cmd(UAContext *ua, char *cmd)
    bsendmsg(ua, _("Restore command done.\n"));
    free_rx(&rx);
    return 1;
+
+bail_out:
+   free_rx(&rx);
+   return 0;
+
 }
 
 static void free_rx(RESTORE_CTX *rx) 
@@ -260,7 +262,6 @@ static int get_client_name(UAContext *ua, RESTORE_CTX *rx)
       }
       memset(&cr, 0, sizeof(cr));
       if (!get_client_dbr(ua, &cr)) {
-        free_rx(rx);
         return 0;
       }
       bstrncpy(rx->ClientName, cr.Name, sizeof(rx->ClientName));
@@ -579,7 +580,7 @@ static int insert_file_into_findex_list(UAContext *ua, RESTORE_CTX *rx, char *fi
    }
    rx->selected_files++;
    /*
-    * Find the FileSets for this JobId and add to the name_list
+    * Find the MediaTypes for this JobId and add to the name_list
     */
    Mmsg(&rx->query, uar_mediatype, rx->JobId);
    if (!db_sql_query(ua->db, rx->query, unique_name_list_handler, (void *)&rx->name_list)) {
@@ -676,7 +677,7 @@ static void build_directory_tree(UAContext *ua, RESTORE_CTX *rx)
          bsendmsg(ua, "%s", db_strerror(ua->db));
       }
       /*
-       * Find the FileSets for this JobId and add to the name_list
+       * Find the MediaTypes for this JobId and add to the name_list
        */
       Mmsg(&rx->query, uar_mediatype, JobId);
       if (!db_sql_query(ua->db, rx->query, unique_name_list_handler, (void *)&rx->name_list)) {
@@ -722,6 +723,7 @@ static int select_backups_before_date(UAContext *ua, RESTORE_CTX *rx, char *date
    CLIENT_DBR cr;
    char fileset_name[MAX_NAME_LENGTH];
    char ed1[50];
+   int i;
 
 
    /* Create temp tables */
@@ -743,27 +745,40 @@ static int select_backups_before_date(UAContext *ua, RESTORE_CTX *rx, char *date
    bstrncpy(rx->ClientName, cr.Name, sizeof(rx->ClientName));
 
    /*
-    * Select FileSet 
+    * Get FileSet 
     */
-   Mmsg(&rx->query, uar_sel_fileset, cr.ClientId, cr.ClientId);
-   start_prompt(ua, _("The defined FileSet resources are:\n"));
-   if (!db_sql_query(ua->db, rx->query, fileset_handler, (void *)ua)) {
-      bsendmsg(ua, "%s\n", db_strerror(ua->db));
+   memset(&fsr, 0, sizeof(fsr));
+   i = find_arg_with_value(ua, "FileSet"); 
+   if (i >= 0) {
+      bstrncpy(fsr.FileSet, ua->argv[i], sizeof(fsr.FileSet));
+      if (!db_get_fileset_record(ua->jcr, ua->db, &fsr)) {
+         bsendmsg(ua, _("Error getting FileSet \"%s\": ERR=%s\n"), fsr.FileSet, 
+           db_strerror(ua->db));
+        i = -1;
+      }
    }
-   if (do_prompt(ua, _("FileSet"), _("Select FileSet resource"), 
+   if (i < 0) {                      /* fileset not found */
+      Mmsg(&rx->query, uar_sel_fileset, cr.ClientId, cr.ClientId);
+      start_prompt(ua, _("The defined FileSet resources are:\n"));
+      if (!db_sql_query(ua->db, rx->query, fileset_handler, (void *)ua)) {
+         bsendmsg(ua, "%s\n", db_strerror(ua->db));
+      }
+      if (do_prompt(ua, _("FileSet"), _("Select FileSet resource"), 
                 fileset_name, sizeof(fileset_name)) < 0) {
-      goto bail_out;
-   }
-   fsr.FileSetId = atoi(fileset_name); /* Id is first part of name */
-   if (!db_get_fileset_record(ua->jcr, ua->db, &fsr)) {
-      bsendmsg(ua, _("Error getting FileSet record: %s\n"), db_strerror(ua->db));
-      bsendmsg(ua, _("This probably means you modified the FileSet.\n"
+        goto bail_out;
+      }
+
+      bstrncpy(fsr.FileSet, fileset_name, sizeof(fsr.FileSet));
+      if (!db_get_fileset_record(ua->jcr, ua->db, &fsr)) {
+         bsendmsg(ua, _("Error getting FileSet record: %s\n"), db_strerror(ua->db));
+         bsendmsg(ua, _("This probably means you modified the FileSet.\n"
                      "Continuing anyway.\n"));
+      }
    }
 
 
    /* Find JobId of last Full backup for this client, fileset */
-   Mmsg(&rx->query, uar_last_full, cr.ClientId, cr.ClientId, date, fsr.FileSetId);
+   Mmsg(&rx->query, uar_last_full, cr.ClientId, cr.ClientId, date, fsr.FileSet);
    if (!db_sql_query(ua->db, rx->query, NULL, NULL)) {
       bsendmsg(ua, "%s\n", db_strerror(ua->db));
       goto bail_out;
@@ -788,7 +803,7 @@ static int select_backups_before_date(UAContext *ua, RESTORE_CTX *rx, char *date
 
    /* Now find all Incremental/Decremental Jobs after Full save */
    Mmsg(&rx->query, uar_inc_dec, edit_uint64(rx->JobTDate, ed1), date,
-       cr.ClientId, fsr.FileSetId);
+       cr.ClientId, fsr.FileSet);
    if (!db_sql_query(ua->db, rx->query, NULL, NULL)) {
       bsendmsg(ua, "%s\n", db_strerror(ua->db));
    }
@@ -815,6 +830,7 @@ bail_out:
    return stat;
 }
 
+
 /* Return next JobId from comma separated list */
 static int next_jobid_from_list(char **p, uint32_t *JobId)
 {
@@ -882,14 +898,15 @@ static int last_full_handler(void *ctx, int num_fields, char **row)
 }
 
 /*
- * Callback handler build fileset prompt list
+ * Callback handler build FileSet name prompt list
  */
 static int fileset_handler(void *ctx, int num_fields, char **row)
 {
-   char prompt[MAX_NAME_LENGTH+200];
 
-   snprintf(prompt, sizeof(prompt), "%s  %s  %s", row[0], row[1], row[2]);
-   add_prompt((UAContext *)ctx, prompt);
+   /* row[0] = FileSet (name) */
+   if (row[0]) {
+      add_prompt((UAContext *)ctx, row[0]);
+   }
    return 0;
 }
 
@@ -955,9 +972,6 @@ static void free_name_list(NAME_LIST *name_list)
 
 static void get_storage_from_mediatype(UAContext *ua, NAME_LIST *name_list, RESTORE_CTX *rx)
 {
-   char name[MAX_NAME_LENGTH];
-   STORE *store = NULL;
-
    if (name_list->num_ids > 1) {
       bsendmsg(ua, _("Warning, the JobIds that you selected refer to more than one MediaType.\n"
          "Restore is not possible. The MediaTypes used are:\n"));
@@ -972,16 +986,8 @@ static void get_storage_from_mediatype(UAContext *ua, NAME_LIST *name_list, REST
       return;
    }
 
-   start_prompt(ua, _("The defined Storage resources are:\n"));
-   LockRes();
-   while ((store = (STORE *)GetNextRes(R_STORAGE, (RES *)store))) {
-      if (strcmp(store->media_type, name_list->name[0]) == 0) {
-        add_prompt(ua, store->hdr.name);
-      }
-   }
-   UnlockRes();
-   do_prompt(ua, _("Storage"),  _("Select Storage resource"), name, sizeof(name));
-   rx->store = (STORE *)GetResWithName(R_STORAGE, name);
+   rx->store = get_storage_resource(ua, false /* don't use default */);
+
    if (!rx->store) {
       bsendmsg(ua, _("\nWarning. Unable to find Storage resource for\n"
          "MediaType %s, needed by the Jobs you selected.\n"
index b71b8161a1726812a35cdf1698ab9c02ae3aa865..f780810106b61e236772cc338b9fe016614df7f1 100644 (file)
@@ -391,8 +391,8 @@ static void list_running_jobs(UAContext *ua)
          */
         if (jcr->JobType == JT_CONSOLE) {
            bstrftime(dt, sizeof(dt), jcr->start_time);
-           strcpy(dt+7, dt+9);  /* cut century */
-           bsendmsg(ua, _("Console connected at %s\n"), dt);
+           strcpy(dt+7, dt+9);  /* cut century */
+            bsendmsg(ua, _("Console connected at %s\n"), dt);
         }
         njobs--;
       }
@@ -543,9 +543,9 @@ static void list_terminated_jobs(UAContext *ua)
    lock_last_jobs_list();
    struct s_last_job *je;
    bsendmsg(ua, _("\nTerminated Jobs:\n"));
-   bsendmsg(ua, _(" JobId  Level   Files        Bytes Status   Finished        Name \n"));
-   bsendmsg(ua, _("====================================================================\n"));
-   for (je=NULL; (je=(s_last_job *)last_jobs->next(je)); ) {
+   bsendmsg(ua, _(" JobId  Level   Files          Bytes Status   Finished        Name \n"));
+   bsendmsg(ua, _("======================================================================\n"));
+   foreach_dlist(je, last_jobs) {
       char JobName[MAX_NAME_LENGTH];
       char *termstat;
 
@@ -590,7 +590,7 @@ static void list_terminated_jobs(UAContext *ua)
            *p = 0;
         }
       }
-      bsendmsg(ua, _("%6d  %-4s %8s %12s %-7s  %-8s %s\n"), 
+      bsendmsg(ua, _("%6d  %-4s %8s %14s %-7s  %-8s %s\n"), 
         je->JobId,
         level, 
         edit_uint64_with_commas(je->JobFiles, b1),
index 9c4aa0deffa385e0062a5ac40128291cd740a6c6..ff6f835354fda5a7eee447589d441ac5fa13ed43 100755 (executable)
@@ -181,9 +181,9 @@ static void list_terminated_jobs(void *arg)
    lock_last_jobs_list();
    msg =  _("\nTerminated Jobs:\n"); 
    sendit(msg, strlen(msg), arg);
-   msg =  _(" JobId  Level   Files        Bytes Status   Finished        Name \n");
+   msg =  _(" JobId  Level   Files          Bytes Status   Finished        Name \n");
    sendit(msg, strlen(msg), arg);
-   msg = _("====================================================================\n"); 
+   msg = _("======================================================================\n"); 
    sendit(msg, strlen(msg), arg);
    for (je=NULL; (je=(s_last_job *)last_jobs->next(je)); ) {
       char JobName[MAX_NAME_LENGTH];
@@ -231,7 +231,7 @@ static void list_terminated_jobs(void *arg)
            *p = 0;
         }
       }
-      bsnprintf(buf, sizeof(buf), _("%6d  %-4s %8s %12s %-7s  %-8s %s\n"), 
+      bsnprintf(buf, sizeof(buf), _("%6d  %-4s %8s %14s %-7s  %-8s %s\n"), 
         je->JobId,
         level, 
         edit_uint64_with_commas(je->JobFiles, b1),
index 72613242ac9b436af605ebc8e9a73a6ffeaab89d..b9425c61143b3e3080ee7b5bd88c82912ca659b7 100644 (file)
@@ -94,7 +94,7 @@ int main()
       sprintf(buf, "This is item %d", i);
       fileset->mylist.append(bstrdup(buf));
    } 
-   for (int i=0; i<fileset->mylist.size(); i++) {
+   for (int i=0; i< fileset->mylist.size(); i++) {
       printf("Item %d = %s\n", i, (char *)fileset->mylist[i]);  
    }
    fileset->mylist.destroy();
@@ -107,7 +107,7 @@ int main()
       sprintf(buf, "This is item %d", i);
       mlist->append(bstrdup(buf));
    } 
-   for (int i=0; i<mlist->size(); i++) {
+   for (int i=0; i< mlist->size(); i++) {
       printf("Item %d = %s\n", i, (char *)mlist->get(i));  
    }
 
index 03d74717d8c1b2dcd4f8a8200bc33467c643a919..3b6d289147c3686b6d91e8951180ece2bbfc95b4 100644 (file)
@@ -198,7 +198,7 @@ int main()
    jcr_chain->insert_before(jcr, next_jcr);
    
    printf("Print remaining list.\n");
-   for (MYJCR *jcr=NULL; (jcr=(MYJCR *)jcr_chain->next(jcr)); ) {
+   foreach_dlist (jcr, jcr_chain) {
       printf("Dlist item = %s\n", jcr->buf);
       free(jcr->buf);
    }
@@ -227,7 +227,7 @@ int main()
    jcr_chain->insert_before(jcr, next_jcr);
    
    printf("Print remaining list.\n");
-   for (MYJCR *jcr=NULL; (jcr=(MYJCR *)jcr_chain->next(jcr)); ) {
+   foreach_dlist (jcr, jcr_chain) {
       printf("Dlist item = %s\n", jcr->buf);
       free(jcr->buf);
    }
index 0b4a154789a049cc3553c47558f639f83a628ff7..d50178a1868d0e6d153a84bd460df7f85f02b887 100644 (file)
  *
  */
 
-#define OFFSET(item,link) ((char *)link - (char *)item)
+/* In case you want to specifically specify the offset to the link */
+#define OFFSET(item, link) ((char *)(link) - (char *)(item))
+
+/*
+ * Loop var through each member of list
+ */
+#define foreach_dlist(var, list) \
+        for((var)=NULL; ((void *)(var))=(list)->next((var)); )
 
 struct dlink {
    void *next;
index 7bd134ca23622425dbe02a248059f15a387d8bc9..1ea0f15388c220f689402c003b3da6ea5a102266 100644 (file)
@@ -322,7 +322,7 @@ int main()
 
    jcrtbl->stats();
    printf("Walk the hash table:\n");
-   for (MYJCR *jcr=(MYJCR *)jcrtbl->first(); jcr; jcr=(MYJCR *)jcrtbl->next() ) {
+   foreach_htable (jcr, jcrtbl) {
 //    printf("htable item = %s\n", jcr->key);
       free(jcr->key);
       count++;
index e2cb3c3a73d85c466e03c15cf4174fdc70281506..b97cce3fabd3483e0d502be6a842cd40f9e8fdcc 100644 (file)
  *
  */
 
+/*
+ * Loop var through each member of table
+ */
+#define foreach_htable(var, tbl) \
+        for(((void *)(var))=(tbl)->first(); \
+            (var); \
+           ((void *)(var))=(tbl)->next())
+
 struct hlink {
-   void *next;                        /* next hash item */
-   char *key;                         /* key this item */
-   uint32_t hash;                     /* hash for this key */
+   void *next;                       /* next hash item */
+   char *key;                        /* key this item */
+   uint32_t hash;                    /* hash for this key */
 };
 
 class htable {
-   hlink **table;                     /* hash table */
-   int loffset;                       /* link offset in item */
-   uint32_t num_items;                /* current number of items */
-   uint32_t max_items;                /* maximum items before growing */
-   uint32_t buckets;                  /* size of hash table */
-   uint32_t hash;                     /* temp storage */
-   uint32_t index;                    /* temp storage */
+   hlink **table;                    /* hash table */
+   int loffset;                      /* link offset in item */
+   uint32_t num_items;               /* current number of items */
+   uint32_t max_items;               /* maximum items before growing */
+   uint32_t buckets;                 /* size of hash table */
+   uint32_t hash;                    /* temp storage */
+   uint32_t index;                   /* temp storage */
    uint32_t mask;                     /* "remainder" mask */
-   uint32_t rshift;                   /* amount to shift down */
-   hlink *walkptr;                    /* table walk pointer */
-   uint32_t walk_index;               /* table walk index */
-   void hash_index(char *key);        /* produce hash key,index */
-   void grow_table();                 /* grow the table */
+   uint32_t rshift;                  /* amount to shift down */
+   hlink *walkptr;                   /* table walk pointer */
+   uint32_t walk_index;              /* table walk index */
+   void hash_index(char *key);       /* produce hash key,index */
+   void grow_table();                /* grow the table */
 public:
    htable(void *item, void *link, int tsize = 31);
    void init(void *item, void *link, int tsize = 31);
    bool  insert(char *key, void *item);
    void *lookup(char *key);
-   void *first();                     /* get first item in table */
-   void *next();                      /* get next item in table */
+   void *first();                    /* get first item in table */
+   void *next();                     /* get next item in table */
    void destroy();
-   void stats();                      /* print stats about the table */
-   uint32_t size();                   /* return size of table */
+   void stats();                     /* print stats about the table */
+   uint32_t size();                  /* return size of table */
    void * operator new(size_t);
    void operator delete(void *);
 };
index 017c0f37ba71b10ff8e05fc1f3df39a031e4e6df..ff0573747b8600657ed8a5707bf60ac0ed9f3899 100755 (executable)
@@ -455,7 +455,7 @@ static void jcr_timeout_check(watchdog_t *self)
 {
    JCR *jcr;
    BSOCK *fd;
-   time_t timer_start, now;
+   time_t timer_start;
 
    Dmsg0(200, "Start JCR timeout checks\n");
 
index 3d2413685c1c937f516e4e5b303c78a80ad7add5..9ee2de331c589b2263fc1eba790b3c1be5ce741e 100755 (executable)
@@ -49,8 +49,6 @@ static int quit;
 static bool wd_is_init = false;
 
 /* Forward referenced callback functions */
-static void callback_child_timer(watchdog_t *self);
-static void callback_thread_timer(watchdog_t *self);
 static pthread_t wd_tid;
 
 /* Static globals */
@@ -159,7 +157,7 @@ bool register_watchdog(watchdog_t *wd)
    wd->next_fire = watchdog_time + wd->interval;
    TAILQ_INSERT_TAIL(&wd_queue, wd, qe);
    Dmsg3(200, "Registered watchdog %p, interval %d%s\n",
-        wd, wd->interval, wd->one_shot ? " one shot" : "");
+         wd, wd->interval, wd->one_shot ? " one shot" : "");
    V(mutex);
 
    return false;
@@ -176,7 +174,7 @@ bool unregister_watchdog_unlocked(watchdog_t *wd)
    TAILQ_FOREACH_SAFE(p, &wd_queue, qe, n) {
       if (wd == p) {
         TAILQ_REMOVE(&wd_queue, wd, qe);
-        Dmsg1(200, "Unregistered watchdog %p\n", wd);
+         Dmsg1(200, "Unregistered watchdog %p\n", wd);
         return true;
       }
    }
@@ -184,7 +182,7 @@ bool unregister_watchdog_unlocked(watchdog_t *wd)
    TAILQ_FOREACH_SAFE(p, &wd_inactive, qe, n) {
       if (wd == p) {
         TAILQ_REMOVE(&wd_inactive, wd, qe);
-        Dmsg1(200, "Unregistered inactive watchdog %p\n", wd);
+         Dmsg1(200, "Unregistered inactive watchdog %p\n", wd);
         return true;
       }
    }
@@ -229,7 +227,7 @@ static void *watchdog_thread(void *arg)
            /* Run the callback */
            p->callback(p);
 
-           /* Reschedule (or move to inactive list if it's a one-shot timer) */
+            /* Reschedule (or move to inactive list if it's a one-shot timer) */
            if (p->one_shot) {
               TAILQ_REMOVE(&wd_queue, p, qe);
               TAILQ_INSERT_TAIL(&wd_inactive, p, qe);
index c98d7e74d21b1b06c8b23d3d1eea45f26d043941..161628ea4f3f24506b71631b823db2de16bd8ab4 100644 (file)
@@ -257,9 +257,9 @@ static void list_terminated_jobs(void *arg)
    lock_last_jobs_list();
    msg =  _("\nTerminated Jobs:\n"); 
    sendit(msg, strlen(msg), arg);
-   msg =  _(" JobId  Level   Files        Bytes Status   Finished        Name \n");
+   msg =  _(" JobId  Level   Files          Bytes Status   Finished        Name \n");
    sendit(msg, strlen(msg), arg);
-   msg = _("====================================================================\n"); 
+   msg = _("======================================================================\n"); 
    sendit(msg, strlen(msg), arg);
    for (je=NULL; (je=(s_last_job *)last_jobs->next(je)); ) {
       char JobName[MAX_NAME_LENGTH];
@@ -307,7 +307,7 @@ static void list_terminated_jobs(void *arg)
            *p = 0;
         }
       }
-      bsnprintf(buf, sizeof(buf), _("%6d  %-4s %8s %12s %-7s  %-8s %s\n"), 
+      bsnprintf(buf, sizeof(buf), _("%6d  %-4s %8s %14s %-7s  %-8s %s\n"), 
         je->JobId,
         level, 
         edit_uint64_with_commas(je->JobFiles, b1),
index 5d1eee1c018cccddfc07cbdd39471979255f8163..918dafba5ea7c289dc70b461e06703f616093208 100644 (file)
@@ -102,7 +102,7 @@ static struct res_items dev_items[] = {
    {"autochanger",           store_yesno,  ITEM(res_dev.cap_bits), CAP_AUTOCHANGER, ITEM_DEFAULT, 0},
    {"changerdevice",         store_strname,ITEM(res_dev.changer_name), 0, 0, 0},
    {"changercommand",        store_strname,ITEM(res_dev.changer_command), 0, 0, 0},
-   {"maximumchangerwait",    store_pint,   ITEM(res_dev.max_changer_wait), 0, ITEM_DEFAULT, 2 * 60},
+   {"maximumchangerwait",    store_pint,   ITEM(res_dev.max_changer_wait), 0, ITEM_DEFAULT, 5 * 60},
    {"maximumopenwait",       store_pint,   ITEM(res_dev.max_open_wait), 0, ITEM_DEFAULT, 5 * 60},
    {"maximumopenvolumes",    store_pint,   ITEM(res_dev.max_open_vols), 0, ITEM_DEFAULT, 1},
    {"offlineonunmount",      store_yesno,  ITEM(res_dev.cap_bits), CAP_OFFLINEUNMOUNT, ITEM_DEFAULT, 0},
index d3295c2b86089508c69ee40b636f90cb5643c63d..5959a8f2b6705a1f59f920f2e3e123fcdafc1d88 100644 (file)
@@ -2,8 +2,8 @@
 #undef  VERSION
 #define VERSION "1.33"
 #define VSTRING "1"
-#define BDATE   "22 Dec 2003"
-#define LSMDATE "22Dec03"
+#define BDATE   "24 Dec 2003"
+#define LSMDATE "24Dec03"
 
 /* Debug flags */
 #undef  DEBUG