From 94e47abe723b0a8c73198a74e6277b5fbc13d930 Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Mon, 23 Feb 2004 09:27:17 +0000 Subject: [PATCH] Fix reporting jobs from state file + misc git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@1073 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/autoconf/configure.in | 2 ++ bacula/configure | 3 +++ bacula/kernstodo | 7 +++++-- bacula/src/dird/dird.c | 1 - bacula/src/dird/ua_status.c | 4 ++-- bacula/src/filed/filed.c | 2 +- bacula/src/filed/status.c | 31 ++++++------------------------- bacula/src/jcr.h | 2 +- bacula/src/lib/bnet.c | 4 +--- bacula/src/lib/jcr.c | 1 - bacula/src/stored/status.c | 10 +++++----- bacula/src/version.h | 4 ++-- 12 files changed, 28 insertions(+), 43 deletions(-) diff --git a/bacula/autoconf/configure.in b/bacula/autoconf/configure.in index 667dac318d..f05a777f0c 100644 --- a/bacula/autoconf/configure.in +++ b/bacula/autoconf/configure.in @@ -1359,6 +1359,8 @@ freebsd) largefile_support="yes" ;; hpux) + PSCMD="UNIX95=1 ps -e -o pid,comm" + CFLAGS="$(CFLAGS) -D_XOPEN_SOURCE_EXTENDED=1" DISTVER=`uname -r` TAPEDRIVE="/dev/rmt/0hnb" ;; diff --git a/bacula/configure b/bacula/configure index 4536fa24b2..bdc681a0bb 100755 --- a/bacula/configure +++ b/bacula/configure @@ -17870,6 +17870,8 @@ freebsd) largefile_support="yes" ;; hpux) + PSCMD="UNIX95=1 ps -e -o pid,comm" + CFLAGS="$(CFLAGS) -D_XOPEN_SOURCE_EXTENDED=1" DISTVER=`uname -r` TAPEDRIVE="/dev/rmt/0hnb" ;; @@ -17981,6 +17983,7 @@ suse) platforms/suse/bacula-fd \ platforms/suse/bacula-sd \ platforms/suse/bacula-dir \ + platforms/suse/bacula \ platforms/suse/bacula.spec" ;; suse5) diff --git a/bacula/kernstodo b/bacula/kernstodo index ca5f31fc1b..b864cc3317 100644 --- a/bacula/kernstodo +++ b/bacula/kernstodo @@ -71,8 +71,8 @@ For 1.33 Testing/Documentation: http://howtos.linux.com/guides/nag2/x-087-2-nfs.mountd.shtml For 1.33 -- Dates are wrong in restore list from Win32 FD. -- Dates are wrong in catalog from Win32 FD. +- Allow for optional cancelling of SD and FD in case DIR + gets a fatal error. Requested by Jesse Guardiani - Remove h_errno from bnet.c by including proper header. - Do not err job if could not write bootstrap file. - Bizarre message: Error: Could not open WriteBootstrap file: @@ -1387,3 +1387,6 @@ Block Position: 0   Differential Backup Pool = zzz } - Look at ASSERT() at 384 src/lib/bnet.c +- Dates are wrong in restore list from Win32 FD. +- Dates are wrong in catalog from Win32 FD. + diff --git a/bacula/src/dird/dird.c b/bacula/src/dird/dird.c index d6532e6ba7..b78e35d866 100644 --- a/bacula/src/dird/dird.c +++ b/bacula/src/dird/dird.c @@ -250,7 +250,6 @@ static void terminate_dird(int sig) exit(1); } already_here = TRUE; - Dmsg0(000, "write_state_file\n"); write_state_file(director->working_directory, "bacula-dir", director->DIRport); delete_pid_file(director->pid_directory, "bacula-dir", director->DIRport); // signal(SIGCHLD, SIG_IGN); /* don't worry about children now */ diff --git a/bacula/src/dird/ua_status.c b/bacula/src/dird/ua_status.c index 7a8a47d147..a33cd179bd 100644 --- a/bacula/src/dird/ua_status.c +++ b/bacula/src/dird/ua_status.c @@ -202,8 +202,8 @@ static void do_director_status(UAContext *ua, char *cmd) bsendmsg(ua, "%s Version: " VERSION " (" BDATE ") %s %s %s\n", my_name, HOST_OS, DISTNAME, DISTVER); bstrftime_nc(dt, sizeof(dt), daemon_start_time); - bsendmsg(ua, _("Daemon started %s, %d Job%s run.\n"), dt, last_job.NumJobs, - last_job.NumJobs == 1 ? "" : "s"); + bsendmsg(ua, _("Daemon started %s, %d Job%s run.\n"), dt, last_jobs->size(), + last_jobs->size() == 1 ? "" : "s"); /* * List scheduled Jobs */ diff --git a/bacula/src/filed/filed.c b/bacula/src/filed/filed.c index e13257ec65..bd8fd35704 100644 --- a/bacula/src/filed/filed.c +++ b/bacula/src/filed/filed.c @@ -242,7 +242,7 @@ Without that I don't know who I am :-(\n"), configfile); &dir_workq, handle_client_request); } - term_msg(); + terminate_filed(0); exit(0); /* should never get here */ } diff --git a/bacula/src/filed/status.c b/bacula/src/filed/status.c index a13f6bc02a..68f8219df4 100755 --- a/bacula/src/filed/status.c +++ b/bacula/src/filed/status.c @@ -60,8 +60,8 @@ static void do_status(void sendit(const char *msg, int len, void *sarg), void *a HOST_OS, DISTNAME, DISTVER); sendit(msg, len, arg); bstrftime_nc(dt, sizeof(dt), daemon_start_time); - len = Mmsg(&msg, _("Daemon started %s, %d Job%s run.\n"), dt, last_job.NumJobs, - last_job.NumJobs == 1 ? "" : "s"); + len = Mmsg(&msg, _("Daemon started %s, %d Job%s run.\n"), dt, last_jobs->size(), + last_jobs->size() == 1 ? "" : "s"); sendit(msg, len, arg); #if defined(HAVE_CYGWIN) || defined(HAVE_WIN32) if (debug_level > 0) { @@ -83,31 +83,12 @@ static void do_status(void sendit(const char *msg, int len, void *sarg), void *a list_terminated_jobs(sendit, arg); -#ifdef xxx - char termstat[30]; - struct s_last_job *je; - lock_last_jobs_list(); - for (je=NULL; (je=(s_last_job *)last_jobs->next(je)); ) { - bstrftime_nc(dt, sizeof(dt), je->end_time); - len = Mmsg(&msg, _("Last Job %s finished at %s\n"), je->Job, dt); - sendit(msg, len, arg); - - jobstatus_to_ascii(je->JobStatus, termstat, sizeof(termstat)); - len = Mmsg(&msg, _(" Files=%s Bytes=%s Termination Status=%s\n"), - edit_uint64_with_commas(je->JobFiles, b1), - edit_uint64_with_commas(je->JobBytes, b2), - termstat); - sendit(msg, len, arg); - } - unlock_last_jobs_list(); -#endif - /* * List running jobs */ Dmsg0(1000, "Begin status jcr loop.\n"); lock_jcr_chain(); - for (njcr=NULL; (njcr=get_next_jcr(njcr)); ) { + foreach_jcr(njcr) { bstrftime_nc(dt, sizeof(dt), njcr->start_time); if (njcr->JobId == 0) { len = Mmsg(&msg, _("Director connected at: %s\n"), dt); @@ -170,7 +151,7 @@ static void list_terminated_jobs(void sendit(const char *msg, int len, void *sa struct s_last_job *je; const char *msg; - if (last_job.NumJobs == 0) { + if (last_jobs->size() == 0) { msg = _("No Terminated Jobs.\n"); sendit(msg, strlen(msg), arg); return; @@ -183,7 +164,7 @@ static void list_terminated_jobs(void sendit(const char *msg, int len, void *sa sendit(msg, strlen(msg), arg); msg = _("======================================================================\n"); sendit(msg, strlen(msg), arg); - for (je=NULL; (je=(s_last_job *)last_jobs->next(je)); ) { + foreach_dlist(je, last_jobs) { char JobName[MAX_NAME_LENGTH]; char *termstat; char buf[1000]; @@ -368,7 +349,7 @@ char *bac_status(int stat) char *termstat = _("Bacula Idle"); bacstat = 0; - if (last_job.NumJobs > 0) { + if (last_jobs->size() > 0) { switch (last_job.JobStatus) { case JS_Canceled: bacstat = -1; diff --git a/bacula/src/jcr.h b/bacula/src/jcr.h index 6d03a634c6..8cfeceb364 100644 --- a/bacula/src/jcr.h +++ b/bacula/src/jcr.h @@ -265,7 +265,7 @@ struct JCR { */ struct s_last_job { dlink link; - int NumJobs; + int xNumJobs; /* no longer used */ int JobType; int JobStatus; int JobLevel; diff --git a/bacula/src/lib/bnet.c b/bacula/src/lib/bnet.c index eb7fab80d3..a95d1e5cb4 100644 --- a/bacula/src/lib/bnet.c +++ b/bacula/src/lib/bnet.c @@ -31,6 +31,7 @@ #include "bacula.h" #include "jcr.h" +#include extern time_t watchdog_time; @@ -496,9 +497,6 @@ bnet_wait_data_intr(BSOCK *bsock, int sec) #define NO_DATA 4 /* Valid name, no data record of requested type. */ #endif -#ifndef HAVE_WIN32 -extern int h_errno; /* On error has one of the above */ -#endif /* * Get human readable error for gethostbyname() */ diff --git a/bacula/src/lib/jcr.c b/bacula/src/lib/jcr.c index 20f2fe7a80..5ef6c4fac0 100755 --- a/bacula/src/lib/jcr.c +++ b/bacula/src/lib/jcr.c @@ -216,7 +216,6 @@ static void free_common_jcr(JCR *jcr) case JT_VERIFY: case JT_RESTORE: case JT_ADMIN: - last_job.NumJobs++; last_job.JobType = jcr->JobType; last_job.JobId = jcr->JobId; last_job.VolSessionId = jcr->VolSessionId; diff --git a/bacula/src/stored/status.c b/bacula/src/stored/status.c index c2682b2786..3452ed4c1e 100644 --- a/bacula/src/stored/status.c +++ b/bacula/src/stored/status.c @@ -64,8 +64,8 @@ int status_cmd(JCR *jcr) bnet_fsend(user, "\n%s Version: " VERSION " (" BDATE ") %s %s %s\n", my_name, HOST_OS, DISTNAME, DISTVER); bstrftime_nc(dt, sizeof(dt), daemon_start_time); - bnet_fsend(user, _("Daemon started %s, %d Job%s run.\n"), dt, last_job.NumJobs, - last_job.NumJobs == 1 ? "" : "s"); + bnet_fsend(user, _("Daemon started %s, %d Job%s run.\n"), dt, last_jobs->size(), + last_jobs->size() == 1 ? "" : "s"); /* * List terminated jobs @@ -126,7 +126,7 @@ int status_cmd(JCR *jcr) found = 0; lock_jcr_chain(); /* NOTE, we reuse a calling argument jcr. Be warned! */ - for (jcr=NULL; (jcr=get_next_jcr(jcr)); ) { + foreach_jcr(jcr) { if (jcr->JobStatus == JS_WaitFD) { bnet_fsend(user, _("%s Job %s waiting for Client connection.\n"), job_type_to_str(jcr->JobType), jcr->Job); @@ -248,7 +248,7 @@ static void list_terminated_jobs(void *arg) struct s_last_job *je; char *msg; - if (last_job.NumJobs == 0) { + if (last_jobs->size() == 0) { msg = _("No Terminated Jobs.\n"); sendit(msg, strlen(msg), arg); return; @@ -260,7 +260,7 @@ static void list_terminated_jobs(void *arg) sendit(msg, strlen(msg), arg); msg = _("======================================================================\n"); sendit(msg, strlen(msg), arg); - for (je=NULL; (je=(s_last_job *)last_jobs->next(je)); ) { + foreach_dlist(je, last_jobs) { char JobName[MAX_NAME_LENGTH]; char *termstat; char buf[1000]; diff --git a/bacula/src/version.h b/bacula/src/version.h index 55693f2402..4243be713f 100644 --- a/bacula/src/version.h +++ b/bacula/src/version.h @@ -2,8 +2,8 @@ #undef VERSION #define VERSION "1.33.4" #define VSTRING "1" -#define BDATE "22 Feb 2004" -#define LSMDATE "22Feb04" +#define BDATE "23 Feb 2004" +#define LSMDATE "23Feb04" /* Debug flags */ #undef DEBUG -- 2.39.2