From: Kern Sibbald Date: Tue, 3 Nov 2009 12:14:38 +0000 (+0100) Subject: Cleanup attribute catalog insert errors + cancel SD only once X-Git-Tag: Release-5.0.0~280^2~16 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=84aabba7cee82f0c1f6dae8882a2ee0bb26306ca;p=bacula%2Fbacula Cleanup attribute catalog insert errors + cancel SD only once --- diff --git a/bacula/src/dird/catreq.c b/bacula/src/dird/catreq.c index aac92cf8fa..dc5d03d3c3 100644 --- a/bacula/src/dird/catreq.c +++ b/bacula/src/dird/catreq.c @@ -504,21 +504,20 @@ static void update_attribute(JCR *jcr, char *msg, int32_t msglen) */ void catalog_update(JCR *jcr, BSOCK *bs) { - POOLMEM *omsg; - - if (job_canceled(jcr) || !jcr->pool->catalog_files) { - goto bail_out; /* user disabled cataloging */ + if (!jcr->pool->catalog_files) { + return; /* user disabled cataloging */ + } + if (job_canceled(jcr)) { + goto bail_out; } if (!jcr->db) { - omsg = get_memory(bs->msglen+1); + POOLMEM *omsg = get_memory(bs->msglen+1); pm_strcpy(omsg, bs->msg); bs->fsend(_("1994 Invalid Catalog Update: %s"), omsg); Jmsg1(jcr, M_FATAL, 0, _("Invalid Catalog Update; DB not open: %s"), omsg); free_memory(omsg); goto bail_out; - } - update_attribute(jcr, bs->msg, bs->msglen); bail_out: @@ -580,7 +579,12 @@ bool despool_attributes_from_file(JCR *jcr, const char *file) last = size; } } - update_attribute(jcr, msg, msglen); + if (!job_canceled(jcr)) { + update_attribute(jcr, msg, msglen); + if (job_canceled(jcr)) { + goto bail_out; + } + } } if (ferror(spool_fd)) { berrno be; diff --git a/bacula/src/dird/job.c b/bacula/src/dird/job.c index 05597a6994..181a411c49 100644 --- a/bacula/src/dird/job.c +++ b/bacula/src/dird/job.c @@ -454,6 +454,10 @@ bool cancel_job(UAContext *ua, JCR *jcr) void cancel_storage_daemon_job(JCR *jcr) { + if (jcr->sd_canceled) { + return; /* cancel only once */ + } + UAContext *ua = new_ua_context(jcr); JCR *control_jcr = new_control_jcr("*JobCancel*", JT_SYSTEM); BSOCK *sd; @@ -487,6 +491,7 @@ void cancel_storage_daemon_job(JCR *jcr) sd->signal(BNET_TERMINATE); sd->close(); ua->jcr->store_bsock = NULL; + jcr->sd_canceled = true; } bail_out: free_jcr(control_jcr); diff --git a/bacula/src/jcr.h b/bacula/src/jcr.h index 58ae568437..52abd89878 100644 --- a/bacula/src/jcr.h +++ b/bacula/src/jcr.h @@ -298,6 +298,7 @@ public: bool run_full_pool_override; bool run_inc_pool_override; bool run_diff_pool_override; + bool sd_canceled; /* set if SD canceled */ FILESET *fileset; /* FileSet resource */ CAT *catalog; /* Catalog resource */ MSGS *messages; /* Default message handler */ diff --git a/bacula/src/lib/bsock.c b/bacula/src/lib/bsock.c index cf3a68cbfd..d35da86409 100644 --- a/bacula/src/lib/bsock.c +++ b/bacula/src/lib/bsock.c @@ -564,6 +564,7 @@ bool BSOCK::despool(void update_attr_spool_size(ssize_t size), ssize_t tsize) size_t nbytes; ssize_t last = 0, size = 0; int count = 0; + JCR *jcr = get_jcr(); rewind(m_spool_fd); @@ -595,11 +596,15 @@ bool BSOCK::despool(void update_attr_spool_size(ssize_t size), ssize_t tsize) } } send(); + if (jcr && job_canceled(jcr)) { + return false; + } + send(); } update_attr_spool_size(tsize - last); if (ferror(m_spool_fd)) { berrno be; - Qmsg1(get_jcr(), M_FATAL, 0, _("fread attr spool error. ERR=%s\n"), + Qmsg1(jcr, M_FATAL, 0, _("fread attr spool error. ERR=%s\n"), be.bstrerror()); return false; }