]> git.sur5r.net Git - bacula/bacula/commitdiff
Lots of cleanups + Christopher Hull's patches
authorKern Sibbald <kern@sibbald.com>
Thu, 1 Apr 2004 16:37:01 +0000 (16:37 +0000)
committerKern Sibbald <kern@sibbald.com>
Thu, 1 Apr 2004 16:37:01 +0000 (16:37 +0000)
git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@1169 91ce42f0-d328-0410-95d8-f526ca767f89

26 files changed:
bacula/Makefile.in
bacula/kernstodo
bacula/src/cats/sql.c
bacula/src/cats/sql_create.c
bacula/src/cats/sql_get.c
bacula/src/cats/sql_update.c
bacula/src/dird/dird.c
bacula/src/dird/job.c
bacula/src/dird/ua_status.c
bacula/src/filed/filed.c
bacula/src/filed/status.c
bacula/src/lib/alist.c
bacula/src/lib/bnet.c
bacula/src/lib/dlist.c
bacula/src/lib/htable.c
bacula/src/lib/jcr.c
bacula/src/lib/mem_pool.c
bacula/src/lib/smartall.c
bacula/src/lib/smartall.h
bacula/src/lib/watchdog.c
bacula/src/stored/btape.c
bacula/src/stored/stored.c
bacula/src/tools/dbcheck.c
bacula/src/tools/testfind.c
bacula/src/tools/testls.c
bacula/src/version.h

index 312c91c4e88c1198f57c7694007460074b5f573d..c1af4b5acb50aa3d4953986cfa1f7af192cb2a86 100755 (executable)
@@ -16,11 +16,10 @@ first_rule: all
 dummy:
 
 fd_subdirs = src scripts doc src/lib src/findlib src/filed \
-            rescue rescue/linux
+            @READLINE_SRC@ src/console rescue rescue/linux
 
 
-subdirs =    src/cats @READLINE_SRC@ src/console src/dird \
-            src/stored @GNOME_DIR@ src/tools
+subdirs =    src/cats src/dird src/stored @GNOME_DIR@ src/tools
 
 all_subdirs = ${fd_subdirs} ${@ALL_DIRS@}
 
@@ -93,17 +92,17 @@ gnomedirs:
        $(MKDIR) $(DESTDIR)/etc/security/console.apps
        $(MKDIR) $(DESTDIR)/etc/pam.d
 
-install-menu: installdirs gnomedirs
+install-menu: gnomedirs
        ${INSTALL_DATA} scripts/bacula.png $(DESTDIR)/usr/share/pixmaps/bacula.png
        ${INSTALL_DATA} scripts/bacula.desktop.gnome1 $(DESTDIR)/usr/share/gnome/apps/System/bacula.desktop
        ${INSTALL_DATA} scripts/bacula.desktop.gnome2 $(DESTDIR)/usr/share/applications/bacula.desktop
 
-install-menu-xsu: installdirs gnomedirs
+install-menu-xsu: gnomedirs
        ${INSTALL_DATA} scripts/bacula.png $(DESTDIR)/usr/share/pixmaps/bacula.png
        ${INSTALL_DATA} scripts/bacula.desktop.gnome1.xsu $(DESTDIR)/usr/share/gnome/apps/System/bacula.desktop
        ${INSTALL_DATA} scripts/bacula.desktop.gnome2.xsu $(DESTDIR)/usr/share/applications/bacula.desktop
 
-install-menu-consolehelper: installdirs gnomedirs
+install-menu-consolehelper: gnomedirs
        ${INSTALL_DATA} scripts/bacula.png $(DESTDIR)/usr/share/pixmaps/bacula.png
        ${INSTALL_DATA} scripts/bacula.desktop.gnome1.consolehelper $(DESTDIR)/usr/share/gnome/apps/System/bacula.desktop
        ${INSTALL_DATA} scripts/bacula.desktop.gnome2.consolehelper $(DESTDIR)/usr/share/applications/bacula.desktop
index b3f1ed56b8bacc50b1f279dd0f517e90de952d52..f9ea23b2a6eb0c96b570bea1a09ae092dd6d61ed 100644 (file)
@@ -1,5 +1,5 @@
                  Kern's ToDo List
-                  28 March 2004
+                  31 March 2004
 
 Documentation to do: (any release a little bit at a time)
 - DB upgrade to version 5 in bacula-1.27b, DB upgrade to
@@ -38,9 +38,6 @@ Testing to do: (painful)
 
 For 1.33 Testing/Documentation:
 - Add counter variable test.
-- Document ln -sf /usr/lib/libncurses.so /usr/lib/libtermcap.so
-  and install the esound-devĀ  package for compiling Console on SuSE.
-  This should read 'Document LDFLAGS="-L/usr/lib/termcap" ... '
 - Add an example of using a FIFO in dirdconf.wml 
 - Add an item to the FAQ about running jobs in different timezones.
 - Add some examples of job editing codes.
@@ -59,23 +56,15 @@ For 1.33 Testing/Documentation:
   a consequence, Bacula will completely stall untilthe machine exporting
   the NSF mounts comes back up.  If someone knows a wayaround this, please
   let me know."I haven't tried using NFS in years, but I think that the
-  "soft" and "intr"remount options may well help you.  The only way of
-  being sure would be totry it.See, for example,
+  "soft" and "intr" remount options may well help you.  The only way of
+  being sure would be to try it.See, for example,
      http://howtos.linux.com/guides/nag2/x-087-2-nfs.mountd.shtml
 
 For 1.33
-- Null dlist head and tail pointers if all items are removed.
 - Complete Win32 installer
 - Finish work on Gnome restore GUI.
-- On unknown client in restore "client=xxx"
-  Could not find Client "Matou": ERR=Query failed: DROP TABLE temp1: 
-     ERR=no such table: temp1
 - Fix "llist jobid=xx" where no fileset or client exists.
-- Build console in client-only build.
 - Test work on conio.c -- particularly linking.
-- Phil says that Windows file sizes mismatch in Verify when they should,
-  and that either the file size or the catalog size was zero.
-- Check time/dates printed during restore when using Win32 API.
 
 --- Maybe in 1.33
 From Chris Hull:
