From f6f6bb76e5b33c134ec27c3988d0fdb74b5472bb Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Thu, 23 Oct 2003 10:58:10 +0000 Subject: [PATCH] Make status dir report all runs + close unused fd in bpipe.c git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@759 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/ChangeLog | 8 ++++++- bacula/ReleaseNotes | 2 ++ bacula/autoconf/configure.in | 2 +- bacula/configure | 2 +- bacula/kernstodo | 8 ++++--- bacula/src/dird/protos.h | 42 ++++++++++++++++++------------------ bacula/src/dird/ua_output.c | 39 ++++++++++++++++++--------------- bacula/src/dird/ua_status.c | 22 +++++++++---------- bacula/src/lib/bpipe.c | 3 +++ bacula/src/version.h | 4 ++-- 10 files changed, 74 insertions(+), 58 deletions(-) diff --git a/bacula/ChangeLog b/bacula/ChangeLog index 563d42267b..7a2b9e1c4c 100644 --- a/bacula/ChangeLog +++ b/bacula/ChangeLog @@ -1,5 +1,11 @@ -2003-10-15 Version 1.32b 20Oct03 Beta +2003-10-15 Version 1.32c 22Oct03 Beta +23Oct03 +- Correct a typo in configure.in when configuring GNOME. +- In doing a "status dir" make it loop over all the run + commands in the Schedule rather than doing on the first one. +- Close all unused file descriptors in bpipe.c otherwise if + a daemon is started, it will keep our TCP/IP port open. 22Oct03 - Print block read error (checksum, I/O, BB01, ...) once then the number found at the end of the reading. diff --git a/bacula/ReleaseNotes b/bacula/ReleaseNotes index f9ef8d92fb..af1ed109d5 100644 --- a/bacula/ReleaseNotes +++ b/bacula/ReleaseNotes @@ -11,6 +11,8 @@ Most Significant Changes since 1.32b - Implemented VerifyJob record that tells Verify which job to verify (JobId not required). - First cut Verify Disk to Catalog +- Fix "status dir" to examine all run commands in sched. +- Close unused file descriptors in bpipe.c Most Significant Changes since 1.32a: - Improve forward space file/block during restore, many diff --git a/bacula/autoconf/configure.in b/bacula/autoconf/configure.in index 8ec3a6c17f..8a1050ac29 100644 --- a/bacula/autoconf/configure.in +++ b/bacula/autoconf/configure.in @@ -172,7 +172,7 @@ if test x$support_gnome = xyes; then pkg=$? if test $pkg = 0; then GNOME_INCLUDEDIR=`pkg-config --cflags-only-I libgnomeui-2.0` - GNOMEUI_LIBS=`pkg-config --libs-only-other libgnomeui-2.0` + GNOMEUI_LIBS=`pkg-config --libs-only libgnomeui-2.0` GNOME_LIBDIR=`pkg-config --libs libgnomeui-2.0` GNOME_LIBS=`pkg-config --libs-only-l libgnomeui-2.0` AC_SUBST(GNOME_INCLUDEDIR) diff --git a/bacula/configure b/bacula/configure index ed3d85bb9b..97e611b398 100755 --- a/bacula/configure +++ b/bacula/configure @@ -4341,7 +4341,7 @@ if test x$support_gnome = xyes; then pkg=$? if test $pkg = 0; then GNOME_INCLUDEDIR=`pkg-config --cflags-only-I libgnomeui-2.0` - GNOMEUI_LIBS=`pkg-config --libs-only-other libgnomeui-2.0` + GNOMEUI_LIBS=`pkg-config --libs-only libgnomeui-2.0` GNOME_LIBDIR=`pkg-config --libs libgnomeui-2.0` GNOME_LIBS=`pkg-config --libs-only-l libgnomeui-2.0` diff --git a/bacula/kernstodo b/bacula/kernstodo index bada35994b..883876f4f1 100644 --- a/bacula/kernstodo +++ b/bacula/kernstodo @@ -40,12 +40,12 @@ For 1.33 Testing/Documentation: - Document verify_disk_to_catalog For 1.32c -- If last Full back is purged and an Incremental or Differential remains, - Bacula does not promote the Incremental to a Full. -- Finish implementation of Verify=DiskToCatalog - Add VerifyJob to "run" summary (yes/mod/no) prompt. For 1.33 +- Finish implementation of Verify=DiskToCatalog +- Change console to bconsole. +- Change smtp to bsmtp. - Add device name to "Current Volume not acceptable because ..." - Make sure that Bacula rechecks the tape after the 20 min wait. - Set IO_NOWAIT on Bacula TCP/IP packets. @@ -1061,4 +1061,6 @@ Done: (see kernsdone for more) - Figure out a way to move Volumes from one pool to another. - Implement a RunAfterFailedJob - Limit the number of block checksum/header BB01, ... errors printed. +- If last Full back is purged and an Incremental or Differential remains, + Bacula does not promote the Incremental to a Full. diff --git a/bacula/src/dird/protos.h b/bacula/src/dird/protos.h index 911bab1a10..30d0dd7ac6 100644 --- a/bacula/src/dird/protos.h +++ b/bacula/src/dird/protos.h @@ -62,7 +62,7 @@ int variable_expansion(JCR *jcr, char *inp, POOLMEM **exp); /* fd_cmds.c */ extern int connect_to_file_daemon(JCR *jcr, int retry_interval, - int max_retry_time, int verbose); + int max_retry_time, int verbose); extern int send_include_list(JCR *jcr); extern int send_exclude_list(JCR *jcr); extern int send_bootstrap_file(JCR *jcr); @@ -70,7 +70,7 @@ extern int send_level_command(JCR *jcr); extern int get_attributes_and_put_in_catalog(JCR *jcr); extern int get_attributes_and_compare_to_catalog(JCR *jcr, JobId_t JobId); extern int put_file_into_catalog(JCR *jcr, long file_index, char *fname, - char *link, char *attr, int stream); + char *link, char *attr, int stream); extern void get_level_since_time(JCR *jcr, char *since, int since_len); extern int send_run_before_and_after_commands(JCR *jcr); @@ -93,7 +93,7 @@ extern void mount_request(JCR *jcr, BSOCK *bs, char *buf); /* msgchan.c */ extern int connect_to_storage_daemon(JCR *jcr, int retry_interval, - int max_retry_time, int verbose); + int max_retry_time, int verbose); extern int start_storage_daemon_job(JCR *jcr); extern int start_storage_daemon_message_thread(JCR *jcr); extern int bget_dirmsg(BSOCK *bs); @@ -132,7 +132,7 @@ int is_volume_name_legal(UAContext *ua, char *name); /* ua_output.c */ void prtit(void *ctx, char *msg); int complete_jcr_for_job(JCR *jcr, JOB *job, POOL *pool); -RUN *find_next_run(JOB *job, time_t &runtime); +RUN *find_next_run(RUN *run, JOB *job, time_t &runtime); /* ua_server.c */ void bsendmsg(void *sock, char *fmt, ...); @@ -140,28 +140,28 @@ UAContext *new_ua_context(JCR *jcr); void free_ua_context(UAContext *ua); /* ua_select.c */ -STORE *select_storage_resource(UAContext *ua); -JOB *select_job_resource(UAContext *ua); -JOB *select_restore_job_resource(UAContext *ua); -CLIENT *select_client_resource(UAContext *ua); +STORE *select_storage_resource(UAContext *ua); +JOB *select_job_resource(UAContext *ua); +JOB *select_restore_job_resource(UAContext *ua); +CLIENT *select_client_resource(UAContext *ua); FILESET *select_fileset_resource(UAContext *ua); -int select_pool_and_media_dbr(UAContext *ua, POOL_DBR *pr, MEDIA_DBR *mr); -int select_media_dbr(UAContext *ua, MEDIA_DBR *mr); -int select_pool_dbr(UAContext *ua, POOL_DBR *pr); -int select_client_dbr(UAContext *ua, CLIENT_DBR *cr); - -void start_prompt(UAContext *ua, char *msg); -void add_prompt(UAContext *ua, char *prompt); -int do_prompt(UAContext *ua, char *automsg, char *msg, char *prompt, int max_prompt); -CAT *get_catalog_resource(UAContext *ua); +int select_pool_and_media_dbr(UAContext *ua, POOL_DBR *pr, MEDIA_DBR *mr); +int select_media_dbr(UAContext *ua, MEDIA_DBR *mr); +int select_pool_dbr(UAContext *ua, POOL_DBR *pr); +int select_client_dbr(UAContext *ua, CLIENT_DBR *cr); + +void start_prompt(UAContext *ua, char *msg); +void add_prompt(UAContext *ua, char *prompt); +int do_prompt(UAContext *ua, char *automsg, char *msg, char *prompt, int max_prompt); +CAT *get_catalog_resource(UAContext *ua); STORE *get_storage_resource(UAContext *ua, int use_default); -int get_media_type(UAContext *ua, char *MediaType, int max_media); -int get_pool_dbr(UAContext *ua, POOL_DBR *pr); -int get_client_dbr(UAContext *ua, CLIENT_DBR *cr); +int get_media_type(UAContext *ua, char *MediaType, int max_media); +int get_pool_dbr(UAContext *ua, POOL_DBR *pr); +int get_client_dbr(UAContext *ua, CLIENT_DBR *cr); POOL *get_pool_resource(UAContext *ua); POOL *select_pool_resource(UAContext *ua); CLIENT *get_client_resource(UAContext *ua); -int get_job_dbr(UAContext *ua, JOB_DBR *jr); +int get_job_dbr(UAContext *ua, JOB_DBR *jr); int find_arg_keyword(UAContext *ua, char **list); int find_arg(UAContext *ua, char *keyword); diff --git a/bacula/src/dird/ua_output.c b/bacula/src/dird/ua_output.c index 35f019567e..2ddd2dc381 100644 --- a/bacula/src/dird/ua_output.c +++ b/bacula/src/dird/ua_output.c @@ -390,20 +390,21 @@ static int do_list_cmd(UAContext *ua, char *cmd, e_list_type llist) } } } - run = find_next_run(job, runtime); - pool = run ? run->pool : NULL; - if (!complete_jcr_for_job(jcr, job, pool)) { - return 1; - } - - if (!find_next_volume_for_append(jcr, &mr, 0)) { - bsendmsg(ua, "Could not find next Volume\n"); - db_close_database(jcr, jcr->db); - jcr->db = NULL; - return 1; - } else { - bsendmsg(ua, "The next Volume to be used by Job \"%s\" will be %s\n", - job->hdr.name, mr.VolumeName); + for (run=NULL; (run = find_next_run(run, job, runtime)); ) { + pool = run ? run->pool : NULL; + if (!complete_jcr_for_job(jcr, job, pool)) { + return 1; + } + + if (!find_next_volume_for_append(jcr, &mr, 0)) { + bsendmsg(ua, "Could not find next Volume\n"); + db_close_database(jcr, jcr->db); + jcr->db = NULL; + return 1; + } else { + bsendmsg(ua, "The next Volume to be used by Job \"%s\" will be %s\n", + job->hdr.name, mr.VolumeName); + } } db_close_database(jcr, jcr->db); jcr->db = NULL; @@ -418,10 +419,9 @@ static int do_list_cmd(UAContext *ua, char *cmd, e_list_type llist) * For a given job, we examine all his run records * to see if it is scheduled today or tomorrow. */ -RUN *find_next_run(JOB *job, time_t &runtime) +RUN *find_next_run(RUN *run, JOB *job, time_t &runtime) { time_t now, tomorrow; - RUN *run; SCHED *sched; struct tm tm; int mday, wday, month, wpos, tmday, twday, tmonth, twpos, i, hour; @@ -449,7 +449,12 @@ RUN *find_next_run(JOB *job, time_t &runtime) tmonth = tm.tm_mon; twpos = (tm.tm_mday - 1) / 7; - for (run=sched->run; run; run=run->next) { + if (run == NULL) { + run = sched->run; + } else { + run = run->next; + } + if (run) { /* * Find runs in next 24 hours */ diff --git a/bacula/src/dird/ua_status.c b/bacula/src/dird/ua_status.c index d2eddedcb9..53942dae9b 100644 --- a/bacula/src/dird/ua_status.c +++ b/bacula/src/dird/ua_status.c @@ -452,19 +452,17 @@ static void print_jobs_scheduled(UAContext *ua) /* Loop through all jobs */ LockRes(); for (job=NULL; (job=(JOB *)GetNextRes(R_JOB, (RES *)job)); ) { - level = job->level; - run = find_next_run(job, runtime); - if (!run) { - continue; - } - if (run->level) { - level = run->level; - } - if (!hdr_printed) { - hdr_printed = true; - prt_runhdr(ua); + for (run=NULL; (run = find_next_run(run, job, runtime)); ) { + level = job->level; + if (run->level) { + level = run->level; + } + if (!hdr_printed) { + hdr_printed = true; + prt_runhdr(ua); + } + prt_runtime(ua, job, level, runtime, run->pool); } - prt_runtime(ua, job, level, runtime, run->pool); } /* end for loop over resources */ UnlockRes(); diff --git a/bacula/src/lib/bpipe.c b/bacula/src/lib/bpipe.c index a44290b75d..1501e18d2c 100644 --- a/bacula/src/lib/bpipe.c +++ b/bacula/src/lib/bpipe.c @@ -92,6 +92,9 @@ BPIPE *open_bpipe(char *prog, int wait, char *mode) dup2(readp[1], 1); /* dup our read to his stdout */ dup2(readp[1], 2); /* and his stderr */ } + for (int i=3; i<=32; i++) { /* close any open file descriptors */ + close(i); + } execvp(bargv[0], bargv); /* call the program */ exit(errno); /* shouldn't get here */ diff --git a/bacula/src/version.h b/bacula/src/version.h index 8dbfcbbc6e..500a14a200 100644 --- a/bacula/src/version.h +++ b/bacula/src/version.h @@ -2,8 +2,8 @@ #undef VERSION #define VERSION "1.32c" #define VSTRING "1" -#define BDATE "20 Oct 2003" -#define LSMDATE "20Oct03" +#define BDATE "22 Oct 2003" +#define LSMDATE "22Oct03" /* Debug flags */ #undef DEBUG -- 2.39.5