From: Kern Sibbald Date: Sat, 22 Jun 2002 20:41:45 +0000 (+0000) Subject: Documentation, fix watchdog.c -- kes22Jun02 X-Git-Tag: Release-1.22~5 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=42c78fbc0d08c3059855cfe98197d318228a7457;p=bacula%2Fbacula Documentation, fix watchdog.c -- kes22Jun02 git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@48 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/src/dird/ua_cmds.c b/bacula/src/dird/ua_cmds.c index f8de24d92d..b2ed0c0f63 100644 --- a/bacula/src/dird/ua_cmds.c +++ b/bacula/src/dird/ua_cmds.c @@ -341,6 +341,7 @@ static int cancelcmd(UAContext *ua, char *cmd) free_locked_jcr(jcr); } unlock_jcr_chain(); + if (njobs == 0) { bsendmsg(ua, _("No Jobs running.\n")); return 1; @@ -356,6 +357,7 @@ static int cancelcmd(UAContext *ua, char *cmd) free_locked_jcr(jcr); } unlock_jcr_chain(); + if (do_prompt(ua, _("Choose Job to cancel"), JobName) < 0) { return 1; } diff --git a/bacula/src/lib/jcr.c b/bacula/src/lib/jcr.c index eec5fcd7b8..6657dffeda 100755 --- a/bacula/src/lib/jcr.c +++ b/bacula/src/lib/jcr.c @@ -50,14 +50,8 @@ JCR *new_jcr(int size, JCR_free_HANDLER *daemon_free_jcr) jcr = (JCR *) malloc(size); memset(jcr, 0, size); jcr->my_thread_id = pthread_self(); - P(mutex); jcr->sched_time = time(NULL); jcr->daemon_free_jcr = daemon_free_jcr; /* plug daemon free routine */ - jcr->prev = NULL; - jcr->next = jobs; - if (jobs) { - jobs->prev = jcr; - } jcr->use_count = 1; pthread_mutex_init(&(jcr->mutex), NULL); jcr->JobStatus = JS_Created; /* ready to run */ @@ -65,6 +59,13 @@ JCR *new_jcr(int size, JCR_free_HANDLER *daemon_free_jcr) jcr->VolumeName[0] = 0; jcr->errmsg = get_pool_memory(PM_MESSAGE); jcr->errmsg[0] = 0; + + P(mutex); + jcr->prev = NULL; + jcr->next = jobs; + if (jobs) { + jobs->prev = jcr; + } jobs = jcr; V(mutex); return jcr; @@ -165,6 +166,7 @@ void free_jcr(JCR *jcr) } remove_jcr(jcr); V(mutex); + jcr->daemon_free_jcr(jcr); /* call daemon free routine */ free_common_jcr(jcr); Dmsg0(200, "Exit free_jcr\n"); diff --git a/bacula/src/lib/message.c b/bacula/src/lib/message.c index f46447a0b0..d2c17c873c 100755 --- a/bacula/src/lib/message.c +++ b/bacula/src/lib/message.c @@ -97,6 +97,7 @@ void my_name_is(int argc, char *argv[], char *name) } exename = (char *)malloc(len); strcpy(exename, l); + if (exepath) { free(exepath); } diff --git a/bacula/src/lib/parse_conf.c b/bacula/src/lib/parse_conf.c index 18f1073847..03d76235da 100755 --- a/bacula/src/lib/parse_conf.c +++ b/bacula/src/lib/parse_conf.c @@ -219,7 +219,7 @@ void store_msgs(LEX *lc, struct res_items *item, int index, int pass) } strcat(dest, lc->str); dest_len += lc->str_len; - Dmsg2(100, "store_msgs newdest=%s: dest=%s:\n", lc->str, dest); + Dmsg2(100, "store_msgs newdest=%s: dest=%s:\n", lc->str, NPRT(dest)); token = lex_get_token(lc, T_ALL); if (token == T_COMMA) { continue; /* get another destination */ @@ -229,7 +229,7 @@ void store_msgs(LEX *lc, struct res_items *item, int index, int pass) } break; } - Dmsg1(200, "mail_cmd=%s\n", cmd); + Dmsg1(200, "mail_cmd=%s\n", NPRT(cmd)); scan_types(lc, (MSGS *)(item->value), item->code, dest, cmd); free_pool_memory(dest); Dmsg0(200, "done with dest codes\n"); @@ -243,7 +243,7 @@ void store_msgs(LEX *lc, struct res_items *item, int index, int pass) strcpy(dest, lc->str); dest_len = lc->str_len; token = lex_get_token(lc, T_ALL); - Dmsg1(200, "store_msgs dest=%s:\n", dest); + Dmsg1(200, "store_msgs dest=%s:\n", NPRT(dest)); if (token != T_EQUALS) { scan_err1(lc, "expected an =, got: %s", lc->str); } diff --git a/bacula/src/lib/signal.c b/bacula/src/lib/signal.c index 7550bd6dc6..153269cf81 100644 --- a/bacula/src/lib/signal.c +++ b/bacula/src/lib/signal.c @@ -80,8 +80,9 @@ static void signal_handler(int sig) static char btpath[400]; pid_t pid; - fprintf(stderr, "Kaboom! %s got signal %d. Attempting traceback.\n", - my_name, sig); + fprintf(stderr, "Kaboom! %s, %s got signal %d. Attempting traceback.\n", + NPRT(exename), NPRT(my_name), sig); + if (strlen(exepath) + 12 > (int)sizeof(btpath)) { strcpy(btpath, "btraceback"); } else { diff --git a/bacula/src/lib/watchdog.c b/bacula/src/lib/watchdog.c index 7d345d5fe8..abed81efaa 100755 --- a/bacula/src/lib/watchdog.c +++ b/bacula/src/lib/watchdog.c @@ -150,31 +150,37 @@ static void *watchdog_thread(void *arg) continue; } fd = jcr->store_bsock; - timer_start = fd->timer_start; - if (fd && timer_start && (watchdog_time - timer_start) > fd->timeout) { - fd->timed_out = TRUE; - Jmsg(jcr, M_ERROR, 0, _( + if (fd) { + timer_start = fd->timer_start; + if (timer_start && (watchdog_time - timer_start) > fd->timeout) { + fd->timed_out = TRUE; + Jmsg(jcr, M_ERROR, 0, _( "Watchdog sending kill after %d secs to thread stalled reading Storage daemon.\n"), - watchdog_time - timer_start); - pthread_kill(jcr->my_thread_id, TIMEOUT_SIGNAL); + watchdog_time - timer_start); + pthread_kill(jcr->my_thread_id, TIMEOUT_SIGNAL); + } } fd = jcr->file_bsock; - timer_start = fd->timer_start; - if (fd && timer_start && (watchdog_time - timer_start) > fd->timeout) { - fd->timed_out = TRUE; - Jmsg(jcr, M_ERROR, 0, _( + if (fd) { + timer_start = fd->timer_start; + if (timer_start && (watchdog_time - timer_start) > fd->timeout) { + fd->timed_out = TRUE; + Jmsg(jcr, M_ERROR, 0, _( "Watchdog sending kill after %d secs to thread stalled reading File daemon.\n"), - watchdog_time - timer_start); - pthread_kill(jcr->my_thread_id, TIMEOUT_SIGNAL); + watchdog_time - timer_start); + pthread_kill(jcr->my_thread_id, TIMEOUT_SIGNAL); + } } fd = jcr->dir_bsock; - timer_start = fd->timer_start; - if (fd && timer_start && (watchdog_time - timer_start) > fd->timeout) { - fd->timed_out = TRUE; - Jmsg(jcr, M_ERROR, 0, _( + if (fd) { + timer_start = fd->timer_start; + if (timer_start && (watchdog_time - timer_start) > fd->timeout) { + fd->timed_out = TRUE; + Jmsg(jcr, M_ERROR, 0, _( "Watchdog sending kill after %d secs to thread stalled reading Director.\n"), - watchdog_time - timer_start); - pthread_kill(jcr->my_thread_id, TIMEOUT_SIGNAL); + watchdog_time - timer_start); + pthread_kill(jcr->my_thread_id, TIMEOUT_SIGNAL); + } } } diff --git a/bacula/src/stored/job.c b/bacula/src/stored/job.c index 47c9f24d54..ee5e63e588 100644 --- a/bacula/src/stored/job.c +++ b/bacula/src/stored/job.c @@ -44,9 +44,9 @@ static char use_device[] = "use device=%s media_type=%s pool_name=%s pool_type=% /* Responses sent to Director daemon */ static char OKjob[] = "3000 OK Job SDid=%u SDtime=%u Authorization=%s\n"; static char OK_device[] = "3000 OK use device\n"; -static char NO_device[] = "3904 Device not available\n"; -static char BAD_use[] = "3903 Bad use command\n"; -static char BAD_job[] = "3905 Bad Job command\n"; +static char NO_device[] = "3904 Device %s not available\n"; +static char BAD_use[] = "3903 Bad use command: %s\n"; +static char BAD_job[] = "3905 Bad Job command: %s\n"; @@ -82,7 +82,7 @@ int job_cmd(JCR *jcr) fileset_name = get_memory(dir->msglen); if (sscanf(dir->msg, jobcmd, &JobId, job, job_name, client_name, &JobType, &level, fileset_name) != 7) { - bnet_fsend(dir, BAD_job); + bnet_fsend(dir, BAD_job, dir->msg); Emsg1(M_FATAL, 0, _("Bad Job Command from Director: %s\n"), dir->msg); free_memory(job); free_memory(job_name); @@ -283,10 +283,10 @@ static int use_device_cmd(JCR *jcr) UnlockRes(); Jmsg(jcr, M_FATAL, 0, _("Requested device %s not found. Cannot continue.\n"), dev_name); - bnet_fsend(dir, NO_device); + bnet_fsend(dir, NO_device, dev_name); } else { Emsg1(M_FATAL, 0, _("storemsg); - bnet_fsend(dir, BAD_use); + bnet_fsend(dir, BAD_use, dir->msg); } free_memory(dev_name); diff --git a/bacula/src/version.h b/bacula/src/version.h index 68336ee870..c6485ed68b 100644 --- a/bacula/src/version.h +++ b/bacula/src/version.h @@ -1,8 +1,8 @@ /* */ #define VERSION "1.22" #define VSTRING "1" -#define DATE "21 June 2002" -#define LSMDATE "21Jun02" +#define DATE "22 June 2002" +#define LSMDATE "22Jun02" /* Debug flags */ #define DEBUG 1