diff options
author | Michael Schroeder <mls@suse.de> | 2021-08-08 19:43:45 +0200 |
---|---|---|
committer | Panu Matilainen <pmatilai@redhat.com> | 2021-08-20 11:44:09 +0300 |
commit | 6f9c596d17ec8695aceaab5967e69f8fe1bba7c8 (patch) | |
tree | 3192f2de90ef00823649fdf8f9d7ee8efbd8590b | |
parent | 5250436e5245627b51b872806df841f4d70b59c2 (diff) | |
download | rpm-6f9c596d17ec8695aceaab5967e69f8fe1bba7c8.tar.gz |
ndb: only invalidate the database cache if we must
We now only invalidate the cache if the cached entry gets written
or deleted. This is needed for the code in rpmdbNextIterator()
which first reads the next header and then writes the modified
old header to the database. Therefore we must not free the cached
entry if a modified header with a different id is written.
(cherry picked from commit 297b7be14be7a5182ada2246b5c15802a88475a1)
-rw-r--r-- | lib/backend/ndb/glue.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/lib/backend/ndb/glue.c b/lib/backend/ndb/glue.c index f30f2d461..7ba3056be 100644 --- a/lib/backend/ndb/glue.c +++ b/lib/backend/ndb/glue.c @@ -311,12 +311,13 @@ static void setdata(dbiCursor dbc, unsigned int hdrNum, unsigned char *hdrBlob, static rpmRC ndb_pkgdbPut(dbiIndex dbi, dbiCursor dbc, unsigned int *hdrNum, unsigned char *hdrBlob, unsigned int hdrLen) { + struct ndbEnv_s *ndbenv = dbc->dbi->dbi_rpmdb->db_dbenv; unsigned int hnum = *hdrNum; int rc = RPMRC_OK; if (hnum == 0) { rc = rpmpkgNextPkgIdx(dbc->dbi->dbi_db, &hnum); - if (!rc) + if (!rc && ndbenv->hdrNum == hnum) setdata(dbc, hnum, 0, 0); } @@ -325,7 +326,8 @@ static rpmRC ndb_pkgdbPut(dbiIndex dbi, dbiCursor dbc, unsigned int *hdrNum, un if (!rc) { dbc->hdrNum = hnum; - setdata(dbc, hnum, 0, 0); + if (ndbenv->hdrNum == hnum) + setdata(dbc, hnum, 0, 0); *hdrNum = hnum; } return rc; @@ -333,8 +335,10 @@ static rpmRC ndb_pkgdbPut(dbiIndex dbi, dbiCursor dbc, unsigned int *hdrNum, un static rpmRC ndb_pkgdbDel(dbiIndex dbi, dbiCursor dbc, unsigned int hdrNum) { + struct ndbEnv_s *ndbenv = dbc->dbi->dbi_rpmdb->db_dbenv; dbc->hdrNum = 0; - setdata(dbc, 0, 0, 0); + if (ndbenv->hdrNum == hdrNum) + setdata(dbc, 0, 0, 0); return rpmpkgDel(dbc->dbi->dbi_db, hdrNum); } |