@@ -94,6 +83,8 @@ From Chris Hull:
 
 
 For version 1.35:
+- Make sure list of Volumes needed is in correct order for restore.
+  See havana.
 - Remove paths (and files that reference them) that have no trailing slash   
   in dbcheck -- or add a trailing slash.
 - Remove Filenames (and files that reference them) that have a trailing
@@ -1421,3 +1412,11 @@ Block Position: 0
 - Test Qmsg() code to be used in bnet.c to prevent recursion.  Queue the
   message. If dequeueing toss the messages. Lock while dequeuing so that
   it cannot be called recursively and set dequeuing flag.
+- On unknown client in restore "client=xxx"
+  Could not find Client "Matou": ERR=Query failed: DROP TABLE temp1: 
+     ERR=no such table: temp1
+- Null dlist head and tail pointers if all items are removed.
+- Build console in client-only build.
+- Phil says that Windows file sizes mismatch in Verify when they should,
+  and that either the file size or the catalog size was zero.
+- Check time/dates printed during restore when using Win32 API.
index 26144925acbda794b8aafa645c3067149b5a28bb..b0e8e943c8c622f0e07ae6b95423368bbab41b2a 100644 (file)
@@ -52,16 +52,16 @@ static int int_handler(void *ctx, int num_fields, char **row)
 {
    uint32_t *val = (uint32_t *)ctx;
 
-   Dmsg1(200, "int_handler starts with row pointing at %x\n", row);
+   Dmsg1(800, "int_handler starts with row pointing at %x\n", row);
 
    if (row[0]) {
-      Dmsg1(200, "int_handler finds '%s'\n", row[0]);
+      Dmsg1(800, "int_handler finds '%s'\n", row[0]);
       *val = atoi(row[0]);
    } else {
-      Dmsg0(200, "int_handler finds zero\n");
+      Dmsg0(800, "int_handler finds zero\n");
       *val = 0;
    }
-   Dmsg0(200, "int_handler finishes\n");
+   Dmsg0(800, "int_handler finishes\n");
    return 0;
 }
        
