;;
slots)
- ${MTX} -f $CHANGER status slot | wc -l
+ ${MTX} -f $CHANGER status slot | wc -l | bc
;;
esac
Kern's ToDo List
- 26 December 2005
+ 07 January 2006
Major development:
Project Developer
=== Done
- Make sure that all do_prompt() calls in Dir check for
-1 (error) and -2 (cancel) returns.
+- Fix foreach_jcr() to have free_jcr() inside next().
+ jcr=jcr_walk_start();
+ for ( ; jcr; (jcr=jcr_walk_next(jcr)) )
+ ...
+ jcr_walk_end(jcr);
+
General:
+1.38.4:
+07Jan06
+- Add PoolId to Job record when updating it at job start time.
+06Jan06
+- Pull in more code from 1.39 so that there are fewer file
+ differences (the new ua_dotcmds.c, base64.h, crypto.h
+ hmac.c jcr.c (dird and lib) lib.h md5.h parse_conf.c
+ util.c. Aside from ua_dotcmds.c these are mostly crypto
+ upgrades.
+- Implement new method of walking the jcr chain. The
+ incr/dec of the use_count is done within the walking
+ routines. This should prevent a jcr from being freed
+ from under the walk routines.
+
Release 1.38.3 05Jan06:
04Jan06
- Move the suitable_drive flag to a better place to prevent
* Version $Id$
*/
/*
- Copyright (C) 2000-2005 Kern Sibbald
+ Copyright (C) 2000-2006 Kern Sibbald
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
*/
-
/* The following is necessary so that we do not include
* the dummy external definition of DB.
*/
int type)
{
int stat;
- char ed1[CRYPTO_DIGEST_MAX_SIZE];
+ char ed1[50];
db_lock(mdb);
Mmsg(mdb->cmd, "UPDATE File SET MD5='%s' WHERE FileId=%s", digest,
struct tm tm;
btime_t JobTDate;
int stat;
- char ed1[50], ed2[50], ed3[50];
+ char ed1[50], ed2[50], ed3[50], ed4[50];
stime = jr->StartTime;
localtime_r(&stime, &tm);
db_lock(mdb);
Mmsg(mdb->cmd, "UPDATE Job SET JobStatus='%c',Level='%c',StartTime='%s',"
-"ClientId=%s,JobTDate=%s WHERE JobId=%s",
+"ClientId=%s,JobTDate=%s,PoolId=%s WHERE JobId=%s",
(char)(jcr->JobStatus),
(char)(jr->JobLevel), dt,
edit_int64(jr->ClientId, ed1),
edit_uint64(JobTDate, ed2),
- edit_int64(jr->JobId, ed3));
+ edit_int64(jr->JobId, ed3),
+ edit_int64(jr->PoolId, ed4));
stat = UPDATE_DB(jcr, mdb, mdb->cmd);
mdb->changes = 0;
* Version $Id$
*/
/*
- Copyright (C) 2000-2005 Kern Sibbald
+ Copyright (C) 2000-2006 Kern Sibbald
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
jcr->PoolId = pr.PoolId;
jcr->jr.PoolId = pr.PoolId;
+ /*
+ * Fire off any clone jobs (run directives)
+ */
Dmsg2(900, "cloned=%d run_cmds=%p\n", jcr->cloned, jcr->job->run_cmds);
if (!jcr->cloned && jcr->job->run_cmds) {
char *runcmd;
* Version $Id$
*/
/*
- Copyright (C) 2000-2005 Kern Sibbald
+ Copyright (C) 2000-2006 Kern Sibbald
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
job_end_push(jcr, reload_job_end_cb, (void *)((long int)table));
njobs++;
}
- free_jcr(jcr);
}
+ endeach_jcr(jcr);
}
/* Reset globals */
static void job_monitor_destructor(watchdog_t *self)
{
- JCR *control_jcr = (JCR *) self->data;
+ JCR *control_jcr = (JCR *)self->data;
free_jcr(control_jcr);
}
if (jcr->JobId == 0) {
Dmsg2(800, "Skipping JCR %p (%s) with JobId 0\n",
jcr, jcr->Job);
- /* Keep reference counts correct */
- free_jcr(jcr);
continue;
}
cancel_job(ua, jcr);
free_ua_context(ua);
- Dmsg1(800, "Have cancelled JCR %p\n", jcr);
+ Dmsg2(800, "Have cancelled JCR %p Job=%d\n", jcr, jcr->JobId);
}
/* Keep reference counts correct */
- free_jcr(jcr);
}
+ endeach_jcr(jcr);
}
/*
*
*/
/*
- Copyright (C) 2004-2005 Kern Sibbald
+ Copyright (C) 2004-2006 Kern Sibbald
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
}
foreach_jcr(jcr) {
if (jcr->JobId == 0) {
- free_jcr(jcr);
continue;
}
if (jcr->JobId == JobId) {
break;
}
}
+ /* endeach_jcr(jcr) not needed because freed below */
+
if (!found) {
/* ***FIXME*** raise exception */
return NULL;
* Version $Id$
*/
/*
- Copyright (C) 2000-2005 Kern Sibbald
+ Copyright (C) 2000-2006 Kern Sibbald
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
/* Count Jobs running */
foreach_jcr(jcr) {
if (jcr->JobId == 0) { /* this is us */
- free_jcr(jcr);
continue;
}
- free_jcr(jcr);
njobs++;
}
+ endeach_jcr(jcr);
if (njobs == 0) {
bsendmsg(ua, _("No Jobs running.\n"));
foreach_jcr(jcr) {
char ed1[50];
if (jcr->JobId == 0) { /* this is us */
- free_jcr(jcr);
continue;
}
bsnprintf(buf, sizeof(buf), _("JobId=%s Job=%s"), edit_int64(jcr->JobId, ed1), jcr->Job);
add_prompt(ua, buf);
- free_jcr(jcr);
}
+ endeach_jcr(jcr);
if (do_prompt(ua, _("Job"), _("Choose Job to cancel"), buf, sizeof(buf)) < 0) {
return 1;
foreach_jcr(jcr) {
if (jcr->JobId != 0) {
running = true;
- free_jcr(jcr);
break;
}
- free_jcr(jcr);
}
+ endeach_jcr(jcr);
+
if (running) {
bmicrosleep(1, 0);
}
* Version $Id$
*/
/*
- Copyright (C) 2001-2005 Kern Sibbald
+ Copyright (C) 2001-2006 Kern Sibbald
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
bsendmsg(ua, DotStatusJob, edit_int64(njcr->JobId, ed1),
njcr->JobStatus, njcr->JobErrors);
}
- free_jcr(njcr);
}
+ endeach_jcr(njcr);
} else if (strcasecmp(ua->argk[2], "last") == 0) {
bsendmsg(ua, OKqstatus, ua->argk[2]);
if ((last_jobs) && (last_jobs->size() > 0)) {
Dmsg0(200, "enter list_run_jobs()\n");
bsendmsg(ua, _("\nRunning Jobs:\n"));
foreach_jcr(jcr) {
- njobs++;
if (jcr->JobId == 0) { /* this is us */
/* this is a console or other control job. We only show console
* jobs in the status output.
bstrftime_nc(dt, sizeof(dt), jcr->start_time);
bsendmsg(ua, _("Console connected at %s\n"), dt);
}
- njobs--;
- }
- free_jcr(jcr);
+ continue;
+ }
+ njobs++;
}
+ endeach_jcr(jcr);
+
if (njobs == 0) {
/* Note the following message is used in regress -- don't change */
bsendmsg(ua, _("No Jobs running.\n====\n"));
bsendmsg(ua, _("======================================================================\n"));
foreach_jcr(jcr) {
if (jcr->JobId == 0 || !acl_access_ok(ua, Job_ACL, jcr->job->hdr.name)) {
- free_jcr(jcr);
continue;
}
njobs++;
free_pool_memory(emsg);
pool_mem = false;
}
- free_jcr(jcr);
}
+ endeach_jcr(jcr);
bsendmsg(ua, _("====\n"));
Dmsg0(200, "leave list_run_jobs()\n");
}
*
*/
/*
- Copyright (C) 2001-2005 Kern Sibbald
+ Copyright (C) 2001-2006 Kern Sibbald
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
}
sendit(msg, len, arg);
if (njcr->JobId == 0) {
- free_jcr(njcr);
continue;
}
sec = time(NULL) - njcr->start_time;
len = Mmsg(msg, _(" SDSocket closed.\n"));
sendit(msg, len, arg);
}
- free_jcr(njcr);
}
+ endeach_jcr(njcr);
+
Dmsg0(1000, "Begin status jcr loop.\n");
if (!found) {
len = Mmsg(msg, _("No Jobs running.\n"));
if (njcr->JobId != 0) {
bnet_fsend(dir, DotStatusJob, njcr->JobId, njcr->JobStatus, njcr->JobErrors);
}
- free_jcr(njcr);
}
+ endeach_jcr(njcr);
} else if (strcmp(time, "last") == 0) {
bnet_fsend(dir, OKqstatus, time);
if ((last_jobs) && (last_jobs->size() > 0)) {
if (njcr->JobId != 0) {
stat = JS_Running;
termstat = _("Bacula Running");
- free_jcr(njcr);
break;
}
- free_jcr(njcr);
}
+ endeach_jcr(njcr);
+
if (stat != 0) {
goto done;
}
* Version $Id$
*/
/*
- Copyright (C) 2000-2005 Kern Sibbald
+ Copyright (C) 2000-2006 Kern Sibbald
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
jcr->JobStatus == JS_FatalError)
#define foreach_jcr(jcr) \
- for ((jcr)=NULL; ((jcr)=get_next_jcr(jcr)); )
+ for (jcr=jcr_walk_start(); jcr; (jcr=jcr_walk_next(jcr)) )
+
+#define endeach_jcr(jcr) jcr_walk_end(jcr)
#define SD_APPEND 1
#define SD_READ 0
@$(MV) Makefile Makefile.bak
@$(SED) "/^# DO NOT DELETE:/,$$ d" Makefile.bak > Makefile
@$(ECHO) "# DO NOT DELETE: nice dependency list follows" >> Makefile
- @$(CXX) -S -M $(CPPFLAGS) $(XINC) $(PYTHON_INC) -I$(srcdir) -I$(basedir) $(SQL_INC) *.c >> Makefile
+ @$(CXX) -S -M $(CPPFLAGS) $(XINC) $(PYTHON_INC) -I$(srcdir) -I$(basedir) $(SQL_INC) *.c >>Makefile
@if test -f Makefile ; then \
$(RMF) Makefile.bak; \
else \
$(MV) Makefile.bak Makefile; \
- echo -e "Something went wrong\n\a"; \
+ echo " ===== Something went wrong in make depend ====="; \
fi
# -----------------------------------------------------------------------
*/
/*
- Copyright (C) 2000-2005 Kern Sibbald and John Walker
+ Copyright (C) 2000-2005 Kern Sibbald
This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License as
- published by the Free Software Foundation; either version 2 of
- the License, or (at your option) any later version.
+ modify it under the terms of the GNU General Public License
+ version 2 as amended with additional clauses defined in the
+ file LICENSE in the main source directory.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public
- License along with this program; if not, write to the Free
- Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
- MA 02111-1307, USA.
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ the file LICENSE for additional details.
*/
* license please contact Landon Fuller <landonf@opendarwin.org>.
*/
/*
- Copyright (C) 2005 Kern Sibbald
+ Copyright (C) 2006 Kern Sibbald
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
* This must be kept in sync with the available message digest algorithms.
* Just in case someone forgets, I've added assertions
* to crypto_digest_finalize().
- * MD5: 128 bits
- * SHA-1: 160 bits
+ * MD5: 128 bits
+ * SHA-1: 160 bits
*/
#ifndef HAVE_SHA2
#define CRYPTO_DIGEST_MAX_SIZE CRYPTO_DIGEST_SHA1_SIZE
*
*/
/*
- Copyright (C) 2000-2005 Kern Sibbald
+ Copyright (C) 2000-2006 Kern Sibbald
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
void free_jcr(JCR *jcr)
{
- Dmsg1(3400, "Enter free_jcr 0x%x\n", jcr);
+ Dmsg2(3400, "Enter free_jcr 0x%x job=%d\n", jcr, jcr->JobId);
#endif
Dmsg3(3400, "Dec free_jcr 0x%x use_count=%d jobid=%d\n", jcr, jcr->use_count, jcr->JobId);
if (jcr->use_count > 0) { /* if in use */
unlock_jcr_chain();
- Dmsg2(3400, "free_jcr 0x%x use_count=%d\n", jcr, jcr->use_count);
+ Dmsg3(3400, "free_jcr 0x%x job=%d use_count=%d\n", jcr, jcr->JobId, jcr->use_count);
return;
}
}
-JCR *get_next_jcr(JCR *prev_jcr)
+/*
+ * Start walk of jcr chain
+ * The proper way to walk the jcr chain is:
+ * JCR *jcr;
+ * foreach_jcr(jcr) {
+ * ...
+ * }
+ * endeach_jcr(jcr);
+ *
+ * It is possible to leave out the endeach_jcr(jcr), but
+ * in that case, the last jcr referenced must be explicitly
+ * released with:
+ *
+ * free_jcr(jcr);
+ *
+ */
+JCR *jcr_walk_start()
+{
+ JCR *jcr;
+ lock_jcr_chain();
+ jcr = (JCR *)jcrs->first();
+ if (jcr) {
+ jcr->inc_use_count();
+ Dmsg3(3400, "Inc jcr_walk_start 0x%x job=%d use_count=%d\n", jcr,
+ jcr->JobId, jcr->use_count);
+ }
+ unlock_jcr_chain();
+ return jcr;
+}
+
+/*
+ * Get next jcr from chain, and release current one
+ */
+JCR *jcr_walk_next(JCR *prev_jcr)
{
JCR *jcr;
jcr = (JCR *)jcrs->next(prev_jcr);
if (jcr) {
jcr->inc_use_count();
- Dmsg2(3400, "Inc get_next_jcr 0x%x use_count=%d\n", jcr, jcr->use_count);
+ Dmsg3(3400, "Inc jcr_walk_next 0x%x job=%d use_count=%d\n", jcr,
+ jcr->JobId, jcr->use_count);
}
unlock_jcr_chain();
+ if (prev_jcr) {
+ free_jcr(prev_jcr);
+ }
return jcr;
}
+/*
+ * Release last jcr referenced
+ */
+void jcr_walk_end(JCR *jcr)
+{
+ if (jcr) {
+ free_jcr(jcr);
+ }
+}
+
+
+/*
+ * Setup to call the timeout check routine every 30 seconds
+ * This routine will check any timers that have been enabled.
+ */
bool init_jcr_subsystem(void)
{
watchdog_t *wd = new_watchdog();
*/
foreach_jcr(jcr) {
if (jcr->JobId == 0) {
- free_jcr(jcr);
continue;
}
fd = jcr->store_bsock;
timer_start = fd->timer_start;
if (timer_start && (watchdog_time - timer_start) > fd->timeout) {
fd->timer_start = 0; /* turn off timer */
- fd->timed_out = TRUE;
+ 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);
timer_start = fd->timer_start;
if (timer_start && (watchdog_time - timer_start) > fd->timeout) {
fd->timer_start = 0; /* turn off timer */
- fd->timed_out = TRUE;
+ 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);
timer_start = fd->timer_start;
if (timer_start && (watchdog_time - timer_start) > fd->timeout) {
fd->timer_start = 0; /* turn off timer */
- fd->timed_out = TRUE;
+ 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);
}
}
- free_jcr(jcr);
}
+ endeach_jcr(jcr);
Dmsg0(3400, "Finished JCR timeout checks\n");
}
*/
/*
- Copyright (C) 2000-2003 Kern Sibbald and John Walker
+ Copyright (C) 2000-2005 Kern Sibbald
This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License as
- published by the Free Software Foundation; either version 2 of
- the License, or (at your option) any later version.
+ modify it under the terms of the GNU General Public License
+ version 2 as amended with additional clauses defined in the
+ file LICENSE in the main source directory.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public
- License along with this program; if not, write to the Free
- Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
- MA 02111-1307, USA.
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ the file LICENSE for additional details.
*/
void job_end_push(JCR *jcr, void job_end_cb(JCR *jcr,void *), void *ctx);
void lock_jobs();
void unlock_jobs();
+JCR *jcr_walk_start();
+JCR *jcr_walk_next(JCR *prev_jcr);
+void jcr_walk_end(JCR *jcr);
/* lex.c */
* Version $Id$
*/
/*
- Copyright (C) 2000-2005 Kern Sibbald
+ Copyright (C) 2000-2006 Kern Sibbald
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
*
*/
/*
- Copyright (C) 2000-2004 Kern Sibbald and John Walker
+ Copyright (C) 2000-2006 Kern Sibbald
This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License as
- published by the Free Software Foundation; either version 2 of
- the License, or (at your option) any later version.
+ modify it under the terms of the GNU General Public License
+ version 2 as amended with additional clauses defined in the
+ file LICENSE in the main source directory.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public
- License along with this program; if not, write to the Free
- Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
- MA 02111-1307, USA.
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ the file LICENSE for additional details.
*/
#ifndef __BLOCK_H
#define __BLOCK_H 1
-#define MAX_BLOCK_LENGTH 500001 /* this is a sort of sanity check */
+#define MAX_BLOCK_LENGTH (1024*1024 + 1) /* this is a sort of sanity check */
#define DEFAULT_BLOCK_SIZE (512 * 126) /* 64,512 N.B. do not use 65,636 here */
/* Block Header definitions. */
*
*/
/*
- Copyright (C) 2003-2005 Kern Sibbald
+ Copyright (C) 2003-2006 Kern Sibbald
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
}
#endif
}
- free_jcr(jcr);
}
+ endeach_jcr(jcr);
+
if (!found) {
bnet_fsend(user, _("No Jobs running.\n"));
}
if (njcr->JobId != 0) {
bnet_fsend(dir, DotStatusJob, njcr->JobId, njcr->JobStatus, njcr->JobErrors);
}
- free_jcr(njcr);
}
+ endeach_jcr(njcr);
} else if (strcmp(time.c_str(), "last") == 0) {
bnet_fsend(dir, OKqstatus, time.c_str());
if ((last_jobs) && (last_jobs->size() > 0)) {
*/
#undef VERSION
-#define VERSION "1.39.3"
-#define BDATE "17 December 2005"
-#define LSMDATE "17Dec05"
+#define VERSION "1.39.4"
+#define BDATE "06 January 2006"
+#define LSMDATE "06Jan06"
/* Debug flags */
#undef DEBUG