From: Eric Bollengier Date: Wed, 9 Apr 2008 19:55:36 +0000 (+0000) Subject: ebl Add sanity checks for VolWriteTime and VolReadTime X-Git-Tag: Release-3.0.0~1583 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=016d56690058f23603cb714443fd3fd0fc6dde76;p=bacula%2Fbacula ebl Add sanity checks for VolWriteTime and VolReadTime ebl Take care of bad clock changes while computing VolWriteTime and VolReadTime. This should fix or limit #1066 git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@6781 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/src/cats/sql_update.c b/bacula/src/cats/sql_update.c index 161effa98d..fa605998f7 100644 --- a/bacula/src/cats/sql_update.c +++ b/bacula/src/cats/sql_update.c @@ -356,6 +356,14 @@ db_update_media_record(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr) UPDATE_DB(jcr, mdb, mdb->cmd); } + /* sanity checks for #1066 */ + if (mr->VolReadTime < 0) { + mr->VolReadTime = 0; + } + if (mr->VolWriteTime < 0) { + mr->VolWriteTime = 0; + } + Mmsg(mdb->cmd, "UPDATE Media SET VolJobs=%u," "VolFiles=%u,VolBlocks=%u,VolBytes=%s,VolMounts=%u,VolErrors=%u," "VolWrites=%u,MaxVolBytes=%s,VolStatus='%s'," diff --git a/bacula/src/dird/catreq.c b/bacula/src/dird/catreq.c index e04a1e7b43..2119f1ebe6 100644 --- a/bacula/src/dird/catreq.c +++ b/bacula/src/dird/catreq.c @@ -284,10 +284,14 @@ void catalog_request(JCR *jcr, BSOCK *bs) mr.VolWrites = sdmr.VolWrites; mr.Slot = sdmr.Slot; mr.InChanger = sdmr.InChanger; - mr.VolReadTime = sdmr.VolReadTime; - mr.VolWriteTime = sdmr.VolWriteTime; mr.VolParts = sdmr.VolParts; bstrncpy(mr.VolStatus, sdmr.VolStatus, sizeof(mr.VolStatus)); + if (sdmr.VolReadTime >= 0) { + mr.VolReadTime = sdmr.VolReadTime; + } + if (sdmr.VolWriteTime >= 0) { + mr.VolWriteTime = sdmr.VolWriteTime; + } /* * Update to point to the last device used to write the Volume. * However, do so only if we are writing the tape, i.e. diff --git a/bacula/src/stored/dev.c b/bacula/src/stored/dev.c index 381986c68c..7c1410b410 100644 --- a/bacula/src/stored/dev.c +++ b/bacula/src/stored/dev.c @@ -2234,12 +2234,15 @@ void DEVICE::edit_mount_codes(POOL_MEM &omsg, const char *imsg) } } -/* return the last timer interval (ms) */ +/* return the last timer interval (ms) + * or 0 if something goes wrong + */ btime_t DEVICE::get_timer_count() { - btime_t old = last_timer; + btime_t temp = last_timer; last_timer = get_current_btime(); - return last_timer - old; + temp = last_timer - temp; /* get elapsed time */ + return (temp>0)?temp:0; /* take care of skewed clock */ } /* read from fd */ diff --git a/bacula/technotes-2.3 b/bacula/technotes-2.3 index 724940a656..d852fc13a6 100644 --- a/bacula/technotes-2.3 +++ b/bacula/technotes-2.3 @@ -25,6 +25,9 @@ Add long term statistics job table General: 09Apr08 +ebl Add sanity checks for VolWriteTime and VolReadTime +ebl Take care of bad clock changes while computing VolWriteTime + and VolReadTime. This should fix or limit #1066 kes Correct error string numbers in dird/catreq.c kes Restructure reserving, acquiring, and mounting volumes. Calls to autochanger are deferred for mount.c -- simplifes the code.