From: Kern Sibbald Date: Thu, 28 Feb 2008 20:18:11 +0000 (+0000) Subject: kes Correct po warning message with datarootdir X-Git-Tag: Release-3.0.0~1772 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=ac44a3404c90cf20b1091a7415c995120a8e5cac;p=bacula%2Fbacula kes Correct po warning message with datarootdir kes Implement more code in dird.c to put configuration parsing in a class rather than use globals. kes Restructure SD status command for implementation of bat API interface. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@6518 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/autoconf/Make.common.in b/bacula/autoconf/Make.common.in index 155e4e591e..c00958580e 100644 --- a/bacula/autoconf/Make.common.in +++ b/bacula/autoconf/Make.common.in @@ -23,6 +23,7 @@ prefix = @prefix@ exec_prefix = @exec_prefix@ binprefix = manprefix = +datarootdir = @datarootdir@ sbindir = @sbindir@ sysconfdir = @sysconfdir@ scriptdir = @scriptdir@ diff --git a/bacula/kernstodo b/bacula/kernstodo index 5a34b80e5b..13cf69f8f8 100644 --- a/bacula/kernstodo +++ b/bacula/kernstodo @@ -70,11 +70,6 @@ Professional Needs: and http://www.openeyet.nl/scc/ for managing customer changes Priority: -- Look at in src/filed/backup.c -> pm_strcpy(ff_pkt->fname, ff_pkt->fname_save); -> pm_strcpy(ff_pkt->link, ff_pkt->link_save); -- Add Catalog = to Pool resource so that pools will exist - in only one catalog -- currently Pools are "global". - New directive "Delete purged Volumes" - Prune by Job - Prune by Job Level (Full, Differential, Incremental) @@ -135,6 +130,31 @@ Priority: level attempts to start, the running job is promoted to the higher level of processing using the resources already allocated, and the subsequent job is treated as in Skip above. + + +DuplicateJobs { + Name = "xxx" + Description = "xxx" + Allow = yes|no (no = default) + + AllowHigherLevel = yes|no (no) + + AllowLowerLevel = yes|no (no) + + AllowSameLevel = yes|no + + Cancel = Running | New (no) + + CancelledStatus = Fail | Skip (fail) + + Job Proximity = (0) + My suggestion was to define it as the minimum guard time between + executions of a specific job -- ie, if a job was scheduled within Job + Proximity number of seconds, it would be considered a duplicate and + consolidated. + +} + === - the cd-command should allow complete paths i.e. cd /foo/bar/foo/bar @@ -187,7 +207,6 @@ Priority: - Performance: despool attributes when despooling data (problem multiplexing Dir connection). - Make restore use the in-use volume reservation algorithm. -- Add TLS to bat (should be done). - When Pool specifies Storage command override does not work. - Implement wait_for_sysop() message display in wait_for_device(), which now prints warnings too often. @@ -1845,3 +1864,10 @@ Block Position: 0 - Unicode input http://en.wikipedia.org/wiki/Byte_Order_Mark - Look at moving the Storage directive from the Job to the Pool in the default conf files. +- Look at in src/filed/backup.c +> pm_strcpy(ff_pkt->fname, ff_pkt->fname_save); +> pm_strcpy(ff_pkt->link, ff_pkt->link_save); +- Add Catalog = to Pool resource so that pools will exist + in only one catalog -- currently Pools are "global". +- Add TLS to bat (should be done). + diff --git a/bacula/po/Makefile.in.in b/bacula/po/Makefile.in.in index d966318b38..9ff8751cfb 100644 --- a/bacula/po/Makefile.in.in +++ b/bacula/po/Makefile.in.in @@ -25,6 +25,7 @@ VPATH = @srcdir@ prefix = @prefix@ exec_prefix = @exec_prefix@ datadir = @datadir@ +datarootdir = @datarootdir@ localedir = $(datadir)/locale gettextsrcdir = $(datadir)/gettext/po @@ -185,23 +186,23 @@ install-data-yes: all for lc in '' $(EXTRA_LOCALE_CATEGORIES); do \ if test -n "$$lc"; then \ if (cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc 2>/dev/null) | grep ' -> ' >/dev/null; then \ - link=`cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc | sed -e 's/^.* -> //'`; \ - mv $(DESTDIR)$(localedir)/$$lang/$$lc $(DESTDIR)$(localedir)/$$lang/$$lc.old; \ - mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \ - (cd $(DESTDIR)$(localedir)/$$lang/$$lc.old && \ - for file in *; do \ - if test -f $$file; then \ - ln -s ../$$link/$$file $(DESTDIR)$(localedir)/$$lang/$$lc/$$file; \ - fi; \ - done); \ - rm -f $(DESTDIR)$(localedir)/$$lang/$$lc.old; \ + link=`cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc | sed -e 's/^.* -> //'`; \ + mv $(DESTDIR)$(localedir)/$$lang/$$lc $(DESTDIR)$(localedir)/$$lang/$$lc.old; \ + mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \ + (cd $(DESTDIR)$(localedir)/$$lang/$$lc.old && \ + for file in *; do \ + if test -f $$file; then \ + ln -s ../$$link/$$file $(DESTDIR)$(localedir)/$$lang/$$lc/$$file; \ + fi; \ + done); \ + rm -f $(DESTDIR)$(localedir)/$$lang/$$lc.old; \ else \ - if test -d $(DESTDIR)$(localedir)/$$lang/$$lc; then \ - :; \ - else \ - rm -f $(DESTDIR)$(localedir)/$$lang/$$lc; \ - mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \ - fi; \ + if test -d $(DESTDIR)$(localedir)/$$lang/$$lc; then \ + :; \ + else \ + rm -f $(DESTDIR)$(localedir)/$$lang/$$lc; \ + mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \ + fi; \ fi; \ rm -f $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo; \ ln -s ../LC_MESSAGES/$(DOMAIN).mo $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo 2>/dev/null || \ @@ -234,23 +235,23 @@ installdirs-data-yes: for lc in '' $(EXTRA_LOCALE_CATEGORIES); do \ if test -n "$$lc"; then \ if (cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc 2>/dev/null) | grep ' -> ' >/dev/null; then \ - link=`cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc | sed -e 's/^.* -> //'`; \ - mv $(DESTDIR)$(localedir)/$$lang/$$lc $(DESTDIR)$(localedir)/$$lang/$$lc.old; \ - mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \ - (cd $(DESTDIR)$(localedir)/$$lang/$$lc.old && \ - for file in *; do \ - if test -f $$file; then \ - ln -s ../$$link/$$file $(DESTDIR)$(localedir)/$$lang/$$lc/$$file; \ - fi; \ - done); \ - rm -f $(DESTDIR)$(localedir)/$$lang/$$lc.old; \ + link=`cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc | sed -e 's/^.* -> //'`; \ + mv $(DESTDIR)$(localedir)/$$lang/$$lc $(DESTDIR)$(localedir)/$$lang/$$lc.old; \ + mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \ + (cd $(DESTDIR)$(localedir)/$$lang/$$lc.old && \ + for file in *; do \ + if test -f $$file; then \ + ln -s ../$$link/$$file $(DESTDIR)$(localedir)/$$lang/$$lc/$$file; \ + fi; \ + done); \ + rm -f $(DESTDIR)$(localedir)/$$lang/$$lc.old; \ else \ - if test -d $(DESTDIR)$(localedir)/$$lang/$$lc; then \ - :; \ - else \ - rm -f $(DESTDIR)$(localedir)/$$lang/$$lc; \ - mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \ - fi; \ + if test -d $(DESTDIR)$(localedir)/$$lang/$$lc; then \ + :; \ + else \ + rm -f $(DESTDIR)$(localedir)/$$lang/$$lc; \ + mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \ + fi; \ fi; \ fi; \ done; \ diff --git a/bacula/src/dird/dird.c b/bacula/src/dird/dird.c index 4cb1b27cb5..d42b00defc 100644 --- a/bacula/src/dird/dird.c +++ b/bacula/src/dird/dird.c @@ -64,7 +64,7 @@ void init_device_resources(); static char *runjob = NULL; static int background = 1; static void init_reload(void); -static PARSER *parser; +static CONFIG *config; /* Globals Exported */ DIRRES *director; /* Director resource */ @@ -228,10 +228,10 @@ int main (int argc, char *argv[]) configfile = bstrdup(CONFIG_FILE); } - parser = new_parser(); - parser->init(configfile, NULL, M_ERROR_TERM, (void *)&res_all, res_all_size, + config = new_config_parser(); + config->init(configfile, NULL, M_ERROR_TERM, (void *)&res_all, res_all_size, r_first, r_last, resources, res_head); - parser->parse_config(); + config->parse_config(); if (init_crypto() != 0) { Jmsg((JCR *)NULL, M_ERROR_TERM, 0, _("Cryptography library initialization failed.\n")); @@ -354,8 +354,9 @@ void terminate_dird(int sig) if (debug_level > 5) { print_memory_pool_stats(); } - free_config_resources(); - free(parser); + config->free_resources(); + free(config); + config = NULL; term_ua_server(); term_msg(); /* terminate message handler */ cleanup_crypto(); @@ -481,7 +482,7 @@ void reload_config(int sig) } Dmsg1(100, "Reload_config njobs=%d\n", njobs); - reload_table[table].res_table = save_config_resources(); + reload_table[table].res_table = config->save_resources(); Dmsg1(100, "Saved old config in table %d\n", table); ok = parse_config(configfile, 0, M_ERROR); /* no exit on error */ @@ -496,7 +497,7 @@ void reload_config(int sig) Jmsg(NULL, M_ERROR, 0, _("Please correct configuration file: %s\n"), configfile); Jmsg(NULL, M_ERROR, 0, _("Resetting previous configuration.\n")); } - reload_table[rtable].res_table = save_config_resources(); + reload_table[rtable].res_table = config->save_resources(); /* Now restore old resoure values */ int num = r_last - r_first + 1; RES **res_tab = reload_table[table].res_table; diff --git a/bacula/src/lib/parse_conf.c b/bacula/src/lib/parse_conf.c index 110bfec8a6..85cb77d831 100644 --- a/bacula/src/lib/parse_conf.c +++ b/bacula/src/lib/parse_conf.c @@ -196,12 +196,12 @@ const char *res_to_str(int rcode) * Initialize the static structure to zeros, then * apply all the default values. */ -static void init_resource(PARSER *parser, int type, RES_ITEM *items, int pass) +static void init_resource(CONFIG *config, int type, RES_ITEM *items, int pass) { int i; int rindex = type - r_first; - memset(parser->m_res_all, 0, parser->m_res_all_size); + memset(config->m_res_all, 0, config->m_res_all_size); res_all.hdr.rcode = type; res_all.hdr.refcnt = 1; @@ -773,15 +773,15 @@ enum parse_state { p_resource }; -PARSER *new_parser() +CONFIG *new_config_parser() { - PARSER *parser; - parser = (PARSER *)malloc(sizeof(PARSER)); - memset(parser, 0, sizeof(PARSER)); - return parser; + CONFIG *config; + config = (CONFIG *)malloc(sizeof(CONFIG)); + memset(config, 0, sizeof(CONFIG)); + return config; } -void PARSER::init( +void CONFIG::init( const char *cf, LEX_ERROR_HANDLER *scan_error, int err_type, @@ -815,16 +815,16 @@ int parse_config(const char *cf, LEX_ERROR_HANDLER *scan_error, int err_type) { int ok; - PARSER *parser = new_parser(); - parser->init(cf, scan_error, err_type, (void *)&res_all, res_all_size, + CONFIG *config = new_config_parser(); + config->init(cf, scan_error, err_type, (void *)&res_all, res_all_size, r_first, r_last, resources, res_head); - ok = parser->parse_config(); - free(parser); + ok = config->parse_config(); + free(config); return ok; } -bool PARSER::parse_config() +bool CONFIG::parse_config() { LEX *lc = NULL; int token, i, pass; @@ -1052,6 +1052,33 @@ find_config_file(const char *config_file, char *full_path, int max_path) * Free configuration resources * */ +void CONFIG::free_resources() +{ + for (int i=m_r_first; i<=m_r_last; i++) { + free_resource(m_res_head[i-m_r_first], i); + m_res_head[i-m_r_first] = NULL; + } +} + +RES **CONFIG::save_resources() +{ + int num = m_r_last - m_r_first + 1; + RES **res = (RES **)malloc(num*sizeof(RES *)); + for (int i=0; i 10) { + bs->fsend(_("====\n\n")); + dump_resource(R_DEVICE, resources[R_DEVICE-r_first].res_head, sendit, user); + bs->fsend(_("====\n\n")); + } +#endif + + list_spool_stats(sendit, (void *)bs); +} + + +static void list_devices(BSOCK *bs) +{ + DEVRES *device; + AUTOCHANGER *changer; + DEVICE *dev; + char b1[35], b2[35], b3[35]; + POOL_MEM msg(PM_MESSAGE); + int len; + int bpb; + len = Mmsg(msg, _("\nDevice status:\n")); - sendit(msg, len, arg); + sendit(msg, len, bs); foreach_res(changer, R_AUTOCHANGER) { len = Mmsg(msg, _("Autochanger \"%s\" with devices:\n"), changer->hdr.name); - sendit(msg, len, arg); + sendit(msg, len, bs); foreach_alist(device, changer->device) { if (device->dev) { len = Mmsg(msg, " %s\n", device->dev->print_name()); - sendit(msg, len, arg); + sendit(msg, len, bs); } else { len = Mmsg(msg, " %s\n", device->hdr.name); - sendit(msg, len, arg); + sendit(msg, len, bs); } } } @@ -147,13 +155,13 @@ void output_status(void sendit(const char *msg, int len, void *sarg), void *arg) dev->VolHdr.VolumeName, dev->pool_name[0]?dev->pool_name:"*unknown*", dev->device->media_type); - sendit(msg, len, arg); + sendit(msg, len, bs); } else { len = Mmsg(msg, _("Device %s open but no Bacula volume is currently mounted.\n"), dev->print_name()); - sendit(msg, len, arg); + sendit(msg, len, bs); } - send_blocked_status(dev, sendit, arg); + send_blocked_status(dev, bs); if (dev->can_append()) { bpb = dev->VolCatInfo.VolCatBlocks; if (bpb <= 0) { @@ -164,7 +172,7 @@ void output_status(void sendit(const char *msg, int len, void *sarg), void *arg) edit_uint64_with_commas(dev->VolCatInfo.VolCatBytes, b1), edit_uint64_with_commas(dev->VolCatInfo.VolCatBlocks, b2), edit_uint64_with_commas(bpb, b3)); - sendit(msg, len, arg); + sendit(msg, len, bs); } else { /* reading */ bpb = dev->VolCatInfo.VolCatReads; if (bpb <= 0) { @@ -179,64 +187,76 @@ void output_status(void sendit(const char *msg, int len, void *sarg), void *arg) edit_uint64_with_commas(dev->VolCatInfo.VolCatRBytes, b1), edit_uint64_with_commas(dev->VolCatInfo.VolCatReads, b2), edit_uint64_with_commas(bpb, b3)); - sendit(msg, len, arg); + sendit(msg, len, bs); } len = Mmsg(msg, _(" Positioned at File=%s Block=%s\n"), edit_uint64_with_commas(dev->file, b1), edit_uint64_with_commas(dev->block_num, b2)); - sendit(msg, len, arg); + sendit(msg, len, bs); } else { if (dev) { len = Mmsg(msg, _("Device %s is not open.\n"), dev->print_name()); - sendit(msg, len, arg); - send_blocked_status(dev, sendit, arg); + sendit(msg, len, bs); + send_blocked_status(dev, bs); } else { len = Mmsg(msg, _("Device \"%s\" is not open or does not exist.\n"), device->hdr.name); - sendit(msg, len, arg); + sendit(msg, len, bs); } } } - sendit("====\n\n", 6, arg); - len = Mmsg(msg, _("In Use Volume status:\n")); - sendit(msg, len, arg); - list_volumes(sendit, arg); - sendit("====\n\n", 6, arg); + sendit("====\n\n", 6, bs); +} -#ifdef xxx - if (debug_level > 10) { - user->fsend(_("====\n\n")); - dump_resource(R_DEVICE, resources[R_DEVICE-r_first].res_head, sendit, user); - user->fsend(_("====\n\n")); - } -#endif +static void list_status_header(BSOCK *bs) +{ + char dt[MAX_TIME_LENGTH]; + char b1[35], b2[35], b3[35], b4[35], b5[35]; + POOL_MEM msg(PM_MESSAGE); + int len; + + len = Mmsg(msg, _("%s Version: %s (%s) %s %s %s\n"), + my_name, VERSION, BDATE, HOST_OS, DISTNAME, DISTVER); + sendit(msg, len, bs); - list_spool_stats(sendit, arg); + bstrftime_nc(dt, sizeof(dt), daemon_start_time); + + + len = Mmsg(msg, _("Daemon started %s, %d Job%s run since started.\n"), + dt, num_jobs_run, num_jobs_run == 1 ? "" : "s"); + sendit(msg, len, bs); - free_pool_memory(msg); + len = Mmsg(msg, _(" Heap: heap=%s smbytes=%s max_bytes=%s bufs=%s max_bufs=%s\n"), + edit_uint64_with_commas((char *)sbrk(0)-(char *)start_heap, b1), + edit_uint64_with_commas(sm_bytes, b2), + edit_uint64_with_commas(sm_max_bytes, b3), + edit_uint64_with_commas(sm_buffers, b4), + edit_uint64_with_commas(sm_max_buffers, b5)); + sendit(msg, len, bs); + len = Mmsg(msg, "Sizes: boffset_t=%d size_t=%d int32_t=%d int64_t=%d\n", + (int)sizeof(boffset_t), (int)sizeof(size_t), (int)sizeof(int32_t), + (int)sizeof(int64_t)); + sendit(msg, len, bs); } -static void send_blocked_status(DEVICE *dev, void sendit(const char *msg, int len, void *sarg), void *arg) +static void send_blocked_status(DEVICE *dev, BSOCK *bs) { - char *msg; + POOL_MEM msg(PM_MESSAGE); int len; - msg = (char *)get_pool_memory(PM_MESSAGE); - if (!dev) { len = Mmsg(msg, _("No DEVICE structure.\n\n")); - sendit(msg, len, arg); - free_pool_memory(msg); + sendit(msg, len, bs); return; } switch (dev->blocked()) { case BST_UNMOUNTED: len = Mmsg(msg, _(" Device is BLOCKED. User unmounted.\n")); - sendit(msg, len, arg); + sendit(msg, len, bs); break; case BST_UNMOUNTED_WAITING_FOR_SYSOP: len = Mmsg(msg, _(" Device is BLOCKED. User unmounted during wait for media/mount.\n")); - sendit(msg, len, arg); + sendit(msg, len, bs); break; case BST_WAITING_FOR_SYSOP: { @@ -253,7 +273,7 @@ static void send_blocked_status(DEVICE *dev, void sendit(const char *msg, int le dcr->VolumeName, dcr->pool_name, dcr->media_type); - sendit(msg, len, arg); + sendit(msg, len, bs); found_jcr = true; } else if (dcr->jcr->JobStatus == JS_WaitMedia) { len = Mmsg(msg, _(" Device is BLOCKED waiting to create a volume for:\n" @@ -261,7 +281,7 @@ static void send_blocked_status(DEVICE *dev, void sendit(const char *msg, int le " Media type: %s\n"), dcr->pool_name, dcr->media_type); - sendit(msg, len, arg); + sendit(msg, len, bs); found_jcr = true; } } @@ -269,17 +289,17 @@ static void send_blocked_status(DEVICE *dev, void sendit(const char *msg, int le if (!found_jcr) { len = Mmsg(msg, _(" Device is BLOCKED waiting for media.\n")); - sendit(msg, len, arg); + sendit(msg, len, bs); } } break; case BST_DOING_ACQUIRE: len = Mmsg(msg, _(" Device is being initialized.\n")); - sendit(msg, len, arg); + sendit(msg, len, bs); break; case BST_WRITING_LABEL: len = Mmsg(msg, _(" Device is blocked labeling a Volume.\n")); - sendit(msg, len, arg); + sendit(msg, len, bs); break; default: break; @@ -289,18 +309,18 @@ static void send_blocked_status(DEVICE *dev, void sendit(const char *msg, int le if (dev->Slot > 0) { len = Mmsg(msg, _(" Slot %d is loaded in drive %d.\n"), dev->Slot, dev->drive_index); - sendit(msg, len, arg); + sendit(msg, len, bs); } else if (dev->Slot == 0) { len = Mmsg(msg, _(" Drive %d is not loaded.\n"), dev->drive_index); - sendit(msg, len, arg); + sendit(msg, len, bs); } else { len = Mmsg(msg, _(" Drive %d status unknown.\n"), dev->drive_index); - sendit(msg, len, arg); + sendit(msg, len, bs); } } if (debug_level > 1) { len = Mmsg(msg, _("Configured device capabilities:\n")); - sendit(msg, len, arg); + sendit(msg, len, bs); len = Mmsg(msg, "%sEOF %sBSR %sBSF %sFSR %sFSF %sEOM %sREM %sRACCESS %sAUTOMOUNT %sLABEL %sANONVOLS %sALWAYSOPEN\n", dev->capabilities & CAP_EOF ? "" : "!", @@ -315,10 +335,10 @@ static void send_blocked_status(DEVICE *dev, void sendit(const char *msg, int le dev->capabilities & CAP_LABEL ? "" : "!", dev->capabilities & CAP_ANONVOLS ? "" : "!", dev->capabilities & CAP_ALWAYSOPEN ? "" : "!"); - sendit(msg, len, arg); + sendit(msg, len, bs); len = Mmsg(msg, _("Device state:\n")); - sendit(msg, len, arg); + sendit(msg, len, bs); len = Mmsg(msg, "%sOPENED %sTAPE %sLABEL %sMALLOC %sAPPEND %sREAD %sEOT %sWEOT %sEOF %sNEXTVOL %sSHORT %sMOUNTED\n", dev->is_open() ? "" : "!", @@ -333,48 +353,45 @@ static void send_blocked_status(DEVICE *dev, void sendit(const char *msg, int le dev->state & ST_NEXTVOL ? "" : "!", dev->state & ST_SHORT ? "" : "!", dev->state & ST_MOUNTED ? "" : "!"); - sendit(msg, len, arg); + sendit(msg, len, bs); len = Mmsg(msg, _("num_writers=%d block=%d\n\n"), dev->num_writers, dev->blocked()); - sendit(msg, len, arg); + sendit(msg, len, bs); len = Mmsg(msg, _("Device parameters:\n")); - sendit(msg, len, arg); + sendit(msg, len, bs); len = Mmsg(msg, _("Archive name: %s Device name: %s\n"), dev->archive_name(), dev->name()); - sendit(msg, len, arg); + sendit(msg, len, bs); len = Mmsg(msg, _("File=%u block=%u\n"), dev->file, dev->block_num); - sendit(msg, len, arg); + sendit(msg, len, bs); len = Mmsg(msg, _("Min block=%u Max block=%u\n"), dev->min_block_size, dev->max_block_size); - sendit(msg, len, arg); + sendit(msg, len, bs); } - - free_pool_memory(msg); } -static void list_running_jobs(void sendit(const char *msg, int len, void *sarg), void *arg) +static void list_running_jobs(BSOCK *bs) { bool found = false; int bps, sec; JCR *jcr; DCR *dcr, *rdcr; char JobName[MAX_NAME_LENGTH]; - char *msg, b1[30], b2[30], b3[30]; + char b1[30], b2[30], b3[30]; int len; - - msg = (char *)get_pool_memory(PM_MESSAGE); + POOL_MEM msg(PM_MESSAGE); len = Mmsg(msg, _("\nRunning Jobs:\n")); - sendit(msg, len, arg); + sendit(msg, len, bs); foreach_jcr(jcr) { if (jcr->JobStatus == JS_WaitFD) { len = Mmsg(msg, _("%s Job %s waiting for Client connection.\n"), job_type_to_str(jcr->JobType), jcr->Job); - sendit(msg, len, arg); + sendit(msg, len, bs); } dcr = jcr->dcr; rdcr = jcr->read_dcr; @@ -398,7 +415,7 @@ static void list_running_jobs(void sendit(const char *msg, int len, void *sarg), rdcr->pool_name, rdcr->dev?rdcr->dev->print_name(): rdcr->device->device_name); - sendit(msg, len, arg); + sendit(msg, len, bs); } if (dcr && dcr->device) { len = Mmsg(msg, _("Writing: %s %s job %s JobId=%d Volume=\"%s\"\n" @@ -411,10 +428,10 @@ static void list_running_jobs(void sendit(const char *msg, int len, void *sarg), dcr->pool_name, dcr->dev?dcr->dev->print_name(): dcr->device->device_name); - sendit(msg, len, arg); + sendit(msg, len, bs); len= Mmsg(msg, _(" spooling=%d despooling=%d despool_wait=%d\n"), dcr->spooling, dcr->despooling, dcr->despool_wait); - sendit(msg, len, arg); + sendit(msg, len, bs); } sec = time(NULL) - jcr->run_time; if (sec <= 0) { @@ -425,7 +442,7 @@ static void list_running_jobs(void sendit(const char *msg, int len, void *sarg), edit_uint64_with_commas(jcr->JobFiles, b1), edit_uint64_with_commas(jcr->JobBytes, b2), edit_uint64_with_commas(bps, b3)); - sendit(msg, len, arg); + sendit(msg, len, bs); found = true; #ifdef DEBUG if (jcr->file_bsock) { @@ -433,10 +450,10 @@ static void list_running_jobs(void sendit(const char *msg, int len, void *sarg), edit_uint64_with_commas(jcr->file_bsock->read_seqno, b1), jcr->file_bsock->in_msg_no, jcr->file_bsock->out_msg_no, jcr->file_bsock->m_fd); - sendit(msg, len, arg); + sendit(msg, len, bs); } else { len = Mmsg(msg, _(" FDSocket closed\n")); - sendit(msg, len, arg); + sendit(msg, len, bs); } #endif } @@ -445,34 +462,33 @@ static void list_running_jobs(void sendit(const char *msg, int len, void *sarg), if (!found) { len = Mmsg(msg, _("No Jobs running.\n")); - sendit(msg, len, arg); + sendit(msg, len, bs); } - sendit("====\n", 5, arg); - - free_pool_memory(msg); + sendit("====\n", 5, bs); } -static void list_jobs_waiting_on_reservation(void sendit(const char *msg, int len, void *sarg), void *arg) +static void list_jobs_waiting_on_reservation(BSOCK *bs) { JCR *jcr; - char *msg; + POOL_MEM msg(PM_MESSAGE); + int len; - msg = _("\nJobs waiting to reserve a drive:\n"); - sendit(msg, strlen(msg), arg); + len = Mmsg(msg, _("\nJobs waiting to reserve a drive:\n")); + sendit(msg, len, bs); foreach_jcr(jcr) { if (!jcr->reserve_msgs) { continue; } - send_drive_reserve_messages(jcr, sendit, arg); + send_drive_reserve_messages(jcr, sendit, bs); } endeach_jcr(jcr); - sendit("====\n", 5, arg); + sendit("====\n", 5, bs); } -static void list_terminated_jobs(void sendit(const char *msg, int len, void *sarg), void *arg) +static void list_terminated_jobs(BSOCK *bs) { char dt[MAX_TIME_LENGTH], b1[30], b2[30]; char level[10]; @@ -480,16 +496,16 @@ static void list_terminated_jobs(void sendit(const char *msg, int len, void *sar const char *msg; msg = _("\nTerminated Jobs:\n"); - sendit(msg, strlen(msg), arg); + sendit(msg, strlen(msg), bs); if (last_jobs->size() == 0) { - sendit("====\n", 5, arg); + sendit("====\n", 5, bs); return; } lock_last_jobs_list(); msg = _(" JobId Level Files Bytes Status Finished Name \n"); - sendit(msg, strlen(msg), arg); + sendit(msg, strlen(msg), bs); msg = _("===================================================================\n"); - sendit(msg, strlen(msg), arg); + sendit(msg, strlen(msg), bs); foreach_dlist(je, last_jobs) { char JobName[MAX_NAME_LENGTH]; const char *termstat; @@ -542,10 +558,10 @@ static void list_terminated_jobs(void sendit(const char *msg, int len, void *sar edit_uint64_with_suffix(je->JobBytes, b2), termstat, dt, JobName); - sendit(buf, strlen(buf), arg); + sendit(buf, strlen(buf), bs); } unlock_last_jobs_list(); - sendit("====\n", 5, arg); + sendit("====\n", 5, bs); } /* @@ -598,26 +614,39 @@ static const char *level_to_str(int level) /* * Send to Director */ -static void dir_sendit(const char *msg, int len, void *arg) +static void sendit(const char *msg, int len, BSOCK *bs) +{ + memcpy(bs->msg, msg, len+1); + bs->msglen = len+1; + bs->send(); +} + +static void sendit(const char *msg, int len, void *arg) { - BSOCK *user = (BSOCK *)arg; + BSOCK *bs = (BSOCK *)arg; + memcpy(bs->msg, msg, len+1); + bs->msglen = len+1; + bs->send(); +} - memcpy(user->msg, msg, len+1); - user->msglen = len+1; - user->send(); +static void sendit(POOL_MEM &msg, int len, BSOCK *bs) +{ + memcpy(bs->msg, msg.c_str(), len+1); + bs->msglen = len+1; + bs->send(); } + /* * Status command from Director */ bool status_cmd(JCR *jcr) { - BSOCK *user = jcr->dir_bsock; - - user->fsend("\n"); - output_status(dir_sendit, (void *)user); + BSOCK *bs = jcr->dir_bsock; - user->signal(BNET_EOD); + bs->fsend("\n"); + output_status(bs); + bs->signal(BNET_EOD); return 1; } @@ -668,6 +697,7 @@ bool qstatus_cmd(JCR *jcr) #if defined(HAVE_WIN32) int bacstat = 0; +/* Return a one line status for the tray monitor */ char *bac_status(char *buf, int buf_len) { JCR *njcr; diff --git a/bacula/technotes-2.3 b/bacula/technotes-2.3 index 82fd2905db..73f260fe80 100644 --- a/bacula/technotes-2.3 +++ b/bacula/technotes-2.3 @@ -1,10 +1,16 @@ Technical notes on version 2.3 General: +28Feb08 +kes Correct po warning message with datarootdir +kes Implement more code in dird.c to put configuration parsing in + a class rather than use globals. +kes Restructure SD status command for implementation of bat API + interface. 27Feb08 -kes Suppress incorrect 'Will not descend from x into y' messages. -kes Eliminate FORTIFY_CODE=2 bug, and make first cut at removing - daemon globals used by parser. +kes Suppress incorrect 'Will not descend from x into y' messages. +kes Eliminate FORTIFY_CODE=2 bug, and make first cut at removing + daemon globals used by parser. kes Apply Joao's patch to separate DB_TYPE and DB_PROG in configure. 26Feb08 kes Fix free of plugin_list when none exists.