From a666769ee7a440f6fcea601b89d4478bbc846836 Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Sat, 3 Apr 2010 20:55:57 +0200 Subject: [PATCH] Replace ASSERT in block.c with fail Job --- bacula/src/stored/block.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/bacula/src/stored/block.c b/bacula/src/stored/block.c index e4a12fe934..313a3dde6f 100644 --- a/bacula/src/stored/block.c +++ b/bacula/src/stored/block.c @@ -418,25 +418,31 @@ bool write_block_to_dev(DCR *dcr) if (job_canceled(jcr)) { return false; } + ASSERT(block->binbuf == ((uint32_t) (block->bufp - block->buf))); - ASSERT(dev->is_open()); + + wlen = block->binbuf; + if (wlen <= WRITE_BLKHDR_LENGTH) { /* Does block have data in it? */ + Dmsg0(100, "return write_block_to_dev no data to write\n"); + return true; + } /* dump_block(block, "before write"); */ if (dev->at_weot()) { Dmsg0(100, "return write_block_to_dev with ST_WEOT\n"); dev->dev_errno = ENOSPC; - Jmsg0(jcr, M_FATAL, 0, _("Cannot write block. Device at EOM.\n")); + Jmsg1(jcr, M_FATAL, 0, _("Cannot write block. Device at EOM. dev=%s\n"), dev->print_name()); return false; } if (!dev->can_append()) { dev->dev_errno = EIO; - Jmsg(jcr, M_FATAL, 0, _("Attempt to write on read-only Volume.\n")); + Jmsg1(jcr, M_FATAL, 0, _("Attempt to write on read-only Volume. dev=%s\n"), dev->print_name()); return false; } - wlen = block->binbuf; - if (wlen <= WRITE_BLKHDR_LENGTH) { /* Does block have data in it? */ - Dmsg0(100, "return write_block_to_dev no data to write\n"); - return true; + + if (!dev->is_open()) { + Jmsg1(jcr, M_FATAL, 0, _("Attempt to write on closed device=%s\n"), dev->print_name()); + return false; } /* * Clear to the end of the buffer if it is not full, -- 2.39.5