diff options
author | jbj <devnull@localhost> | 2001-10-27 20:09:20 +0000 |
---|---|---|
committer | jbj <devnull@localhost> | 2001-10-27 20:09:20 +0000 |
commit | 7402ce15464cc59617177a2af2799c36c8ef60fd (patch) | |
tree | 6c3185d6dd7d9e8e95b518a896799438176f5199 /rpmdb | |
parent | 4a1a5e81483a2f81b22c3a0d2cb054d93055998e (diff) | |
download | rpm-7402ce15464cc59617177a2af2799c36c8ef60fd.tar.gz rpm-7402ce15464cc59617177a2af2799c36c8ef60fd.tar.bz2 rpm-7402ce15464cc59617177a2af2799c36c8ef60fd.zip |
- legacy signatures always checked where possible on package read.
- wire transactions through rpmcli build modes.
- lazy rpmdb open/close through transaction methods (mostly anyways).
- no-brainer refcounts for rpmdb object.
- check added header against transaction set, replace if newer.
CVS patchset: 5135
CVS date: 2001/10/27 20:09:20
Diffstat (limited to 'rpmdb')
-rw-r--r-- | rpmdb/db1.c | 2 | ||||
-rw-r--r-- | rpmdb/db3.c | 2 | ||||
-rw-r--r-- | rpmdb/dbconfig.c | 8 | ||||
-rw-r--r-- | rpmdb/rpmdb.c | 49 | ||||
-rw-r--r-- | rpmdb/rpmdb.h | 19 |
5 files changed, 40 insertions, 40 deletions
diff --git a/rpmdb/db1.c b/rpmdb/db1.c index bfeaa9e04..57ea66721 100644 --- a/rpmdb/db1.c +++ b/rpmdb/db1.c @@ -516,7 +516,7 @@ static int db1close(/*@only@*/ dbiIndex dbi, /*@unused@*/ unsigned int flags) return rc; } -static int db1open(/*@keep@*/ rpmdb rpmdb, int rpmtag, +static int db1open(rpmdb rpmdb, int rpmtag, /*@out@*/ dbiIndex * dbip) /*@globals rpmGlobalMacroContext, fileSystem @*/ diff --git a/rpmdb/db3.c b/rpmdb/db3.c index 4739dd114..f35a16d51 100644 --- a/rpmdb/db3.c +++ b/rpmdb/db3.c @@ -801,7 +801,7 @@ exit: } /*@=moduncon@*/ -static int db3open(/*@keep@*/ rpmdb rpmdb, int rpmtag, dbiIndex * dbip) +static int db3open(rpmdb rpmdb, int rpmtag, dbiIndex * dbip) /*@globals rpmGlobalMacroContext, fileSystem @*/ /*@modifies *dbip, fileSystem @*/ diff --git a/rpmdb/dbconfig.c b/rpmdb/dbconfig.c index 75d209901..83f3966f8 100644 --- a/rpmdb/dbconfig.c +++ b/rpmdb/dbconfig.c @@ -476,16 +476,16 @@ dbiIndex db3New(rpmdb rpmdb, int rpmtag) dbOpts = _free(dbOpts); /*@-assignexpose@*/ - *dbi = db3dbi; /* structure assignment */ +/*@i@*/ *dbi = db3dbi; /* structure assignment */ /*@=assignexpose@*/ memset(&db3dbi, 0, sizeof(db3dbi)); if (!(dbi->dbi_perms & 0600)) dbi->dbi_perms = 0644; dbi->dbi_mode = rpmdb->db_mode; - /*@-keeptrans@*/ - dbi->dbi_rpmdb = rpmdb; - /*@=keeptrans@*/ + /*@-assignexpose -newreftrans@*/ /* FIX: figger rpmdb/dbi refcounts */ +/*@i@*/ dbi->dbi_rpmdb = rpmdb; + /*@=assignexpose =newreftrans@*/ dbi->dbi_rpmtag = rpmtag; /* diff --git a/rpmdb/rpmdb.c b/rpmdb/rpmdb.c index c94daab1b..c865861ec 100644 --- a/rpmdb/rpmdb.c +++ b/rpmdb/rpmdb.c @@ -817,7 +817,9 @@ int rpmdbClose(rpmdb db) int dbix; int rc = 0; - if (db == NULL) return 0; + if (db == NULL || --db->nrefs > 0) + return 0; + if (db->_dbi) for (dbix = db->db_ndbi; --dbix >= 0; ) { int xx; @@ -833,7 +835,7 @@ int rpmdbClose(rpmdb db) db->db_root = _free(db->db_root); db->db_home = _free(db->db_home); db->_dbi = _free(db->_dbi); - db = _free(db); + /*@-refcounttrans@*/ db = _free(db); /*@=refcounttrans@*/ return rc; } @@ -858,9 +860,8 @@ static /*@only@*/ /*@null@*/ rpmdb newRpmdb(/*@kept@*/ /*@null@*/ const char * root, /*@kept@*/ /*@null@*/ const char * home, int mode, int perms, int flags) - /*@globals _db_filter_dups, rpmGlobalMacroContext, - fileSystem @*/ - /*@modifies _db_filter_dups, rpmGlobalMacroContext, fileSystem @*/ + /*@globals _db_filter_dups, rpmGlobalMacroContext @*/ + /*@modifies _db_filter_dups, rpmGlobalMacroContext @*/ { rpmdb db = xcalloc(sizeof(*db), 1); const char * epfx = _DB_ERRPFX; @@ -875,6 +876,8 @@ rpmdb newRpmdb(/*@kept@*/ /*@null@*/ const char * root, *db = dbTemplate; /* structure assignment */ /*@=assignexpose@*/ + db->_dbi = NULL; + if (!(perms & 0600)) perms = 0644; /* XXX sanity */ if (mode >= 0) db->db_mode = mode; @@ -887,7 +890,9 @@ rpmdb newRpmdb(/*@kept@*/ /*@null@*/ const char * root, /*@=nullpass@*/ if (!(db->db_home && db->db_home[0] != '%')) { rpmError(RPMERR_DBOPEN, _("no dbpath has been set\n")); - (void) rpmdbClose(db); + db->db_root = _free(db->db_root); + db->db_home = _free(db->db_home); + db = _free(db); /*@-globstate@*/ return NULL; /*@=globstate@*/ } /*@-nullpass@*/ @@ -897,6 +902,7 @@ rpmdb newRpmdb(/*@kept@*/ /*@null@*/ const char * root, db->db_filter_dups = _db_filter_dups; db->db_ndbi = dbiTagsMax; db->_dbi = xcalloc(db->db_ndbi, sizeof(*db->_dbi)); + db->nrefs = 1; /*@-globstate@*/ return db; /*@=globstate@*/ } /*@=mods@*/ @@ -1048,6 +1054,18 @@ exit: return rc; } +rpmdb rpmdbLink(rpmdb db) +{ + db->nrefs++; + /*@-refcounttrans@*/ return db; /*@=refcounttrans@*/ +} + +rpmdb rpmdbUnlink(rpmdb db) +{ + db->nrefs--; + return NULL; +} + /* XXX python/rpmmodule.c */ /*@-globs@*/ /* FIX: rpmGlobalMacroContext not in <rpmlib.h> */ int rpmdbOpen (const char * prefix, rpmdb *dbp, int mode, int perms) @@ -1517,7 +1535,7 @@ typedef struct miRE_s { struct _rpmdbMatchIterator { /*@only@*/ const void * mi_keyp; size_t mi_keylen; -/*@kept@*/ rpmdb mi_rpmdb; +/*@refcounted@*/ rpmdb mi_db; int mi_rpmtag; dbiIndexSet mi_set; DBC * mi_dbc; @@ -1547,7 +1565,7 @@ rpmdbMatchIterator rpmdbFreeIterator(rpmdbMatchIterator mi) if (mi == NULL) return mi; - dbi = dbiOpen(mi->mi_rpmdb, RPMDBI_PACKAGES, 0); + dbi = dbiOpen(mi->mi_db, RPMDBI_PACKAGES, 0); /*@-branchstate@*/ if (mi->mi_h) { if (dbi && mi->mi_dbc && mi->mi_modified && mi->mi_prevoffset) { @@ -1584,18 +1602,11 @@ rpmdbMatchIterator rpmdbFreeIterator(rpmdbMatchIterator mi) mi->mi_dbc = NULL; mi->mi_set = dbiFreeIndexSet(mi->mi_set); mi->mi_keyp = _free(mi->mi_keyp); + mi->mi_db = rpmdbUnlink(mi->mi_db); mi = _free(mi); return mi; } -rpmdb rpmdbGetIteratorRpmDB(rpmdbMatchIterator mi) { - if (mi == NULL) - return NULL; - /*@-retexpose -retalias@*/ - return mi->mi_rpmdb; - /*@=retexpose =retalias@*/ -} - unsigned int rpmdbGetIteratorOffset(rpmdbMatchIterator mi) { if (mi == NULL) return 0; @@ -2023,7 +2034,7 @@ Header rpmdbNextIterator(rpmdbMatchIterator mi) if (mi == NULL) return NULL; - dbi = dbiOpen(mi->mi_rpmdb, RPMDBI_PACKAGES, 0); + dbi = dbiOpen(mi->mi_db, RPMDBI_PACKAGES, 0); if (dbi == NULL) return NULL; @@ -2163,7 +2174,7 @@ static int rpmdbGrowIterator(/*@null@*/ rpmdbMatchIterator mi, if (!(mi && keyp)) return 1; - dbi = dbiOpen(mi->mi_rpmdb, mi->mi_rpmtag, 0); + dbi = dbiOpen(mi->mi_db, mi->mi_rpmtag, 0); if (dbi == NULL) return 1; @@ -2294,7 +2305,7 @@ fprintf(stderr, "*** RMW %s %p\n", tagName(rpmtag), dbi->dbi_rmw); mi->mi_keylen = keylen; /*@-assignexpose@*/ - mi->mi_rpmdb = db; + mi->mi_db = rpmdbLink(db); /*@=assignexpose@*/ mi->mi_rpmtag = rpmtag; diff --git a/rpmdb/rpmdb.h b/rpmdb/rpmdb.h index 25875023a..d6fccff68 100644 --- a/rpmdb/rpmdb.h +++ b/rpmdb/rpmdb.h @@ -31,19 +31,6 @@ struct _dbiIndexItem { unsigned int dbNum; /*!< database index */ }; -#ifdef DYING -/** \ingroup dbi - * A single item in an index database (i.e. the "data saved"). - */ -struct _dbiIR { -/*@unused@*/ unsigned int recOffset; /*!< byte offset of header in db */ -/*@unused@*/ unsigned int fileNumber; /*!< file array index */ -}; -/*@-typeuse@*/ -typedef struct _dbiIR * DBIR_t; -/*@=typeuse@*/ -#endif /* DYING */ - /** \ingroup dbi * Items retrieved from the index database. */ @@ -299,7 +286,7 @@ struct _dbiIndex { /* queue access parameters */ unsigned int dbi_q_extentsize; -/*@kept@*/ rpmdb dbi_rpmdb; +/*@refcounted@*/ rpmdb dbi_rpmdb; rpmTag dbi_rpmtag; /*!< rpm tag used for index */ int dbi_jlen; /*!< size of join key */ @@ -341,6 +328,8 @@ struct rpmdb_s { /*@modifies *ptr @*/; int db_ndbi; /*!< No. of tag indices. */ dbiIndex * _dbi; /*!< Tag indices. */ + +/*@refs@*/ int nrefs; /*!< Reference count. */ }; /* for RPM's internal use only */ @@ -364,7 +353,7 @@ extern "C" { * Return new configured index database handle instance. * @param rpmdb rpm database */ -/*@only@*/ /*@null@*/ dbiIndex db3New(/*@keep@*/ rpmdb rpmdb, int rpmtag) +/*@only@*/ /*@null@*/ dbiIndex db3New(rpmdb rpmdb, int rpmtag) /*@globals rpmGlobalMacroContext @*/ /*@modifies rpmGlobalMacroContext @*/; |