From f0c91e8f7c98fb8b0facb77960e00fef80dd01dc Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Tue, 17 Jun 2003 11:04:54 +0000 Subject: [PATCH] Check neg device use cound + fix BlockNumber check + close socket with shutdown() if timed out git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@586 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/kernstodo | 1 + bacula/src/lib/bnet.c | 5 ++++- bacula/src/stored/dev.c | 6 ++++++ bacula/src/stored/label.c | 1 + bacula/src/stored/read.c | 4 ++-- bacula/src/version.h | 5 ++--- 6 files changed, 16 insertions(+), 6 deletions(-) diff --git a/bacula/kernstodo b/bacula/kernstodo index 579c34b127..03f966506b 100644 --- a/bacula/kernstodo +++ b/bacula/kernstodo @@ -32,6 +32,7 @@ Testing to do: (painful) - Figure out how to use ssh or stunnel to protect Bacula communications. For 1.31 release: +- Fix first block number after label to be zero instead of 1 (reset after label). - Grep for Backup OK in regression script. - Do NOT reuse same JobId if tape written. - Move JobFiles and JobBytes to SD rather than FD -- more correct. diff --git a/bacula/src/lib/bnet.c b/bacula/src/lib/bnet.c index a05702c553..8ee57ddffd 100644 --- a/bacula/src/lib/bnet.c +++ b/bacula/src/lib/bnet.c @@ -797,7 +797,10 @@ bnet_close(BSOCK *bsock) for ( ; bsock != NULL; bsock = next) { next = bsock->next; if (!bsock->duped) { - close(bsock->fd); + if (bsock->timed_out) { + shutdown(bsock->fd, 2); /* discard any pending I/O */ + } + close(bsock->fd); /* normal close */ } term_bsock(bsock); } diff --git a/bacula/src/stored/dev.c b/bacula/src/stored/dev.c index 8eb7acb577..de8d15eb4b 100644 --- a/bacula/src/stored/dev.c +++ b/bacula/src/stored/dev.c @@ -1106,6 +1106,9 @@ close_dev(DEVICE *dev) do_close(dev); } dev->use_count--; +#ifdef FULL_DEBUG + ASSERT(dev->use_count >= 0); +#endif } /* @@ -1121,6 +1124,9 @@ void force_close_dev(DEVICE *dev) Dmsg0(29, "really close_dev\n"); do_close(dev); dev->use_count--; +#ifdef FULL_DEBUG + ASSERT(dev->use_count >= 0); +#endif } int truncate_dev(DEVICE *dev) diff --git a/bacula/src/stored/label.c b/bacula/src/stored/label.c index 3867976b5d..739e8d8447 100644 --- a/bacula/src/stored/label.c +++ b/bacula/src/stored/label.c @@ -243,6 +243,7 @@ int write_volume_label_to_block(JCR *jcr, DEVICE *dev, DEV_BLOCK *block) create_volume_label_record(jcr, dev, &rec); empty_block(block); /* Volume label always at beginning */ + block->BlockNumber = 0; if (!write_record_to_block(block, &rec)) { free_pool_memory(rec.data); Jmsg1(jcr, M_FATAL, 0, _("Cannot write Volume label to block for device %s\n"), diff --git a/bacula/src/stored/read.c b/bacula/src/stored/read.c index 3434eb260c..45d89aebd1 100644 --- a/bacula/src/stored/read.c +++ b/bacula/src/stored/read.c @@ -188,11 +188,11 @@ int do_read_data(JCR *jcr) } if (block->block_read) { - if (++BlockNumber != block->BlockNumber) { + if (BlockNumber != block->BlockNumber) { Jmsg(jcr, M_ERROR, 0, _("Invalid block number. Expected %u, got %u\n"), BlockNumber, block->BlockNumber); } - BlockNumber = block->BlockNumber; + BlockNumber = block->BlockNumber + 1; block->block_read = false; } diff --git a/bacula/src/version.h b/bacula/src/version.h index 52659d533e..e71542c889 100644 --- a/bacula/src/version.h +++ b/bacula/src/version.h @@ -10,6 +10,8 @@ #define SMCHECK #define TRACE_FILE 1 +#define FULL_DEBUG 1 /* normally on for testing only */ + /* Turn this on ONLY if you want all Dmsg() to append to the * trace file. Implemented mainly for Win32 ... */ @@ -18,9 +20,6 @@ /* Turn this on if you want to try the new Job semaphore code */ #define USE_SEMAPHORE -/* IF you undefine this, Bacula will run 10X slower */ -#define NO_POLL_TEST 1 - /* #define NO_ATTRIBUTES_TEST 1 */ /* #define NO_TAPE_WRITE_TEST 1 */ /* #define FD_NO_SEND TEST 1 */ -- 2.39.5