diff options
author | Panu Matilainen <pmatilai@redhat.com> | 2012-08-30 11:02:54 +0300 |
---|---|---|
committer | Panu Matilainen <pmatilai@redhat.com> | 2012-08-30 11:02:54 +0300 |
commit | 551209488ff63092abccad34d8766992bf473484 (patch) | |
tree | 82dff3fe481f680112dc8676b6015aa5b4da1d92 /lib | |
parent | 1a3a4089def9b00790eeebd6f931c99a03a3d44b (diff) | |
download | rpm-551209488ff63092abccad34d8766992bf473484.tar.gz rpm-551209488ff63092abccad34d8766992bf473484.tar.bz2 rpm-551209488ff63092abccad34d8766992bf473484.zip |
Cache the actual result on rpmdb header verification
- Previously we'd turn all but FAILED results into "OK" after first
check, now we return the real value. And perhaps more importantly,
no longer try re-verifying previously failed headers in vain.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/rpmdb.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/lib/rpmdb.c b/lib/rpmdb.c index 434e0666c..05d205ac6 100644 --- a/lib/rpmdb.c +++ b/lib/rpmdb.c @@ -41,6 +41,7 @@ #undef HTDATATYPE #define HASHTYPE dbChk #define HTKEYTYPE unsigned int +#define HTDATATYPE rpmRC #include "lib/rpmhash.H" #include "lib/rpmhash.C" #undef HASHTYPE @@ -198,7 +199,7 @@ static dbiIndex rpmdbOpenIndex(rpmdb db, rpmDbiTagVal rpmtag, int flags) /* Allocate based on max header instance number + some reserve */ if (!verifyonly && (db->db_checked == NULL)) { db->db_checked = dbChkCreate(1024 + pkgInstance(dbi, 0) / 4, - uintId, uintCmp, NULL); + uintId, uintCmp, NULL, NULL); } /* If primary got created, we can safely run without fsync */ if ((!verifyonly && (dbiFlags(dbi) & DBI_CREATED)) || db->cfg.db_no_fsync) { @@ -1714,8 +1715,11 @@ static rpmRC miVerifyHeader(rpmdbMatchIterator mi, const void *uh, size_t uhlen) /* Don't bother re-checking a previously read header. */ if (mi->mi_db->db_checked) { - if (dbChkHasEntry(mi->mi_db->db_checked, mi->mi_offset)) - rpmrc = RPMRC_OK; + rpmRC *res; + if (dbChkGetEntry(mi->mi_db->db_checked, mi->mi_offset, + &res, NULL, NULL)) { + rpmrc = res[0]; + } } /* If blob is unchecked, check blob import consistency now. */ @@ -1731,8 +1735,8 @@ static rpmRC miVerifyHeader(rpmdbMatchIterator mi, const void *uh, size_t uhlen) msg = _free(msg); /* Mark header checked. */ - if (mi->mi_db && mi->mi_db->db_checked && rpmrc != RPMRC_FAIL) { - dbChkAddEntry(mi->mi_db->db_checked, mi->mi_offset); + if (mi->mi_db && mi->mi_db->db_checked) { + dbChkAddEntry(mi->mi_db->db_checked, mi->mi_offset, rpmrc); } } return rpmrc; |