From f57c8600d465c20fc9b1487dbfca0a7d6afcdd12 Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Tue, 6 Feb 2007 14:37:57 +0000 Subject: [PATCH] 06Feb07 kes Delete src/lib/btree.c from win32 build, then add rblist.c plus the entrypoints. kes Apply patch supplied that corrects debug print in canceling jobs for max run time. Supplied as part of bug #621, which was previously fixed. 05Feb07 kes Test on job_canceled() and sd_msg_thread_done inside loop starting the message thread to avoid a race condition. Fixes bug #771. kes Remove rl_catch_signal from console.c as it conflicted with the header definition. Fixes bug #765. ebl Fixes bug #766 about RunsOnClient = Yes 04Feb07 kes Clarify some stored/acquire messages to indicate if the problem is with read or append. 02Feb07 kes Fix memory leak with storage ids in cats/sql_get.c kes Terminate watchdog earlier to avoid reference to released memory -- reported by Jason Austin. kes Move closing the database from jobq.c to the director daemon termination routine. This fixes memory leaks for shadow jobs (i.e. migration jobs). kes Free up the unique jobid chain items in migrate.c. This fixes a memory leak problem. kes Convert some ugly looking for statements to use foreach_alist in findlib/find.c. This will facilitate converting the structures to use dlist (for large include/exclude lists). kes Fix a bug in the btree.c and btree.h routines, then rename them rblist and add them to be built in src/lib. Include some new methods written by Rudolf Cejka that make the code more readable (hides some of the ugly casting). git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/branches/Branch-2.0@4116 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/ChangeLog | 2 +- bacula/po/LINGUAS | 1 + bacula/src/cats/sql_get.c | 7 +- bacula/src/dird/dird.c | 2 +- bacula/src/dird/dird_conf.c | 2 +- bacula/src/dird/dird_conf.h | 2 +- bacula/src/dird/job.c | 4 + bacula/src/dird/jobq.c | 4 - bacula/src/dird/migrate.c | 3 + bacula/src/dird/protos.h | 2 +- bacula/src/findlib/find.c | 18 +- bacula/src/lib/btree.c | 490 ------------------------------- bacula/src/lib/btree.h | 107 ------- bacula/src/lib/lib.h | 3 +- bacula/src/lib/parse_conf.h | 2 +- bacula/src/stored/acquire.c | 16 +- bacula/src/version.h | 6 +- bacula/src/win32/dll/Makefile | 2 +- bacula/src/win32/dll/bacula.def | 10 +- bacula/src/win32/libbac/Makefile | 2 +- bacula/technotes-2.0 | 35 ++- 21 files changed, 84 insertions(+), 636 deletions(-) delete mode 100644 bacula/src/lib/btree.c delete mode 100644 bacula/src/lib/btree.h diff --git a/bacula/ChangeLog b/bacula/ChangeLog index 33fbc808ff..15e06fb64e 100644 --- a/bacula/ChangeLog +++ b/bacula/ChangeLog @@ -2,7 +2,7 @@ General: -Version 2.0.2 released: xx January 2007 +Version 2.0.2 released: 30 January 2007 28Jan08 kes Fix maxruntime bug #621. 27Jan07 diff --git a/bacula/po/LINGUAS b/bacula/po/LINGUAS index fc01a1cb3f..342b8ccccc 100644 --- a/bacula/po/LINGUAS +++ b/bacula/po/LINGUAS @@ -2,3 +2,4 @@ fr it de es +fi diff --git a/bacula/src/cats/sql_get.c b/bacula/src/cats/sql_get.c index b2cc9734e5..9176853496 100644 --- a/bacula/src/cats/sql_get.c +++ b/bacula/src/cats/sql_get.c @@ -412,12 +412,10 @@ int db_get_job_volume_parameters(JCR *jcr, B_DB *mdb, JobId_t JobId, VOL_PARAMS stat = 0; } else { stat = mdb->num_rows; - DBId_t *SId; + DBId_t *SId = NULL; if (stat > 0) { *VolParams = Vols = (VOL_PARAMS *)malloc(stat * sizeof(VOL_PARAMS)); SId = (DBId_t *)malloc(stat * sizeof(DBId_t)); - } else { - SId = NULL; } for (i=0; i < stat; i++) { if ((row = sql_fetch_row(mdb)) == NULL) { @@ -453,6 +451,9 @@ int db_get_job_volume_parameters(JCR *jcr, B_DB *mdb, JobId_t JobId, VOL_PARAMS } } } + if (SId) { + free(SId); + } } sql_free_result(mdb); } diff --git a/bacula/src/dird/dird.c b/bacula/src/dird/dird.c index 6d48a4f236..5081f08561 100644 --- a/bacula/src/dird/dird.c +++ b/bacula/src/dird/dird.c @@ -301,6 +301,7 @@ void terminate_dird(int sig) exit(1); } already_here = true; + stop_watchdog(); generate_daemon_event(NULL, "Exit"); write_state_file(director->working_directory, "bacula-dir", get_first_port_host_order(director->DIRaddrs)); delete_pid_file(director->pid_directory, "bacula-dir", get_first_port_host_order(director->DIRaddrs)); @@ -319,7 +320,6 @@ void terminate_dird(int sig) free_config_resources(); term_ua_server(); term_msg(); /* terminate message handler */ - stop_watchdog(); cleanup_crypto(); close_memory_pool(); /* release free memory in pool */ sm_dump(false); diff --git a/bacula/src/dird/dird_conf.c b/bacula/src/dird/dird_conf.c index 5494f0eca3..1046fe09d0 100644 --- a/bacula/src/dird/dird_conf.c +++ b/bacula/src/dird/dird_conf.c @@ -24,7 +24,7 @@ /* Bacula® - The Network Backup Solution - Copyright (C) 2000-2006 Free Software Foundation Europe e.V. + Copyright (C) 2000-2007 Free Software Foundation Europe e.V. The main author of Bacula is Kern Sibbald, with contributions from many others, a complete list can be found in the file AUTHORS. diff --git a/bacula/src/dird/dird_conf.h b/bacula/src/dird/dird_conf.h index 020a086ffe..6cecf73937 100644 --- a/bacula/src/dird/dird_conf.h +++ b/bacula/src/dird/dird_conf.h @@ -8,7 +8,7 @@ /* Bacula® - The Network Backup Solution - Copyright (C) 2000-2006 Free Software Foundation Europe e.V. + Copyright (C) 2000-2007 Free Software Foundation Europe e.V. The main author of Bacula is Kern Sibbald, with contributions from many others, a complete list can be found in the file AUTHORS. diff --git a/bacula/src/dird/job.c b/bacula/src/dird/job.c index 1ca59f857f..83d06fcaed 100644 --- a/bacula/src/dird/job.c +++ b/bacula/src/dird/job.c @@ -882,6 +882,10 @@ void dird_free_jcr(JCR *jcr) pthread_cond_destroy(&jcr->term_wait); jcr->term_wait_inited = false; } + if (jcr->db) { + db_close_database(jcr, jcr->db); + jcr->db = NULL; + } if (jcr->stime) { Dmsg0(200, "Free JCR stime\n"); free_pool_memory(jcr->stime); diff --git a/bacula/src/dird/jobq.c b/bacula/src/dird/jobq.c index 03230dae10..780b2f258f 100755 --- a/bacula/src/dird/jobq.c +++ b/bacula/src/dird/jobq.c @@ -558,10 +558,6 @@ void *jobq_server(void *arg) Dmsg0(2300, "Back from running new job.\n"); } /* Clean up and release old jcr */ - if (jcr->db) { - db_close_database(jcr, jcr->db); - jcr->db = NULL; - } Dmsg2(2300, "====== Termination job=%d use_cnt=%d\n", jcr->JobId, jcr->use_count()); jcr->SDJobStatus = 0; V(jq->mutex); /* release internal lock */ diff --git a/bacula/src/dird/migrate.c b/bacula/src/dird/migrate.c index 11d497b546..6d21bd8a4a 100644 --- a/bacula/src/dird/migrate.c +++ b/bacula/src/dird/migrate.c @@ -1002,6 +1002,9 @@ static bool regex_find_jobids(JCR *jcr, idpkt *ids, const char *query1, bail_out: Dmsg2(dbglevel, "Count=%d Jobids=%s\n", ids->count, ids->list); + foreach_dlist(item, item_chain) { + free(item->item); + } delete item_chain; return ok; } diff --git a/bacula/src/dird/protos.h b/bacula/src/dird/protos.h index 31761cd19f..fcdaa11d4c 100644 --- a/bacula/src/dird/protos.h +++ b/bacula/src/dird/protos.h @@ -6,7 +6,7 @@ /* Bacula® - The Network Backup Solution - Copyright (C) 2000-2006 Free Software Foundation Europe e.V. + Copyright (C) 2000-2007 Free Software Foundation Europe e.V. The main author of Bacula is Kern Sibbald, with contributions from many others, a complete list can be found in the file AUTHORS. diff --git a/bacula/src/findlib/find.c b/bacula/src/findlib/find.c index c4bd014adf..75da814b49 100644 --- a/bacula/src/findlib/find.c +++ b/bacula/src/findlib/find.c @@ -119,14 +119,14 @@ get_win32_driveletters(FF_PKT *ff, char* szDrives) findFILESET *fileset = ff->fileset; if (fileset) { - int i, j; + int i; + char *fname; for (i=0; iinclude_list.size(); i++) { findINCEXE *incexe = (findINCEXE *)fileset->include_list.get(i); /* look through all files and check */ - for (j=0; jname_list.size(); j++) { - char *fname = (char *)incexe->name_list.get(j); + foreach_alist(fname, &incexe->name_list) { /* fname should match x:/ */ if (strlen(fname) >= 2 && B_ISALPHA(fname[0]) && fname[1] == ':') { @@ -190,9 +190,10 @@ find_files(JCR *jcr, FF_PKT *ff, int callback(FF_PKT *ff_pkt, void *hpkt, bool t ff->drivetypes = fo->drivetype; bstrncat(ff->VerifyOpts, fo->VerifyOpts, sizeof(ff->VerifyOpts)); } - for (j=0; jname_list.size(); j++) { - Dmsg1(100, "F %s\n", (char *)incexe->name_list.get(j)); - ff->top_fname = (char *)incexe->name_list.get(j); + char *fname; + foreach_alist(fname, &incexe->name_list) { + Dmsg1(100, "F %s\n", fname); + ff->top_fname = fname; if (find_one_file(jcr, ff, our_callback, his_pkt, ff->top_fname, (dev_t)-1, true) == 0) { return 0; /* error return */ } @@ -339,8 +340,9 @@ static bool accept_file(FF_PKT *ff) } fnm_flags = (incexe->current_opts != NULL && incexe->current_opts->flags & FO_IGNORECASE) ? FNM_CASEFOLD : 0; - for (j=0; jname_list.size(); j++) { - if (fnmatch((char *)incexe->name_list.get(j), ff->fname, fnmode|fnm_flags) == 0) { + char *fname; + foreach_alist(fname, &incexe->name_list) { + if (fnmatch(fname, ff->fname, fnmode|fnm_flags) == 0) { Dmsg1(100, "Reject wild2: %s\n", ff->fname); return false; /* reject file */ } diff --git a/bacula/src/lib/btree.c b/bacula/src/lib/btree.c deleted file mode 100644 index c17fe143a2..0000000000 --- a/bacula/src/lib/btree.c +++ /dev/null @@ -1,490 +0,0 @@ -/* - * Bacula red-black binary tree routines. - * - * btree is a binary tree with the links being in the data item. - * - * Developped in part from ideas obtained from several online University - * courses. - * - * Kern Sibbald, November MMV - * - * Version $Id$ - * - */ -/* - Bacula® - The Network Backup Solution - - Copyright (C) 2005-2006 Free Software Foundation Europe e.V. - - The main author of Bacula is Kern Sibbald, with contributions from - many others, a complete list can be found in the file AUTHORS. - This program is Free Software; you can redistribute it and/or - modify it under the terms of version two of the GNU General Public - License as published by the Free Software Foundation plus additions - that are listed in the file LICENSE. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - - Bacula® is a registered trademark of John Walker. - The licensor of Bacula is the Free Software Foundation Europe - (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich, - Switzerland, email:ftf@fsfeurope.org. -*/ - -#include "bacula.h" -#include "btree.h" - -/* =================================================================== - * btree - */ - -/* - * Insert an item in the tree, but only if it is unique - * otherwise, the item is returned non inserted - * The big trick is keeping the tree balanced after the - * insert. We use a parent pointer to make it simpler and - * to avoid recursion. - * - * Returns: item if item inserted - * other_item if same value already exists (item not inserted) - */ -bnode *btree::insert(bnode *item, int compare(bnode *item1, bnode *item2)) -{ - bnode *x, *y; - bnode *last = NULL; /* last leaf if not found */ - bnode *found = NULL; - int comp = 0; - - /* Search */ - x = head; - while (x && !found) { - last = x; - comp = compare(item, x); - if (comp < 0) { - x = x->left; - } else if (comp > 0) { - x = x->right; - } else { - found = x; - } - } - - if (found) { /* found? */ - return found; /* yes, return item found */ - } - /* Handle empty tree */ - if (num_items == 0) { - head = item; - num_items++; - return item; - } - x = last; - /* Not found, so insert it on appropriate side of tree */ - if (comp < 0) { - last->left = item; - } else { - last->right = item; - } - last->red = true; - item->parent = last; - num_items++; - - /* Now we must walk up the tree balancing it */ - x = last; - while (x != head && x->parent->red) { - if (x->parent == x->parent->parent->left) { - /* Look at the right side of our grandparent */ - y = x->parent->parent->right; - if (y && y->red) { - /* our parent must be black */ - x->parent->red = false; - y->red = false; - x->parent->parent->red = true; - x = x->parent->parent; /* move up to grandpa */ - } else { - if (x == x->parent->right) { /* right side of parent? */ - x = x->parent; - left_rotate(x); - } - /* make parent black too */ - x->parent->red = false; - x->parent->parent->red = true; - right_rotate(x->parent->parent); - } - } else { - /* Look at left side of our grandparent */ - y = x->parent->parent->left; - if (y && y->red) { - x->parent->red = false; - y->red = false; - x->parent->parent->red = true; - x = x->parent->parent; /* move up to grandpa */ - } else { - if (x == x->parent->left) { - x = x->parent; - right_rotate(x); - } - /* make parent black too */ - x->parent->red = false; - x->parent->parent->red = true; - left_rotate(x->parent->parent); - } - } - } - /* Make sure the head is always black */ - head->red = false; - return item; -} - - -/* - * Search for item - */ -bnode *btree::search(bnode *item, int compare(bnode *item1, bnode *item2)) -{ - bnode *found = NULL; - bnode *x; - int comp; - - x = head; - while (x) { - comp = compare(item, x); - if (comp < 0) { - x = x->left; - } else if (comp > 0) { - x = x->right; - } else { - found = x; - break; - } - } - return found; -} - -/* - * Get first item (i.e. lowest value) - */ -bnode *btree::first(void) -{ - bnode *x; - - x = head; - down = true; - while (x) { - if (x->left) { - x = x->left; - continue; - } - return x; - } - /* Tree is empty */ - return NULL; -} - -/* - * This is a non-recursive btree walk routine that returns - * the items one at a time in order. I've never seen a - * non-recursive tree walk routine published that returns - * one item at a time rather than doing a callback. - * - * Return the next item in sorted order. We assume first() - * was called once before calling this routine. - * We always go down as far as we can to the left, then up, and - * down one to the right, and again down as far as we can to the - * left. etc. - * - * Returns: pointer to next larger item - * NULL when no more items in tree - */ -bnode *btree::next(bnode *item) -{ - bnode *x; - - x = item; - if ((down && !x->left && x->right) || (!down && x->right)) { - /* Move down to right one */ - down = true; - x = x->right; - /* Then all the way down left */ - while (x->left) { - x = x->left; - } - return x; - } - - /* We have gone down all we can, so now go up */ - for ( ;; ) { - /* If at head, we are done */ - if (!x->parent) { - return NULL; - } - /* Move up in tree */ - down = false; - /* if coming from right, continue up */ - if (x->parent->right == x) { - x = x->parent; - continue; - } - /* Coming from left, go up one -- ie. return parent */ - return x->parent; - } -} - -/* - * Similer to next(), but visits all right nodes when - * coming up the tree. - */ -bnode *btree::any(bnode *item) -{ - bnode *x; - - x = item; - if ((down && !x->left && x->right) || (!down && x->right)) { - /* Move down to right one */ - down = true; - x = x->right; - /* Then all the way down left */ - while (x->left) { - x = x->left; - } - return x; - } - - /* We have gone down all we can, so now go up */ - for ( ;; ) { - /* If at head, we are done */ - if (!x->parent) { - return NULL; - } - down = false; - /* Go up one and return parent */ - return x->parent; - } -} - - -/* x is item, y is below and to right, then rotated to below left */ -void btree::left_rotate(bnode *item) -{ - bnode *y; - bnode *x; - - x = item; - y = x->right; - x->right = y->left; - if (y->left) { - y->left->parent = x; - } - y->parent = x->parent; - /* if no parent then we have a new head */ - if (!x->parent) { - head = y; - } else if (x == x->parent->left) { - x->parent->left = y; - } else { - x->parent->right = y; - } - y->left = x; - x->parent = y; -} - -void btree::right_rotate(bnode *item) -{ - bnode *x, *y; - - y = item; - x = y->left; - y->left = x->right; - if (x->right) { - x->right->parent = y; - } - x->parent = y->parent; - /* if no parent then we have a new head */ - if (!y->parent) { - head = x; - } else if (y == y->parent->left) { - y->parent->left = x; - } else { - y->parent->right = x; - } - x->right = y; - y->parent = x; -} - - -void btree::remove(bnode *item) -{ -} - -/* Destroy the tree contents. Not totally working */ -void btree::destroy() -{ - bnode *x, *y = NULL; - - x = first(); -// printf("head=%p first=%p left=%p right=%p\n", head, x, x->left, x->right); - - for ( ; (y=any(x)); ) { - /* Prune the last item */ - if (x->parent) { - if (x == x->parent->left) { - x->parent->left = NULL; - } else if (x == x->parent->right) { - x->parent->right = NULL; - } - } - if (!x->left && !x->right) { - if (head == x) { - head = NULL; - } -// if (num_items<30) { -// printf("free nitems=%d item=%p left=%p right=%p\n", num_items, x, x->left, x->right); -// } - free((void *)x); /* free previous node */ - num_items--; - } - x = y; /* save last node */ - } - if (x) { - if (x == head) { - head = NULL; - } -// printf("free nitems=%d item=%p left=%p right=%p\n", num_items, x, x->left, x->right); - free((void *)x); - num_items--; - } - if (head) { -// printf("Free head\n"); - free((void *)head); - } -// printf("free nitems=%d\n", num_items); - - head = NULL; -} - - - -#ifdef TEST_PROGRAM - -struct MYJCR { - bnode link; - char *buf; -}; - -static int my_compare(bnode *item1, bnode *item2) -{ - MYJCR *jcr1, *jcr2; - int comp; - jcr1 = (MYJCR *)item1; - jcr2 = (MYJCR *)item2; - comp = strcmp(jcr1->buf, jcr2->buf); - //Dmsg3(000, "compare=%d: %s to %s\n", comp, jcr1->buf, jcr2->buf); - return comp; -} - -int main() -{ - char buf[30]; - btree *jcr_chain; - MYJCR *jcr = NULL; - MYJCR *jcr1; - - - /* Now do a binary insert for the tree */ - jcr_chain = New(btree()); -#define CNT 26 - printf("append %d items\n", CNT*CNT*CNT); - strcpy(buf, "ZZZ"); - int count = 0; - for (int i=0; ibuf = bstrdup(buf); -// printf("buf=%p %s\n", jcr, jcr->buf); - jcr1 = (MYJCR *)jcr_chain->insert((bnode *)jcr, my_compare); - if (jcr != jcr1) { - Dmsg2(000, "Insert of %s vs %s failed.\n", jcr->buf, jcr1->buf); - } - buf[1]--; - } - buf[1] = 'Z'; - buf[2]--; - } - buf[2] = 'Z'; - buf[0]--; - } - printf("%d items appended\n", CNT*CNT*CNT); - printf("num_items=%d\n", jcr_chain->size()); - - jcr = (MYJCR *)malloc(sizeof(MYJCR)); - memset(jcr, 0, sizeof(MYJCR)); - - jcr->buf = bstrdup("a"); - if ((jcr1=(MYJCR *)jcr_chain->search((bnode *)jcr, my_compare))) { - printf("One less failed!!!! Got: %s\n", jcr1->buf); - } else { - printf("One less: OK\n"); - } - free(jcr->buf); - - jcr->buf = bstrdup("ZZZZZZZZZZZZZZZZ"); - if ((jcr1=(MYJCR *)jcr_chain->search((bnode *)jcr, my_compare))) { - printf("One greater failed!!!! Got:%s\n", jcr1->buf); - } else { - printf("One greater: OK\n"); - } - free(jcr->buf); - - jcr->buf = bstrdup("AAA"); - if ((jcr1=(MYJCR *)jcr_chain->search((bnode *)jcr, my_compare))) { - printf("Search for AAA got %s\n", jcr1->buf); - } else { - printf("Search for AAA not found\n"); - } - free(jcr->buf); - - jcr->buf = bstrdup("ZZZ"); - if ((jcr1 = (MYJCR *)jcr_chain->search((bnode *)jcr, my_compare))) { - printf("Search for ZZZ got %s\n", jcr1->buf); - } else { - printf("Search for ZZZ not found\n"); - } - free(jcr->buf); - free(jcr); - - - printf("Find each of %d items in tree.\n", count); - for (jcr=(MYJCR *)jcr_chain->first(); jcr; (jcr=(MYJCR *)jcr_chain->next((bnode *)jcr)) ) { -// printf("Got: %s\n", jcr->buf); - if (!jcr_chain->search((bnode *)jcr, my_compare)) { - printf("btree binary_search item not found = %s\n", jcr->buf); - } - } - printf("Free each of %d items in tree.\n", count); - for (jcr=(MYJCR *)jcr_chain->first(); jcr; (jcr=(MYJCR *)jcr_chain->next((bnode *)jcr)) ) { -// printf("Free: %p %s\n", jcr, jcr->buf); - free(jcr->buf); - jcr->buf = NULL; - } - printf("num_items=%d\n", jcr_chain->size()); - delete jcr_chain; - - - sm_dump(true); - -} -#endif diff --git a/bacula/src/lib/btree.h b/bacula/src/lib/btree.h deleted file mode 100644 index 23e79a9be9..0000000000 --- a/bacula/src/lib/btree.h +++ /dev/null @@ -1,107 +0,0 @@ -/* - * Version $Id$ - */ -/* - Bacula® - The Network Backup Solution - - Copyright (C) 2005-2006 Free Software Foundation Europe e.V. - - The main author of Bacula is Kern Sibbald, with contributions from - many others, a complete list can be found in the file AUTHORS. - This program is Free Software; you can redistribute it and/or - modify it under the terms of version two of the GNU General Public - License as published by the Free Software Foundation plus additions - that are listed in the file LICENSE. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - - Bacula® is a registered trademark of John Walker. - The licensor of Bacula is the Free Software Foundation Europe - (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich, - Switzerland, email:ftf@fsfeurope.org. -*/ - - -/* ======================================================================== - * - * red-black binary tree routines -- btree.h - * - * Kern Sibbald, MMV - * - */ - -#define M_ABORT 1 - -/* - * There is a lot of extra casting here to work around the fact - * that some compilers (Sun and Visual C++) do not accept - * (bnode *) as an lvalue on the left side of an equal. - * - * Loop var through each member of list - */ -#define foreach_btree(var, tree) \ - for(*((bnode **)&(var))=(tree)->first(); (*((bnode **)&(var))=(tree)->next((bnode *)var)); ) - -#ifdef the_old_way -#define foreach_btree(var, tree) \ - for((var)=(tree)->first(); (((bnode *)(var))=(tree)->next((bnode *)var)); ) -#endif - -struct bnode; -struct bnode { - bnode *left; - bnode *right; - bnode *parent; - bool red; -}; - -class btree : public SMARTALLOC { - bnode *head; - uint32_t num_items; - bool down; - void left_rotate(bnode *item); - void right_rotate(bnode *item); -public: - btree(void); - ~btree() { destroy(); } - void init(void); - bnode *insert(bnode *item, int compare(bnode *item1, bnode *item2)); - bnode *search(bnode *item, int compare(bnode *item1, bnode *item2)); - bnode *first(void); - bnode *next(bnode *item); - bnode *any(bnode *item); - void remove(bnode *item); - int size() const; - void destroy(); -}; - - -/* - * This allows us to do explicit initialization, - * allowing us to mix C++ classes inside malloc'ed - * C structures. Define before called in constructor. - */ -inline void btree::init() -{ - head = NULL; - num_items = 0; -} - - -/* Constructor with link at head of item */ -inline btree::btree(void) : head(0), num_items(0) -{ -} - -inline int btree::size() const -{ - return num_items; -} diff --git a/bacula/src/lib/lib.h b/bacula/src/lib/lib.h index 671e066b41..37a8c2b4bc 100644 --- a/bacula/src/lib/lib.h +++ b/bacula/src/lib/lib.h @@ -10,7 +10,7 @@ /* Bacula® - The Network Backup Solution - Copyright (C) 2000-2006 Free Software Foundation Europe e.V. + Copyright (C) 2000-2007 Free Software Foundation Europe e.V. The main author of Bacula is Kern Sibbald, with contributions from many others, a complete list can be found in the file AUTHORS. @@ -38,6 +38,7 @@ #include "smartall.h" #include "alist.h" #include "dlist.h" +#include "rblist.h" #include "base64.h" #include "bits.h" #include "btime.h" diff --git a/bacula/src/lib/parse_conf.h b/bacula/src/lib/parse_conf.h index 75a8dd8d8c..a5d53c9584 100644 --- a/bacula/src/lib/parse_conf.h +++ b/bacula/src/lib/parse_conf.h @@ -4,7 +4,7 @@ /* Bacula® - The Network Backup Solution - Copyright (C) 2000-2006 Free Software Foundation Europe e.V. + Copyright (C) 2000-2007 Free Software Foundation Europe e.V. The main author of Bacula is Kern Sibbald, with contributions from many others, a complete list can be found in the file AUTHORS. diff --git a/bacula/src/stored/acquire.c b/bacula/src/stored/acquire.c index e673bd7669..9fa9f79c95 100644 --- a/bacula/src/stored/acquire.c +++ b/bacula/src/stored/acquire.c @@ -66,7 +66,7 @@ bool acquire_device_for_read(DCR *dcr) dev->block(BST_DOING_ACQUIRE); if (dev->num_writers > 0) { - Jmsg2(jcr, M_FATAL, 0, _("Num_writers=%d not zero. Job %d canceled.\n"), + Jmsg2(jcr, M_FATAL, 0, _("Acquire read: num_writers=%d not zero. Job %d canceled.\n"), dev->num_writers, jcr->JobId); goto get_out; } @@ -75,7 +75,7 @@ bool acquire_device_for_read(DCR *dcr) vol = jcr->VolList; if (!vol) { char ed1[50]; - Jmsg(jcr, M_FATAL, 0, _("No volumes specified. Job %s canceled.\n"), + Jmsg(jcr, M_FATAL, 0, _("No volumes specified for reading. Job %s canceled.\n"), edit_int64(jcr->JobId, ed1)); goto get_out; } @@ -84,7 +84,7 @@ bool acquire_device_for_read(DCR *dcr) vol = vol->next; } if (!vol) { - Jmsg(jcr, M_FATAL, 0, _("Logic error: no next volume. Numvol=%d Curvol=%d\n"), + Jmsg(jcr, M_FATAL, 0, _("Logic error: no next volume to read. Numvol=%d Curvol=%d\n"), jcr->NumReadVolumes, jcr->CurReadVolume); goto get_out; /* should not happen */ } @@ -268,7 +268,7 @@ default_path: break; } /* end for loop */ if (!ok) { - Jmsg1(jcr, M_FATAL, 0, _("Too many errors trying to mount device %s.\n"), + Jmsg1(jcr, M_FATAL, 0, _("Too many errors trying to mount device %s for reading.\n"), dev->print_name()); goto get_out; } @@ -321,8 +321,8 @@ DCR *acquire_device_for_append(DCR *dcr) * With the reservation system, this should not happen */ if (dev->can_read()) { - Jmsg1(jcr, M_FATAL, 0, _("Device %s is busy reading.\n"), dev->print_name()); - Dmsg1(200, "Device %s is busy reading.\n", dev->print_name()); + Jmsg1(jcr, M_FATAL, 0, _("Want to append, but device %s is busy reading.\n"), dev->print_name()); + Dmsg1(200, "Want to append but device %s is busy reading.\n", dev->print_name()); goto get_out; } @@ -351,9 +351,9 @@ DCR *acquire_device_for_append(DCR *dcr) free_unused_volume(dcr); } if (dev->num_writers != 0) { - Jmsg3(jcr, M_FATAL, 0, _("Wanted Volume \"%s\", but device %s is busy writing on \"%s\" .\n"), + Jmsg3(jcr, M_FATAL, 0, _("Wanted to append to Volume \"%s\", but device %s is busy writing on \"%s\" .\n"), dcr->VolumeName, dev->print_name(), dev->VolHdr.VolumeName); - Dmsg3(200, "Wanted Volume \"%s\", but device %s is busy writing on \"%s\" .\n", + Dmsg3(200, "Wanted to append to Volume \"%s\", but device %s is busy writing on \"%s\" .\n", dcr->VolumeName, dev->print_name(), dev->VolHdr.VolumeName); goto get_out; } diff --git a/bacula/src/version.h b/bacula/src/version.h index 2461938a3f..b6db5b3f36 100644 --- a/bacula/src/version.h +++ b/bacula/src/version.h @@ -3,9 +3,9 @@ */ #undef VERSION -#define VERSION "2.0.2" -#define BDATE "28 January 2007" -#define LSMDATE "28Jan07" +#define VERSION "2.0.3" +#define BDATE "06 February 2007" +#define LSMDATE "06Feb07" #define PROG_COPYRIGHT "Copyright (C) %d-2007 Free Software Foundation Europe e.V.\n" #define BYEAR "2007" /* year for copyright messages in progs */ diff --git a/bacula/src/win32/dll/Makefile b/bacula/src/win32/dll/Makefile index b2cf711125..1925463f17 100644 --- a/bacula/src/win32/dll/Makefile +++ b/bacula/src/win32/dll/Makefile @@ -58,7 +58,6 @@ LIB_OBJS = \ $(OBJDIR)/bsys.o \ $(OBJDIR)/btime.o \ $(OBJDIR)/btimers.o \ - $(OBJDIR)/btree.o \ $(OBJDIR)/cram-md5.o \ $(OBJDIR)/crc32.o \ $(OBJDIR)/crypto.o \ @@ -78,6 +77,7 @@ LIB_OBJS = \ $(OBJDIR)/openssl.o \ $(OBJDIR)/pythonlib.o \ $(OBJDIR)/queue.o \ + $(OBJDIR)/rblist.o \ $(OBJDIR)/runscript.o \ $(OBJDIR)/rwlock.o \ $(OBJDIR)/scan.o \ diff --git a/bacula/src/win32/dll/bacula.def b/bacula/src/win32/dll/bacula.def index c06ae29750..4304031129 100644 --- a/bacula/src/win32/dll/bacula.def +++ b/bacula/src/win32/dll/bacula.def @@ -220,8 +220,6 @@ _Z17start_bsock_timerP5BSOCKj _Z17stop_thread_timerP10s_btimer_t _Z18start_thread_timerP10pthread_t_j -; btree.c: - ; cram-md5.c: _Z16cram_md5_respondP5BSOCKPcPiS2_ _Z18cram_md5_challengeP5BSOCKPcii @@ -391,6 +389,14 @@ _Z5qnextP7b_queueS0_ _Z7qdchainP7b_queue _Z7qinsertP7b_queueS0_ +; rblist.c: +_ZN6rblist4nextEPv +_ZN6rblist5firstEv +_ZN6rblist6insertEPvPFiS0_S0_E +_ZN6rblist6removeEPv +_ZN6rblist6searchEPvPFiS0_S0_E +_ZN6rblist7destroyEv + ; runscript.c: _Z11run_scriptsP3JCRP5alistPKc _Z13new_runscriptv diff --git a/bacula/src/win32/libbac/Makefile b/bacula/src/win32/libbac/Makefile index 28c94f8df5..993c22ad6a 100644 --- a/bacula/src/win32/libbac/Makefile +++ b/bacula/src/win32/libbac/Makefile @@ -41,7 +41,6 @@ LIB_OBJS = \ $(OBJDIR)/bsys.o \ $(OBJDIR)/btime.o \ $(OBJDIR)/btimers.o \ - $(OBJDIR)/btree.o \ $(OBJDIR)/cram-md5.o \ $(OBJDIR)/crc32.o \ $(OBJDIR)/crypto.o \ @@ -62,6 +61,7 @@ LIB_OBJS = \ $(OBJDIR)/parse_conf.o \ $(OBJDIR)/pythonlib.o \ $(OBJDIR)/queue.o \ + $(OBJDIR)/rblist.o \ $(OBJDIR)/res.o \ $(OBJDIR)/runscript.o \ $(OBJDIR)/rwlock.o \ diff --git a/bacula/technotes-2.0 b/bacula/technotes-2.0 index 488dac11dd..572a2827ad 100644 --- a/bacula/technotes-2.0 +++ b/bacula/technotes-2.0 @@ -1,9 +1,40 @@ Technical notes on version 2.0 General: -Version 2.0.2 released: xx January 2007 +06Feb07 +kes Delete src/lib/btree.c from win32 build, then add rblist.c + plus the entrypoints. +kes Apply patch supplied that corrects debug print + in canceling jobs for max run time. Supplied as + part of bug #621, which was previously fixed. 05Feb07 -ebl Fixes bug #766 about RunsOnClient = Yes +kes Test on job_canceled() and sd_msg_thread_done inside + loop starting the message thread to avoid a race condition. + Fixes bug #771. +kes Remove rl_catch_signal from console.c as it conflicted + with the header definition. Fixes bug #765. +ebl Fixes bug #766 about RunsOnClient = Yes +04Feb07 +kes Clarify some stored/acquire messages to indicate if the + problem is with read or append. +02Feb07 +kes Fix memory leak with storage ids in cats/sql_get.c +kes Terminate watchdog earlier to avoid reference to released + memory -- reported by Jason Austin. +kes Move closing the database from jobq.c to the director daemon + termination routine. This fixes memory leaks for shadow jobs + (i.e. migration jobs). +kes Free up the unique jobid chain items in migrate.c. This fixes + a memory leak problem. +kes Convert some ugly looking for statements to use foreach_alist + in findlib/find.c. This will facilitate converting the structures + to use dlist (for large include/exclude lists). +kes Fix a bug in the btree.c and btree.h routines, then rename them + rblist and add them to be built in src/lib. Include some new + methods written by Rudolf Cejka that make the code more readable + (hides some of the ugly casting). + +Version 2.0.2 released: 30 January 2007 28Jan08 kes Fix maxruntime bug #621. 27Jan07 -- 2.39.5