@@ -383,17 +383,17 @@ list_result(JCR *jcr, B_DB *mdb, DB_LIST_HANDLER *send, void *ctx, e_list_type t
    int i, col_len, max_len = 0;
    char buf[2000], ewc[30];
 
-   Dmsg0(200, "list_result starts\n");
+   Dmsg0(800, "list_result starts\n");
    if (mdb->result == NULL || sql_num_rows(mdb) == 0) {
       send(ctx, _("No results to list.\n"));
       return;
    }
 
-   Dmsg1(200, "list_result starts looking at %d fields\n", sql_num_fields(mdb));
+   Dmsg1(800, "list_result starts looking at %d fields\n", sql_num_fields(mdb));
    /* determine column display widths */
    sql_field_seek(mdb, 0);
    for (i = 0; i < sql_num_fields(mdb); i++) {
-      Dmsg1(200, "list_result processing field %d\n", i);
+      Dmsg1(800, "list_result processing field %d\n", i);
       field = sql_fetch_field(mdb);
       col_len = strlen(field->name);
       if (type == VERT_LIST) {
@@ -414,17 +414,17 @@ list_result(JCR *jcr, B_DB *mdb, DB_LIST_HANDLER *send, void *ctx, e_list_type t
       }
    }
 
-   Dmsg0(200, "list_result finished first loop\n");
+   Dmsg0(800, "list_result finished first loop\n");
    if (type == VERT_LIST) {
       goto vertical_list;
    }
 
-   Dmsg1(200, "list_result starts second loop looking at %d fields\n", sql_num_fields(mdb));
+   Dmsg1(800, "list_result starts second loop looking at %d fields\n", sql_num_fields(mdb));
    list_dashes(mdb, send, ctx);
    send(ctx, "|");
    sql_field_seek(mdb, 0);
    for (i = 0; i < sql_num_fields(mdb); i++) {
-      Dmsg1(200, "list_result looking at field %d\n", i);
+      Dmsg1(800, "list_result looking at field %d\n", i);
       field = sql_fetch_field(mdb);
       bsnprintf(buf, sizeof(buf), " %-*s |", (int)field->max_length, field->name);
       send(ctx, buf);
@@ -432,7 +432,7 @@ list_result(JCR *jcr, B_DB *mdb, DB_LIST_HANDLER *send, void *ctx, e_list_type t
    send(ctx, "\n");
    list_dashes(mdb, send, ctx);
 
-   Dmsg1(200, "list_result starts third loop looking at %d fields\n", sql_num_fields(mdb));
+   Dmsg1(800, "list_result starts third loop looking at %d fields\n", sql_num_fields(mdb));
    while ((row = sql_fetch_row(mdb)) != NULL) {
       sql_field_seek(mdb, 0);
       send(ctx, "|");
@@ -455,7 +455,7 @@ list_result(JCR *jcr, B_DB *mdb, DB_LIST_HANDLER *send, void *ctx, e_list_type t
 
 vertical_list:
    
-   Dmsg1(200, "list_result starts vertical list at %d fields\n", sql_num_fields(mdb));
+   Dmsg1(800, "list_result starts vertical list at %d fields\n", sql_num_fields(mdb));
    while ((row = sql_fetch_row(mdb)) != NULL) {
       sql_field_seek(mdb, 0);
       for (i = 0; i < sql_num_fields(mdb); i++) {
index a69471623d4f0c08827036bcb7c643712adb4b1e..9720b1f16e0a26dda73fde7843a14303657ec6fd 100644 (file)
@@ -515,6 +515,7 @@ int db_create_fileset_record(JCR *jcr, B_DB *mdb, FILESET_DBR *fsr)
 int db_create_file_attributes_record(JCR *jcr, B_DB *mdb, ATTR_DBR *ar)
 {
 
+   db_lock(mdb);
    Dmsg1(300, "Fname=%s\n", ar->fname);
    Dmsg0(500, "put_file_into_catalog\n");
    /*
@@ -524,36 +525,36 @@ int db_create_file_attributes_record(JCR *jcr, B_DB *mdb, ATTR_DBR *ar)
         ar->Stream == STREAM_UNIX_ATTRIBUTES_EX)) {
       Mmsg0(&mdb->errmsg, _("Attempt to put non-attributes into catalog\n"));
       Jmsg(jcr, M_ERROR, 0, "%s", mdb->errmsg);
-      return 0;
+      goto bail_out;
    }
 
-   db_lock(mdb);
 
    split_path_and_file(jcr, mdb, ar->fname);
 
    if (!db_create_filename_record(jcr, mdb, ar)) {
-      db_unlock(mdb);
-      return 0;
+      goto bail_out;
    }
    Dmsg1(500, "db_create_filename_record: %s\n", mdb->esc_name);
 
 
    if (!db_create_path_record(jcr, mdb, ar)) {
-      db_unlock(mdb);
-      return 0;
+      goto bail_out;
    }
    Dmsg1(500, "db_create_path_record: %s\n", mdb->esc_name);
 
    /* Now create master File record */
    if (!db_create_file_record(jcr, mdb, ar)) {
-      db_unlock(mdb);
-      return 0;
+      goto bail_out;
    }
    Dmsg0(500, "db_create_file_record OK\n");
 
    Dmsg3(300, "CreateAttributes Path=%s File=%s FilenameId=%d\n", mdb->path, mdb->fname, ar->FilenameId);
    db_unlock(mdb);
    return 1;
+
+bail_out:
+   db_unlock(mdb);
+   return 0;
 }
 
 /*
index 9594f74108309497cfff78e011fce6c1999fde64..d02d251ac079b0eaf5d16fff20f507768cfd7180 100644 (file)
@@ -144,6 +144,8 @@ int db_get_file_record(JCR *jcr, B_DB *mdb, JOB_DBR *jr, FILE_DBR *fdbr)
            fdbr->PathId, fdbr->FilenameId);
       }
       sql_free_result(mdb);
+   } else {
+      Mmsg(&mdb->errmsg, _("File record not found in Catalog.\n"));
    }
    return stat;
 
@@ -189,6 +191,8 @@ static int db_get_filename_record(JCR *jcr, B_DB *mdb)
          Mmsg1(&mdb->errmsg, _("Filename record: %s not found.\n"), mdb->fname);
       }
       sql_free_result(mdb);
+   } else {
+      Mmsg(&mdb->errmsg, _("Filename record: %s not found in Catalog.\n"), mdb->fname);
    }
    return FilenameId;
 }
@@ -246,6 +250,8 @@ static int db_get_path_record(JCR *jcr, B_DB *mdb)
          Mmsg1(&mdb->errmsg, _("Path record: %s not found.\n"), mdb->path);
       }
       sql_free_result(mdb);
+   } else {
+      Mmsg(&mdb->errmsg, _("Path record: %s not found in Catalog.\n"), mdb->path);
    }
    return PathId;
 }
@@ -352,6 +358,8 @@ int db_get_job_volume_names(JCR *jcr, B_DB *mdb, uint32_t JobId, POOLMEM **Volum
         }
       }
       sql_free_result(mdb);
+   } else {
+      Mmsg(&mdb->errmsg, _("No Volume for JobId %d found in Catalog.\n"), JobId);
    }
    db_unlock(mdb);
    return stat;
@@ -563,8 +571,12 @@ MaxVolBytes,PoolType,LabelFormat FROM Pool WHERE Pool.Name='%s'", pdbr->Name);
             bstrncpy(pdbr->LabelFormat, row[14]!=NULL?row[15]:"", sizeof(pdbr->LabelFormat));
            stat = pdbr->PoolId;
         }
+      } else {
+         Mmsg(&mdb->errmsg, _("Pool record not found in Catalog.\n"));
       }
       sql_free_result(mdb);
+   } else {
+      Mmsg(&mdb->errmsg, _("Pool record not found in Catalog.\n"));
    }
    db_unlock(mdb);
    return stat;
@@ -613,8 +625,12 @@ int db_get_client_record(JCR *jcr, B_DB *mdb, CLIENT_DBR *cdbr)
            cdbr->JobRetention = str_to_int64(row[5]);
            stat = 1;
         }
+      } else {
+         Mmsg(&mdb->errmsg, _("Client record not found in Catalog.\n"));
       }
       sql_free_result(mdb);
+   } else {
+      Mmsg(&mdb->errmsg, _("Client record not found in Catalog.\n"));
    }
    db_unlock(mdb);
    return stat;
@@ -664,7 +680,9 @@ int db_get_counter_record(JCR *jcr, B_DB *mdb, COUNTER_DBR *cr)
         return 1;
       }
       sql_free_result(mdb);
-   }
+   } else {
+      Mmsg(&mdb->errmsg, _("Counter record: %s not found in Catalog.\n"), cr->Counter);
+   }  
    db_unlock(mdb);
    return 0;
 }
@@ -711,6 +729,8 @@ int db_get_fileset_record(JCR *jcr, B_DB *mdb, FILESET_DBR *fsr)
         stat = fsr->FileSetId;
       }
       sql_free_result(mdb);
+   } else {
+      Mmsg(&mdb->errmsg, _("FileSet record not found in Catalog.\n"));
    }
    db_unlock(mdb);
    return stat;
@@ -854,6 +874,8 @@ int db_get_media_record(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr)
         }
       }
       sql_free_result(mdb);
+   } else {
+      Mmsg(&mdb->errmsg, _("Media record not found in Catalog.\n"));
    }
    db_unlock(mdb);
    return stat;
index 98e5dd1e0317ffbe43e8d6f3adca9428dda0f6a2..7ffad52f60b035d794697a9a7ee725ecf17b8f97 100644 (file)
@@ -108,8 +108,8 @@ db_update_job_start_record(JCR *jcr, B_DB *mdb, JOB_DBR *jr)
       (char)(jr->Level), dt, jr->ClientId, edit_uint64(JobTDate, ed1), jr->JobId);
 
    stat = UPDATE_DB(jcr, mdb, mdb->cmd);
-   db_unlock(mdb);
    mdb->changes = 0;
+   db_unlock(mdb);
    return stat;
 }
 
index c09721b6b08d46f6898de0297dd8b9336f8687d7..71f4bc538d3ba5d7f1ffd764c0f50d26e1aa382d 100644 (file)
@@ -271,7 +271,7 @@ static void terminate_dird(int sig)
    term_msg();                       /* terminate message handler */
    stop_watchdog();
    close_memory_pool();              /* release free memory in pool */
-   sm_dump(False);
+   sm_dump(false);
    exit(sig);
 }
 
index 6c486ae54524c1f66508c7acbf7d16c695321d63..f26f2b369ca3a7f6ab633bfb557467c9b2a6b152 100644 (file)
@@ -68,8 +68,6 @@ void init_job_server(int max_workers)
    wd->interval = 60;
    wd->data = new_control_jcr("*JobMonitor*", JT_SYSTEM);
    register_watchdog(wd);
-   
-   return;
 }
 
 /*
@@ -82,7 +80,7 @@ void run_job(JCR *jcr)
    int stat, errstat;
 
    P(jcr->mutex);
-   sm_check(__FILE__, __LINE__, True);
+   sm_check(__FILE__, __LINE__, true);
    init_msg(jcr, jcr->messages);
    create_unique_job_name(jcr, jcr->job->hdr.name);
    set_jcr_job_status(jcr, JS_Created);
@@ -160,8 +158,9 @@ static void *job_thread(void *arg)
 {
    JCR *jcr = (JCR *)arg;
 
-   pthread_detach(pthread_self());
-   sm_check(__FILE__, __LINE__, True);
+   jcr->my_thread_id = pthread_self();
+   pthread_detach(jcr->my_thread_id);
+   sm_check(__FILE__, __LINE__, true);
 
    for ( ;; ) {
 
@@ -271,7 +270,7 @@ bail_out:
    }
 
    Dmsg0(50, "======== End Job ==========\n");
-   sm_check(__FILE__, __LINE__, True);
+   sm_check(__FILE__, __LINE__, true);
    return NULL;
 }
 
index ce801ee496c099926fcf25571635b20b362bc396..a65efae62dcefa0a9bd9d9f508b77f5f708d03e5 100644 (file)
@@ -414,7 +414,6 @@ static void list_running_jobs(UAContext *ua)
       return;
    }
    njobs = 0;
-   bsendmsg(ua, _("\nRunning Jobs:\n"));
    bsendmsg(ua, _(" JobId Level   Name                       Status\n"));
    bsendmsg(ua, _("======================================================================\n"));
    foreach_jcr(jcr) {
index aa536f1617b8c2f500cea7ee4c2c19040dd6591d..5ebf0c37ba0360296a1409b3d399bdeb1cb65f30 100644 (file)
@@ -263,6 +263,6 @@ void terminate_filed(int sig)
    term_msg();
    stop_watchdog();
    close_memory_pool();              /* release free memory in pool */
-   sm_dump(False);                   /* dump orphaned buffers */
+   sm_dump(false);                   /* dump orphaned buffers */
    exit(sig);
 }
index 32e50a5da68e4ead765ed8e132dd6301ebba3a00..5565deeebc3de38ba0be0b2f574a6dfdafe82cb3 100755 (executable)
@@ -354,6 +354,9 @@ char *bac_status(int stat)
    struct s_last_job *job;
 
    bacstat = 0;
+   if (!last_jobs) {
+      return _("Bacula Terminated");
+   }
    if (last_jobs->size() > 0) {
       job = (struct s_last_job *)last_jobs->first();
       switch (job->JobStatus) {
index ea60835b0d771411ef0217d03a8a1b3ed424dcb4..9d90a97f84989088b31b6155d8e8af9038d13f76 100644 (file)
@@ -194,7 +194,7 @@ int main()
    delete mlist;
 
 
-   sm_dump(False);
+   sm_dump(false);
 
 }
 #endif
index bef757e231d459a68eedb0c84ed437d857c7c226..a9a339b102f90bc3370d14e7d46aef6164eb883e 100644 (file)
@@ -245,7 +245,7 @@ int32_t bnet_recv(BSOCK *bsock)
     * buffer is at least one byte longer than the message length.
     */
    mp_chr(bsock->msg)[nbytes] = 0;    /* terminate in case it is a string */
-   sm_check(__FILE__, __LINE__, False);
+   sm_check(__FILE__, __LINE__, false);
    return nbytes;                    /* return actual length of message */
 }
 
index c0d124263881447a2bbbd22b4283580500821dd6..b82c8bd0dd3012f2773fff8226aa770056e26337 100644 (file)
@@ -127,6 +127,9 @@ void dlist::remove(void *item)
       ((dlink *)(((char *)xitem)+loffset))->next = ilink->next;
    }
    num_items--;
+   if (num_items == 0) {
+      head = tail = NULL;
+   }
 }
 
 void * dlist::next(void *item)
@@ -235,7 +238,7 @@ int main()
 
    delete jcr_chain;
 
-   sm_dump(False);
+   sm_dump(false);
 
 }
 #endif
index 1ea0f15388c220f689402c003b3da6ea5a102266..088b8c96a7453c88955345b983c6f852c67add98 100644 (file)
@@ -187,7 +187,7 @@ bool htable::insert(char *key, void *item)
    if (lookup(key)) {
       return false;                  /* already exists */
    }
-   sm_check(__FILE__, __LINE__, False);
+   sm_check(__FILE__, __LINE__, false);
    ASSERT(index < buckets);
    Dmsg2(100, "Insert: hash=0x%x index=%d\n", (unsigned)hash, index);
    hp = (hlink *)(((char *)item)+loffset);
@@ -204,7 +204,7 @@ bool htable::insert(char *key, void *item)
       Dmsg2(100, "num_items=%d max_items=%d\n", num_items, max_items);
       grow_table();
    }
-   sm_check(__FILE__, __LINE__, False);
+   sm_check(__FILE__, __LINE__, false);
    Dmsg3(100, "Leave insert index=%d num_items=%d key=%s\n", index, num_items, key);
    return true;
 }
