Skip to content

Commit

Permalink
ndb: only invalidate the database cache if we must
Browse files Browse the repository at this point in the history
We now only invaludate the cache if the cached entry is 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 cache
if a modified header with a different id is written.
  • Loading branch information
mlschroe committed Aug 8, 2021
1 parent 24b6c45 commit 4b758e1
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions lib/backend/ndb/glue.c
Expand Up @@ -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);
}

Expand All @@ -325,16 +326,19 @@ 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;
}

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);
}

Expand Down

0 comments on commit 4b758e1

Please sign in to comment.