From: Kern Sibbald Date: Sun, 11 Feb 2007 11:18:26 +0000 (+0000) Subject: kes Optimize the use of the database a bit in the Status dir command. X-Git-Tag: Release-2.2.0~1061 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=556161f68a5ac813546c6b273269df96e4cf36bc;p=bacula%2Fbacula kes Optimize the use of the database a bit in the Status dir command. Only open it when needed, ensure that if any previous database was opened, it is closed. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@4160 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/src/dird/protos.h b/bacula/src/dird/protos.h index a7870e7fad..fa0b88d737 100644 --- a/bacula/src/dird/protos.h +++ b/bacula/src/dird/protos.h @@ -200,7 +200,7 @@ void update_vol_pool(UAContext *ua, char *val, MEDIA_DBR *mr, POOL_DBR *opr); /* ua_output.c */ void prtit(void *ctx, const char *msg); -int complete_jcr_for_job(JCR *jcr, JOB *job, POOL *pool); +bool complete_jcr_for_job(JCR *jcr, JOB *job, POOL *pool); RUN *find_next_run(RUN *run, JOB *job, time_t &runtime, int ndays); /* ua_restore.c */ diff --git a/bacula/src/dird/ua_output.c b/bacula/src/dird/ua_output.c index 5f05046870..3d03199f12 100644 --- a/bacula/src/dird/ua_output.c +++ b/bacula/src/dird/ua_output.c @@ -1,16 +1,7 @@ -/* - * - * Bacula Director -- User Agent Output Commands - * I.e. messages, listing database, showing resources, ... - * - * Kern Sibbald, September MM - * - * 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. @@ -34,6 +25,15 @@ (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich, Switzerland, email:ftf@fsfeurope.org. */ +/* + * + * Bacula Director -- User Agent Output Commands + * I.e. messages, listing database, showing resources, ... + * + * Kern Sibbald, September MM + * + * Version $Id$ + */ #include "bacula.h" #include "dird.h" @@ -602,7 +602,7 @@ RUN *find_next_run(RUN *run, JOB *job, time_t &runtime, int ndays) * Fill in the remaining fields of the jcr as if it * is going to run the job. */ -int complete_jcr_for_job(JCR *jcr, JOB *job, POOL *pool) +bool complete_jcr_for_job(JCR *jcr, JOB *job, POOL *pool) { POOL_DBR pr; @@ -611,6 +611,10 @@ int complete_jcr_for_job(JCR *jcr, JOB *job, POOL *pool) if (pool) { jcr->pool = pool; /* override */ } + if (jcr->db) { + db_close_database(jcr, jcr->db); + jcr->db = NULL; + } jcr->db = jcr->db=db_init_database(jcr, jcr->catalog->db_name, jcr->catalog->db_user, jcr->catalog->db_password, jcr->catalog->db_address, jcr->catalog->db_port, jcr->catalog->db_socket, @@ -620,8 +624,10 @@ int complete_jcr_for_job(JCR *jcr, JOB *job, POOL *pool) jcr->catalog->db_name); if (jcr->db) { Jmsg(jcr, M_FATAL, 0, "%s", db_strerror(jcr->db)); + db_close_database(jcr, jcr->db); + jcr->db = NULL; } - return 0; + return false; } bstrncpy(pr.Name, jcr->pool->hdr.name, sizeof(pr.Name)); while (!db_get_pool_record(jcr, jcr->db, &pr)) { /* get by Name */ @@ -633,13 +639,13 @@ int complete_jcr_for_job(JCR *jcr, JOB *job, POOL *pool) db_close_database(jcr, jcr->db); jcr->db = NULL; } - return 0; + return false; } else { Jmsg(jcr, M_INFO, 0, _("Pool %s created in database.\n"), pr.Name); } } jcr->jr.PoolId = pr.PoolId; - return 1; + return true; } diff --git a/bacula/src/dird/ua_status.c b/bacula/src/dird/ua_status.c index 2da4d56a2e..b5fa59f537 100644 --- a/bacula/src/dird/ua_status.c +++ b/bacula/src/dird/ua_status.c @@ -1,15 +1,7 @@ -/* - * - * Bacula Director -- User Agent Status Command - * - * Kern Sibbald, August MMI - * - * Version $Id$ - */ /* Bacula® - The Network Backup Solution - Copyright (C) 2001-2006 Free Software Foundation Europe e.V. + Copyright (C) 2001-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. @@ -33,6 +25,14 @@ (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich, Switzerland, email:ftf@fsfeurope.org. */ +/* + * + * Bacula Director -- User Agent Status Command + * + * Kern Sibbald, August MMI + * + * Version $Id$ + */ #include "bacula.h" @@ -100,9 +100,6 @@ int status_cmd(UAContext *ua, const char *cmd) CLIENT *client; int item, i; - if (!open_client_db(ua)) { - return 1; - } Dmsg1(20, "status:%s:\n", cmd); for (i=1; iargc; i++) { diff --git a/bacula/src/version.h b/bacula/src/version.h index 63c9173121..ee2260d30e 100644 --- a/bacula/src/version.h +++ b/bacula/src/version.h @@ -4,8 +4,8 @@ #undef VERSION #define VERSION "2.1.4" -#define BDATE "10 February 2007" -#define LSMDATE "10Feb07" +#define BDATE "11 February 2007" +#define LSMDATE "11Feb07" #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 ad5f0bde1f..89873c09fa 100644 --- a/bacula/technotes-2.1 +++ b/bacula/technotes-2.1 @@ -1,6 +1,10 @@ Technical notes on version 2.1 General: +11Feb07 +kes Optimize the use of the database a bit in the Status dir command. + Only open it when needed, ensure that if any previous database + was opened, it is closed. 10Feb07 kes Correct VolCatBytes bug from media patch. kes Apply patch from bug #612 by Rudolf Cejka to speedup pruning