From b9c369590773781b98db38ffc83df1a5ed20f4e4 Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Thu, 24 May 2007 09:42:42 +0000 Subject: [PATCH] kes Add additional sm_check() code on debug level 1. kes Set default debug level to 1. kes Trap SIGABRT in attempt to get traceback. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@4888 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/src/baconfig.h | 14 +++++------ bacula/src/dird/catreq.c | 2 ++ bacula/src/dird/dird.c | 2 +- bacula/src/dird/job.c | 4 ++- bacula/src/filed/job.c | 1 + bacula/src/lib/message.c | 2 +- bacula/src/lib/signal.c | 2 +- bacula/src/lib/smartall.c | 52 +++++++++++++++++++-------------------- bacula/src/lib/smartall.h | 16 ++++++------ bacula/src/stored/dev.c | 4 +-- bacula/src/stored/job.c | 2 ++ bacula/src/version.h | 4 +-- bacula/technotes-2.1 | 4 +++ 13 files changed, 61 insertions(+), 48 deletions(-) diff --git a/bacula/src/baconfig.h b/bacula/src/baconfig.h index dd7c223ebd..7f733cd03b 100644 --- a/bacula/src/baconfig.h +++ b/bacula/src/baconfig.h @@ -1,13 +1,7 @@ -/* - * General header file configurations that apply to - * all daemons. System dependent stuff goes here. - * - * Version $Id$ - */ /* 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. @@ -31,6 +25,12 @@ (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich, Switzerland, email:ftf@fsfeurope.org. */ +/* + * General header file configurations that apply to + * all daemons. System dependent stuff goes here. + * + * Version $Id$ + */ #ifndef _BACONFIG_H diff --git a/bacula/src/dird/catreq.c b/bacula/src/dird/catreq.c index 23e3795f21..a62dea0b1b 100644 --- a/bacula/src/dird/catreq.c +++ b/bacula/src/dird/catreq.c @@ -117,6 +117,7 @@ void catalog_request(JCR *jcr, BSOCK *bs) memset(&mr, 0, sizeof(mr)); memset(&sdmr, 0, sizeof(sdmr)); memset(&jm, 0, sizeof(jm)); + Dsm_check(1); /* * Request to find next appendable Volume for this Job @@ -356,6 +357,7 @@ void catalog_update(JCR *jcr, BSOCK *bs) ATTR_DBR *ar = NULL; POOLMEM *omsg; + Dsm_check(1); if (!jcr->pool->catalog_files) { return; /* user disabled cataloging */ } diff --git a/bacula/src/dird/dird.c b/bacula/src/dird/dird.c index 64e94d82ab..6f92ba9aeb 100644 --- a/bacula/src/dird/dird.c +++ b/bacula/src/dird/dird.c @@ -153,7 +153,7 @@ int main (int argc, char *argv[]) if (debug_level <= 0) { debug_level = 1; } - Dmsg1(0, "Debug level = %d\n", debug_level); + Dmsg1(10, "Debug level = %d\n", debug_level); break; case 'f': /* run in foreground */ diff --git a/bacula/src/dird/job.c b/bacula/src/dird/job.c index 5e6a233421..c4f3ca1356 100644 --- a/bacula/src/dird/job.c +++ b/bacula/src/dird/job.c @@ -213,6 +213,7 @@ bool setup_job(JCR *jcr) } generate_job_event(jcr, "JobInit"); + Dsm_check(1); return true; bail_out: @@ -238,7 +239,7 @@ static void *job_thread(void *arg) jcr->my_thread_id = pthread_self(); pthread_detach(jcr->my_thread_id); - sm_check(__FILE__, __LINE__, true); + Dsm_check(1); Dmsg0(200, "=====Start Job=========\n"); set_jcr_job_status(jcr, JS_Running); /* this will be set only if no error */ @@ -440,6 +441,7 @@ static void job_monitor_watchdog(watchdog_t *self) control_jcr = (JCR *)self->data; + Dsm_check(1); Dmsg1(800, "job_monitor_watchdog %p called\n", self); foreach_jcr(jcr) { diff --git a/bacula/src/filed/job.c b/bacula/src/filed/job.c index 6e78537d38..cfb569317f 100644 --- a/bacula/src/filed/job.c +++ b/bacula/src/filed/job.c @@ -340,6 +340,7 @@ void *handle_client_request(void *dirp) Dmsg0(100, "Done with term_find_files\n"); free_jcr(jcr); /* destroy JCR record */ Dmsg0(100, "Done with free_jcr\n"); + Dsm_check(1); return NULL; } diff --git a/bacula/src/lib/message.c b/bacula/src/lib/message.c index 2c3cd90cd9..fc9a9cc26b 100644 --- a/bacula/src/lib/message.c +++ b/bacula/src/lib/message.c @@ -49,7 +49,7 @@ sql_escape p_sql_escape = NULL; */ const char *working_directory = NULL; /* working directory path stored here */ int verbose = 0; /* increase User messages */ -int debug_level = 0; /* debug level */ +int debug_level = 1; /* debug level */ time_t daemon_start_time = 0; /* Daemon start time */ const char *version = VERSION " (" BDATE ")"; char my_name[30]; /* daemon name is stored here */ diff --git a/bacula/src/lib/signal.c b/bacula/src/lib/signal.c index 68442ddc23..f5a624af82 100644 --- a/bacula/src/lib/signal.c +++ b/bacula/src/lib/signal.c @@ -296,7 +296,7 @@ void init_signals(void terminate(int sig)) sigaction(SIGQUIT, &sighandle, NULL); sigaction(SIGILL, &sighandle, NULL); sigaction(SIGTRAP, &sighandle, NULL); -/* sigaction(SIGABRT, &sighandle, NULL); */ + sigaction(SIGABRT, &sighandle, NULL); #ifdef SIGEMT sigaction(SIGEMT, &sighandle, NULL); #endif diff --git a/bacula/src/lib/smartall.c b/bacula/src/lib/smartall.c index f991ceefdf..11ca3dd656 100644 --- a/bacula/src/lib/smartall.c +++ b/bacula/src/lib/smartall.c @@ -1,22 +1,3 @@ -/* - - S M A R T A L L O C - Smart Memory Allocator - - Evolved over several years, starting with the initial - SMARTALLOC code for AutoSketch in 1986, guided by the Blind - Watchbreaker, John Walker. Isolated in this general-purpose - form in September of 1989. Updated with be more POSIX - compliant and to include Web-friendly HTML documentation in - October of 1998 by the same culprit. For additional - information and the current version visit the Web page: - - http://www.fourmilab.ch/smartall/ - - - Version $Id$ - -*/ /* Bacula® - The Network Backup Solution @@ -44,6 +25,25 @@ (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich, Switzerland, email:ftf@fsfeurope.org. */ +/* + + S M A R T A L L O C + Smart Memory Allocator + + Evolved over several years, starting with the initial + SMARTALLOC code for AutoSketch in 1986, guided by the Blind + Watchbreaker, John Walker. Isolated in this general-purpose + form in September of 1989. Updated with be more POSIX + compliant and to include Web-friendly HTML documentation in + October of 1998 by the same culprit. For additional + information and the current version visit the Web page: + + http://www.fourmilab.ch/smartall/ + + + Version $Id$ + +*/ #include "bacula.h" /* Use the real routines here */ @@ -178,7 +178,7 @@ void sm_free(const char *file, int line, void *fp) } cp -= HEAD_SIZE; - qp = (struct b_queue *) cp; + qp = (struct b_queue *)cp; struct abufhead *head = (struct abufhead *)cp; P(mutex); @@ -425,10 +425,10 @@ void sm_dump(bool bufdump) /* SM_CHECK -- Check the buffers and dump if any damage exists. */ 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"), - fname, lineno); - } + if (!sm_check_rtn(fname, lineno, bufdump)) { + Emsg2(M_ABORT, 0, _("Damaged buffer found. Called from %s:%d\n"), + fname, lineno); + } } #undef sm_check_rtn @@ -518,9 +518,9 @@ int sm_check_rtn(const char *fname, int lineno, bool bufdump) that all the other safeguards still apply to buffers allocated when sm_static(1) mode is in effect. */ -void sm_static(int mode) +void sm_static(bool mode) { - bufimode = (bool) (mode != 0); + bufimode = mode; } /* diff --git a/bacula/src/lib/smartall.h b/bacula/src/lib/smartall.h index a698593567..5875db28c0 100644 --- a/bacula/src/lib/smartall.h +++ b/bacula/src/lib/smartall.h @@ -1,10 +1,3 @@ -/* - - Definitions for the smart memory allocator - - Version $Id$ - -*/ /* Bacula® - The Network Backup Solution @@ -32,6 +25,13 @@ (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich, Switzerland, email:ftf@fsfeurope.org. */ +/* + + Definitions for the smart memory allocator + + Version $Id$ + +*/ extern uint64_t DLL_IMP_EXP sm_max_bytes; extern uint64_t DLL_IMP_EXP sm_bytes; @@ -56,9 +56,11 @@ extern void actuallyfree(void *cp), extern void sm_new_owner(const char *fname, int lineno, char *buf); #ifdef SMCHECK +#define Dsm_check(lvl) if ((lvl)<=debug_level) sm_check(__FILE__, __LINE__, true) 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 Dsm_check(lvl, f, l, fl) #define sm_check(f, l, fl) #define sm_check_rtn(f, l, fl) 1 #endif diff --git a/bacula/src/stored/dev.c b/bacula/src/stored/dev.c index 14637c81e1..cd656ce723 100644 --- a/bacula/src/stored/dev.c +++ b/bacula/src/stored/dev.c @@ -2007,7 +2007,7 @@ bool DEVICE::do_mount(int mount, int dotimeout) char *icmd; int status, timeout; - sm_check(__FILE__, __LINE__, false); + Dsm_check(1); if (mount) { if (is_mounted()) { Dmsg0(200, "======= mount=1\n"); @@ -2128,9 +2128,9 @@ bool DEVICE::do_mount(int mount, int dotimeout) } get_out: set_mounted(false); - sm_check(__FILE__, __LINE__, false); free_pool_memory(results); Dmsg0(200, "============ mount=0\n"); + Dsm_check(1); return false; } diff --git a/bacula/src/stored/job.c b/bacula/src/stored/job.c index 856e531588..fe0389654f 100644 --- a/bacula/src/stored/job.c +++ b/bacula/src/stored/job.c @@ -150,6 +150,7 @@ bool run_cmd(JCR *jcr) struct timespec timeout; int errstat; + Dsm_check(1); Dmsg1(200, "Run_cmd: %s\n", jcr->dir_bsock->msg); /* The following jobs don't need the FD */ switch (jcr->JobType) { @@ -382,5 +383,6 @@ void stored_free_jcr(JCR *jcr) delete jcr->write_store; jcr->write_store = NULL; } + Dsm_check(1); return; } diff --git a/bacula/src/version.h b/bacula/src/version.h index 8d0d9d607a..27827ae4fc 100644 --- a/bacula/src/version.h +++ b/bacula/src/version.h @@ -4,8 +4,8 @@ #undef VERSION #define VERSION "2.1.11" -#define BDATE "22 May 2007" -#define LSMDATE "22May07" +#define BDATE "24 May 2007" +#define LSMDATE "24May07" #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/technotes-2.1 b/bacula/technotes-2.1 index ae7ba36629..d3f40e44bc 100644 --- a/bacula/technotes-2.1 +++ b/bacula/technotes-2.1 @@ -1,6 +1,10 @@ Technical notes on version 2.1 General: +24May07 +kes Add additional sm_check() code on debug level 1. +kes Set default debug level to 1. +kes Trap SIGABRT in attempt to get traceback. 23May07 kes Reduce bat connect timeout from 30 to 15 seconds. kes More restructuring and implementing BSOCK class in place of -- 2.39.5