@@ -334,7 +334,7 @@ int main()
    free(jcrtbl);
    printf("Freed jcrtbl\n");
 
-   sm_dump(False);
+   sm_dump(false);
 
 }
 #endif
index 8f7d60bd1b828e12400d3af0028fcade3e0dc2a2..00a7254689834149c8426b7775fcadb0cf59c336 100755 (executable)
@@ -50,7 +50,7 @@ void init_last_jobs_list()
    int errstat;
    struct s_last_job *job_entry = NULL;
    if (!last_jobs) {
-      last_jobs = new dlist(job_entry, &job_entry->link);
+      last_jobs = new dlist(job_entry, &job_entry->link);
       if ((errstat=rwl_init(&lock)) != 0) {
          Emsg1(M_ABORT, 0, _("Unable to initialize jcr_chain lock. ERR=%s\n"), 
               strerror(errstat));
@@ -61,11 +61,7 @@ void init_last_jobs_list()
 
 void term_last_jobs_list()
 {
-   struct s_last_job *je;
    if (last_jobs) {
-      foreach_dlist(je, last_jobs) {
-        free(je);                     
-      }
       delete last_jobs;
       last_jobs = NULL;
       rwl_destroy(&lock);
@@ -186,7 +182,6 @@ JCR *new_jcr(int size, JCR_free_HANDLER *daemon_free_jcr)
    memset(jcr, 0, size);
    jcr->msg_queue = new dlist(item, &item->link);
    jcr->job_end_push.init(1, false);
-   jcr->my_thread_id = pthread_self();
    jcr->sched_time = time(NULL);
    jcr->daemon_free_jcr = daemon_free_jcr;    /* plug daemon free routine */
    jcr->use_count = 1;
index 55240b15127e31669874481a4cbf19c950e9e632..229868bc09f19022dfe5fb2dc972cd99d5673da8 100644 (file)
@@ -360,7 +360,7 @@ void close_memory_pool()
 {
    struct abufhead *buf, *next;
 
-   sm_check(__FILE__, __LINE__, False);
+   sm_check(__FILE__, __LINE__, false);
    P(mutex);
    for (int i=1; i<=PM_MAX; i++) {
       buf = pool_ctl[i].free_buf;
index 3a5a679ee7c2a5d5d7cd5288cc4803c2c9206727..fe8093facb92f38a83acbb1b545ec36bd7fe29fb 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
 #undef calloc
 #undef malloc
 #undef free
+
+/* We normally turn off debugging here.
+ *  If you want it, simply #ifdef all the 
+ *  following off.
+ */
+#undef Dmsg1
+#undef Dmsg2
+#undef Dmsg3
+#undef Dmsg4
+#define Dmsg1(l,f,a1)
+#define Dmsg2(l,f,a1,a2)
+#define Dmsg3(l,f,a1,a2,a3)
+#define Dmsg4(l,f,a1,a2,a3,a4)
       
 
 
@@ -73,7 +86,7 @@ static struct b_queue abqueue = {    /* Allocated buffer queue */
    &abqueue, &abqueue
 };
 
-static Boolean bufimode = False;   /* Buffers not tracked when True */
+static bool bufimode = false;  /* Buffers not tracked when True */
 
 #define HEAD_SIZE BALIGN(sizeof(struct abufhead))
 
@@ -320,7 +333,7 @@ void actuallyfree(void *cp)
  *  N.B. DO NOT USE any Bacula print routines (Dmsg, Jmsg, Emsg, ...)
  *    as they have all been shut down at this point.
  */
-void sm_dump(Boolean bufdump)
+void sm_dump(bool bufdump)
 {
    struct abufhead *ap;
 
@@ -344,27 +357,29 @@ void sm_dump(Boolean bufdump)
 
       if (ap->abfname != NULL) {
         unsigned memsize = ap->ablen - (HEAD_SIZE + 1);
-        char errmsg[80];
+        char errmsg[500];
 
-        sprintf(errmsg,
+        bsnprintf(errmsg, sizeof(errmsg),
            "Orphaned buffer:  %6u bytes allocated at line %d of %s %s\n",
            memsize, ap->ablineno, my_name, ap->abfname
         );
          fprintf(stderr, "%s", errmsg);
         if (bufdump) {
+           char buf[20];
            unsigned llen = 0;
            char *cp = ((char *) ap) + HEAD_SIZE;
 
            errmsg[0] = EOS;
            while (memsize) {
               if (llen >= 16) {
-                  strcat(errmsg, "\n");
+                  bstrncat(errmsg, "\n", sizeof(errmsg));
                  llen = 0;
                   fprintf(stderr, "%s", errmsg);
                  errmsg[0] = EOS;
               }
-               sprintf(errmsg + strlen(errmsg), " %02X",
+               bsnprintf(buf, sizeof(buf), " %02X",
                  (*cp++) & 0xFF);
+              bstrncat(errmsg, buf, sizeof(errmsg));
               llen++;
               memsize--;
            }
@@ -378,7 +393,7 @@ void sm_dump(Boolean bufdump)
 
 #undef sm_check
 /*  SM_CHECK --  Check the buffers and dump if any damage exists. */
-void sm_check(const char *fname, int lineno, Boolean bufdump)
+void sm_check(const char *fname, int lineno, bool bufdump)
 {
        if (!sm_check_rtn(fname, lineno, bufdump)) {
            Emsg2(M_ABORT, 0, "Damaged buffer found. Called from %s:%d\n",
@@ -388,7 +403,7 @@ void sm_check(const char *fname, int lineno, Boolean bufdump)
 
 #undef sm_check_rtn
 /*  SM_CHECK_RTN -- Check the buffers and return 1 if OK otherwise 0 */
-int sm_check_rtn(const char *fname, int lineno, Boolean bufdump)
+int sm_check_rtn(const char *fname, int lineno, bool bufdump)
 {
    struct abufhead *ap;
    int bad, badbuf = 0;
@@ -475,7 +490,7 @@ int sm_check_rtn(const char *fname, int lineno, Boolean bufdump)
 
 void sm_static(int mode)
 {
-   bufimode = (Boolean) (mode != 0);
+   bufimode = (bool) (mode != 0);
 }
 
 /* 
index ad72bcedd6a8a392e50422e4a6b67363d740a101..26062e371cacf79e8581305f9f3c2a50908c1e6e 100644 (file)
@@ -1,6 +1,6 @@
 /*
 
-       Definitions for the smart memory allocator
+        Definitions for the smart memory allocator
   
      Version $Id$
 
 
 #ifdef SMARTALLOC
 
-typedef enum {False = 0, True = 1} Boolean;
-
 extern void *sm_malloc(const char *fname, int lineno, unsigned int nbytes),
-           *sm_calloc(const char *fname, int lineno,
-               unsigned int nelem, unsigned int elsize),
-           *sm_realloc(const char *fname, int lineno, void *ptr, unsigned int size),
-           *actuallymalloc(unsigned int size),
-           *actuallycalloc(unsigned int nelem, unsigned int elsize),
-           *actuallyrealloc(void *ptr, unsigned int size);
+            *sm_calloc(const char *fname, int lineno,
+                unsigned int nelem, unsigned int elsize),
+            *sm_realloc(const char *fname, int lineno, void *ptr, unsigned int size),
+            *actuallymalloc(unsigned int size),
+            *actuallycalloc(unsigned int nelem, unsigned int elsize),
+            *actuallyrealloc(void *ptr, unsigned int size);
 extern void sm_free(const char *fname, int lineno, void *fp);
 extern void actuallyfree(void *cp),
-           sm_dump(Boolean bufdump), sm_static(int mode);
+            sm_dump(bool bufdump), sm_static(int mode);
 extern void sm_new_owner(const char *fname, int lineno, char *buf);
 
 #ifdef SMCHECK
-extern void sm_check(const char *fname, int lineno, Boolean bufdump);
-extern int sm_check_rtn(const char *fname, int lineno, Boolean bufdump);
+extern void sm_check(const char *fname, int lineno, bool bufdump);
+extern int sm_check_rtn(const char *fname, int lineno, bool bufdump);
 #else
 #define sm_check(f, l, fl)
 #define sm_check_rtn(f, l, fl) 1
@@ -79,7 +77,7 @@ extern int sm_check_rtn(const char *fname, int lineno, Boolean bufdump);
 #define sm_check_rtn(f, l, fl) 1
 
 extern void *b_malloc();
-#define malloc(x) b_malloc(__FILE__, __LINE__, (x))                 
+#define malloc(x) b_malloc(__FILE__, __LINE__, (x))                  
 
 
 #endif
index 05e59dfe0192945b65adbfa7ec24580a8b413ae5..13d3375847ed96afd9c74834c098290a6c1c9a21 100755 (executable)
@@ -101,7 +101,10 @@ int stop_watchdog(void)
 
    stat = pthread_join(wd_tid, NULL);
 
-   foreach_dlist(p, wd_queue) {
+   while (!wd_queue->empty()) {
+      void *item = wd_queue->first();
+      wd_queue->remove(item);
+      p = (watchdog_t *)item;
       if (p->destructor != NULL) {
         p->destructor(p);
       }
@@ -110,13 +113,15 @@ int stop_watchdog(void)
    delete wd_queue;
    wd_queue = NULL;
 
-   foreach_dlist(p, wd_inactive) {
+   while (!wd_inactive->empty()) {
+      void *item = wd_inactive->first();
+      wd_inactive->remove(item);
+      p = (watchdog_t *)item;
       if (p->destructor != NULL) {
         p->destructor(p);
       }
       free(p);
    }
-
    delete wd_inactive;
    wd_inactive = NULL;
    rwl_destroy(&lock);
@@ -214,14 +219,14 @@ static void *watchdog_thread(void *arg)
    Dmsg0(400, "NicB-reworked watchdog thread entered\n");
 
    while (!quit) {
-      watchdog_t *p;
+      watchdog_t *p, *q;
 
       /* 
        * We lock the jcr chain here because a good number of the
        *   callback routines lock the jcr chain. We need to lock
        *   it here *before* the watchdog lock because the SD message
        *   thread first locks the jcr chain, then when closing the
-       *   job locks the watchdog chain. If the two thread do not
+       *   job locks the watchdog chain. If the two threads do not
        *   lock in the same order, we get a deadlock -- each holds
        *   the other's needed lock.
        */
@@ -236,8 +241,17 @@ static void *watchdog_thread(void *arg)
 
             /* Reschedule (or move to inactive list if it's a one-shot timer) */
            if (p->one_shot) {
+              /* 
+               * Note, when removing an item while walking the list
+               *  we must get the previous pointer (q) and set the
+               *  current pointer (p) to this previous pointer after
+                *  removing the current pointer, otherwise, we won't
+               *  walk the rest of the list.
+               */
+              q = (watchdog_t *)wd_queue->prev(p);
               wd_queue->remove(p);
               wd_inactive->append(p);
+              p = q;
            } else {
               p->next_fire = watchdog_time + p->interval;
            }
index c4984a6081c50059c77d2beb3a9cdb4a9756a2a1..8c815cc8e56149a6ea4158d21bbe0e714a7a1082 100644 (file)
@@ -189,7 +189,7 @@ int main(int margc, char *margv[])
         break;
 
       case 's':
-        signals = FALSE;
+        signals = false;
         break;
 
       case 'v':
@@ -253,7 +253,7 @@ terminate:
 static void terminate_btape(int stat)
 {
 
-   sm_check(__FILE__, __LINE__, False);
+   sm_check(__FILE__, __LINE__, false);
    if (configfile) {
       free(configfile);
    }
@@ -288,7 +288,7 @@ static void terminate_btape(int stat)
    term_msg();
    close_memory_pool();              /* free memory in pool */
 
-   sm_dump(False);
+   sm_dump(false);
    exit(stat);
 }
 
@@ -576,7 +576,7 @@ static void rectestcmd()
       return;
    }
 
-   sm_check(__FILE__, __LINE__, False);
+   sm_check(__FILE__, __LINE__, false);
    block = new_block(dev);
    rec = new_record();
 
@@ -584,7 +584,7 @@ static void rectestcmd()
       rec->data = check_pool_memory_size(rec->data, i);
       memset(rec->data, i & 0xFF, i);
       rec->data_len = i;
-      sm_check(__FILE__, __LINE__, False);
+      sm_check(__FILE__, __LINE__, false);
       if (write_record_to_block(block, rec)) {
         empty_block(block);
         blkno++;
@@ -592,11 +592,11 @@ static void rectestcmd()
       } else {
         break;
       }
-      sm_check(__FILE__, __LINE__, False);
+      sm_check(__FILE__, __LINE__, false);
    }
    free_record(rec);
    free_block(block);
-   sm_check(__FILE__, __LINE__, False);
+   sm_check(__FILE__, __LINE__, false);
 }
 
 /*
@@ -1412,7 +1412,7 @@ static void wrcmd()
    DEV_RECORD *rec;
    int i;
 
-   sm_check(__FILE__, __LINE__, False);
+   sm_check(__FILE__, __LINE__, false);
    block = new_block(dev);
    rec = new_record();
    dump_block(block, "test");
@@ -1422,7 +1422,7 @@ static void wrcmd()
    rec->data = check_pool_memory_size(rec->data, i);
    memset(rec->data, i & 0xFF, i);
    rec->data_len = i;
-   sm_check(__FILE__, __LINE__, False);
+   sm_check(__FILE__, __LINE__, false);
    if (!write_record_to_block(block, rec)) {
       Pmsg0(0, _("Error writing record to block.\n")); 
       goto bail_out;
@@ -1436,10 +1436,10 @@ static void wrcmd()
    Pmsg0(0, _("Wrote block to device.\n"));
 
 bail_out:
-   sm_check(__FILE__, __LINE__, False);
+   sm_check(__FILE__, __LINE__, false);
    free_record(rec);
    free_block(block);
-   sm_check(__FILE__, __LINE__, False);
+   sm_check(__FILE__, __LINE__, false);
 }
 
 /* 
@@ -1834,12 +1834,12 @@ This may take a long time -- hours! ...\n\n");
       }
       if (!write_session_label(jcr, block, EOS_LABEL)) {
          Pmsg1(000, _("Error writting end session label. ERR=%s\n"), strerror_dev(dev));
-        ok = FALSE;
+        ok = false;
       }
       /* Write out final block of this session */
       if (!write_block_to_device(jcr->dcr, block)) {
-         Pmsg0(-1, _("Set ok=FALSE after write_block_to_device.\n"));
-        ok = FALSE;
+         Pmsg0(-1, _("Set ok=false after write_block_to_device.\n"));
+        ok = false;
       }
       Pmsg0(-1, _("Wrote End Of Session label.\n"));
 
@@ -1875,7 +1875,7 @@ This may take a long time -- hours! ...\n\n");
    /* Release the device */
    if (!release_device(jcr)) {
       Pmsg0(-1, _("Error in release_device\n"));
-      ok = FALSE;
+      ok = false;
    }
 
 
@@ -2185,7 +2185,7 @@ static int flush_block(DEV_BLOCK *block, int dump)
         /* Full test in progress */
         if (!fixup_device_block_write_error(jcr, dev, block)) {
             Pmsg1(000, _("Cannot fixup device error. %s\n"), strerror_dev(dev));
-           ok = FALSE;
+           ok = false;
            unlock_device(dev);
            return 0;
         }
@@ -2233,7 +2233,7 @@ static void qfillcmd()
       count = 1000;
    }
 
-   sm_check(__FILE__, __LINE__, False);
+   sm_check(__FILE__, __LINE__, false);
    block = new_block(dev);
    rec = new_record();
 
@@ -2267,10 +2267,10 @@ static void qfillcmd()
    scan_blocks();
 
 bail_out:
-   sm_check(__FILE__, __LINE__, False);
+   sm_check(__FILE__, __LINE__, false);
    free_record(rec);
    free_block(block);
-   sm_check(__FILE__, __LINE__, False);
+   sm_check(__FILE__, __LINE__, false);
 
 }
 
@@ -2416,7 +2416,7 @@ do_tape_cmds()
    bool found;
 
    while (get_cmd("*")) {
-      sm_check(__FILE__, __LINE__, False);
+      sm_check(__FILE__, __LINE__, false);
       found = false;
       parse_args(cmd, &args, &argc, argk, argv, MAX_CMD_ARGS);
       for (i=0; i<comsize; i++)       /* search for command */
index 865d6bb511aba893ceb53a139be867ccf7ae4538..746f3831ae934ef43b3e5f2160fbae85c081d55b 100644 (file)
@@ -405,6 +405,6 @@ void terminate_stored(int sig)
    stop_watchdog();
    close_memory_pool();
 
-   sm_dump(False);                   /* dump orphaned buffers */
+   sm_dump(false);                   /* dump orphaned buffers */
    exit(sig);
 }
index 1333902d28d4d543a0156125310caa7d454fc8cf..86df726e8ee47583a7edb033a4e9f6e9b2205286 100644 (file)
@@ -466,6 +466,9 @@ static void eliminate_duplicate_filenames()
         /* Get all the Ids of each name */
         db_escape_string(esc_name, name_list.name[i], strlen(name_list.name[i]));
          sprintf(buf, "SELECT FilenameId FROM Filename WHERE Name='%s'", esc_name);
+        if (verbose > 1) {
+            printf("%s\n", buf);
+        }
         if (!make_id_list(buf, &id_list)) {
            exit(1);
         }
@@ -476,9 +479,15 @@ static void eliminate_duplicate_filenames()
         for (int j=1; j<id_list.num_ids; j++) {
             sprintf(buf, "UPDATE File SET FilenameId=%u WHERE FilenameId=%u", 
               id_list.Id[0], id_list.Id[j]);
+           if (verbose > 1) {
+               printf("%s\n", buf);
+           }
            db_sql_query(db, buf, NULL, NULL);
             sprintf(buf, "DELETE FROM Filename WHERE FilenameId=%u", 
               id_list.Id[j]);
+           if (verbose > 2) {
+               printf("%s\n", buf);
+           }
            db_sql_query(db, buf, NULL, NULL);
         }
       }
@@ -511,7 +520,9 @@ static void eliminate_duplicate_paths()
         /* Get all the Ids of each name */
         db_escape_string(esc_name, name_list.name[i], strlen(name_list.name[i]));
          sprintf(buf, "SELECT PathId FROM Path WHERE Path='%s'", esc_name);
-        id_list.num_ids = 0;
+        if (verbose > 1) {
+            printf("%s\n", buf);
+        }
         if (!make_id_list(buf, &id_list)) {
            exit(1);
         }
@@ -522,9 +533,15 @@ static void eliminate_duplicate_paths()
         for (int j=1; j<id_list.num_ids; j++) {
             sprintf(buf, "UPDATE File SET PathId=%u WHERE PathId=%u", 
               id_list.Id[0], id_list.Id[j]);
+           if (verbose > 1) {
+               printf("%s\n", buf);
+           }
            db_sql_query(db, buf, NULL, NULL);
             sprintf(buf, "DELETE FROM Path WHERE PathId=%u", 
               id_list.Id[j]);
+           if (verbose > 2) {
+               printf("%s\n", buf);
+           }
            db_sql_query(db, buf, NULL, NULL);
         }
       }
@@ -569,6 +586,9 @@ static void eliminate_orphaned_file_records()
    query = "SELECT File.FileId,Job.JobId FROM File "
            "LEFT OUTER JOIN Job ON (File.JobId=Job.JobId) "
            "WHERE Job.JobId IS NULL";
+   if (verbose > 1) {
+      printf("%s\n", query);
+   }
    if (!make_id_list(query, &id_list)) {
       exit(1);
    }
@@ -598,6 +618,9 @@ static void eliminate_orphaned_path_records()
    query = "SELECT Path.PathId,File.PathId FROM Path "
            "LEFT OUTER JOIN File ON (Path.PathId=File.PathId) "
            "GROUP BY Path.PathId HAVING File.PathId IS NULL";
+   if (verbose > 1) {
+      printf("%s\n", query);
+   }
    if (!make_id_list(query, &id_list)) {
       exit(1);
    }
@@ -623,7 +646,9 @@ static void eliminate_orphaned_filename_records()
    query = "SELECT Filename.FilenameId,File.FilenameId FROM Filename "
            "LEFT OUTER JOIN File ON (Filename.FilenameId=File.FilenameId) "
            "WHERE File.FilenameId IS NULL";
-
+   if (verbose > 1) {
+      printf("%s\n", query);
+   }
    if (!make_id_list(query, &id_list)) {
       exit(1);
    }
@@ -649,6 +674,9 @@ static void eliminate_orphaned_fileset_records()
    query = "SELECT FileSet.FileSetId,Job.FileSetId FROM FileSet "
            "LEFT OUTER JOIN Job ON (FileSet.FileSetId=Job.FileSetId) "
            "WHERE Job.FileSetId IS NULL";
+   if (verbose > 1) {
+      printf("%s\n", query);
+   }
    if (!make_id_list(query, &id_list)) {
       exit(1);
    }
@@ -677,6 +705,9 @@ static void repair_bad_filenames()
    printf("Checking for Filenames with a trailing slash\n");
    query = "SELECT FilenameId,Name from Filename "
            "WHERE Name LIKE '%/'";
+   if (verbose > 1) {
+      printf("%s\n", query);
+   }
    if (!make_id_list(query, &id_list)) {
       exit(1);
    }
@@ -716,6 +747,9 @@ static void repair_bad_filenames()
         bsnprintf(buf, sizeof(buf), 
             "UPDATE Filename SET Name='%s' WHERE FilenameId=%u", 
            esc_name, id_list.Id[i]);
+        if (verbose > 1) {
+            printf("%s\n", buf);
+        }
         db_sql_query(db, buf, NULL, NULL);
       }
    }
@@ -729,6 +763,9 @@ static void repair_bad_paths()
    printf("Checking for Paths without a trailing slash\n");
    query = "SELECT PathId,Path from Path "
            "WHERE Path NOT LIKE '%/'";
+   if (verbose > 1) {
+      printf("%s\n", query);
+   }
    if (!make_id_list(query, &id_list)) {
       exit(1);
    }
@@ -763,6 +800,9 @@ static void repair_bad_paths()
         db_escape_string(esc_name, name, len);
          bsnprintf(buf, sizeof(buf), "UPDATE Path SET Path='%s' WHERE PathId=%u", 
            esc_name, id_list.Id[i]);
+        if (verbose > 1) {
+            printf("%s\n", buf);
+        }
         db_sql_query(db, buf, NULL, NULL);
       }
    }
index fca5d95a27ff30d236e854c22125b2a8cbad5686..a9f9afa2315642fb96467ee3c2720720f7024938 100644 (file)
@@ -167,7 +167,7 @@ Hard links     : %d\n"),
   
   free_jcr(jcr);
   close_memory_pool();
-  sm_dump(False);
+  sm_dump(false);
   exit(0);
 }
 
index ccd0577646bbdafb7719580c4214f5ee32d0924c..7ecd5fb9bce54213c2142e58dfdef7b03c1bae53 100755 (executable)
@@ -152,7 +152,7 @@ main (int argc, char *const *argv)
   
    free_jcr(jcr);
    close_memory_pool();
-   sm_dump(False);
+   sm_dump(false);
    exit(0);
 }
 
index dda5cf07fc0f7c2eebf5e003d55529bdea673f36..cbf2da5184a3a95247ed105303bdb09de686767d 100644 (file)
@@ -2,8 +2,8 @@
 #undef  VERSION
 #define VERSION "1.33.6"
 #define VSTRING "1"
-#define BDATE   "30 Mar 2004"
-#define LSMDATE "30Mar04"
+#define BDATE   "01 Apr 2004"
+#define LSMDATE "01Apr04"
 
 /* Debug flags */
 #undef  DEBUG