From: Kern Sibbald Date: Sat, 3 Apr 2010 18:55:57 +0000 (+0200) Subject: Replace ASSERT in block.c with fail Job X-Git-Tag: Release-5.2.1~1542 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=1b40a85bc88d8a9714dc9b35597fff6efe53fcc6;p=bacula%2Fbacula Replace ASSERT in block.c with fail Job --- 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,