- sparc: make dbenv per-rpmdb, not per-dbi.
authorjbj <devnull@localhost>
Sun, 6 Jan 2002 02:23:33 +0000 (02:23 +0000)
committerjbj <devnull@localhost>
Sun, 6 Jan 2002 02:23:33 +0000 (02:23 +0000)
CVS patchset: 5237
CVS date: 2002/01/06 02:23:33

CHANGES
lib/depends.c
lib/rpmte.c
lib/rpmte.h
po/rpm.pot
rpmdb/db3.c
rpmdb/header.c
rpmdb/header.h
rpmdb/header_internal.h
rpmdb/rpmdb.c
rpmdb/rpmdb.h

diff --git a/CHANGES b/CHANGES
index 48897d3..466d88e 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -85,6 +85,7 @@
        - fix: typo in find-requires.
        - tru64 compiler message cleanup.
        - add buildarch lines for hppa (#57728).
+       - sparc: make dbenv per-rpmdb, not per-dbi.
 
 4.0.2 -> 4.0.3:
        - update per-interpreter dependency scripts, add sql/tcl (#20295).
index 2ee2ab2..79cf7fe 100644 (file)
@@ -1698,7 +1698,7 @@ assert(newOrderCount == ts->orderCount);
     ts->orderAlloced = ts->orderCount;
     orderList = _free(orderList);
 
-#ifdef HACK
+#if defined(__LCLINT__)                /* XXX HACK rpmsort needs for graphviz */
     /* Clean up after dependency checks */
     pi = teInitIterator(ts);
     while ((p = teNextIterator(pi)) != NULL) {
index 9ebfe7f..de23243 100644 (file)
@@ -267,10 +267,14 @@ transactionElement teGetParent(transactionElement te)
 transactionElement teSetParent(transactionElement te, transactionElement pte)
 {
     transactionElement opte = NULL;
+    /*@-branchstate@*/
     if (te != NULL) {
        opte = te->parent;
+       /*@-assignexpose -temptrans@*/
        te->parent = pte;
+       /*@=assignexpose =temptrans@*/
     }
+    /*@=branchstate@*/
     return opte;
 }
 
index ecd4500..16b4dc4 100644 (file)
@@ -290,6 +290,7 @@ int teSetTree(transactionElement te, int ntree)
  * @param te           transaction element
  * @return             parent transaction element
  */
+/*@observer@*/ /*@unused@*/
 transactionElement teGetParent(transactionElement te)
        /*@*/;
 
@@ -313,10 +314,10 @@ int teGetDegree(transactionElement te)
 /**
  * Set number of children of transaction element.
  * @param te           transaction element
- * @param ntree                new number of children
+ * @param ndegree      new number of children
  * @return             previous number of children
  */
-int teSetDegree(transactionElement te, int ntree)
+int teSetDegree(transactionElement te, int ndegree)
        /*@modifies te @*/;
 
 /**
@@ -345,6 +346,7 @@ void teNewTSI(transactionElement te)
  * Destroy dependency set info of transaction element.
  * @param te           transaction element
  */
+/*@unused@*/
 void teCleanDS(transactionElement te)
        /*@modifies te @*/;
 
index 52d3c91..88bdf5d 100644 (file)
@@ -6,7 +6,7 @@
 msgid ""
 msgstr ""
 "Project-Id-Version: PACKAGE VERSION\n"
-"POT-Creation-Date: 2002-01-04 21:38-0500\n"
+"POT-Creation-Date: 2002-01-05 21:18-0500\n"
 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
 "Language-Team: LANGUAGE <LL@li.org>\n"
@@ -883,7 +883,7 @@ msgstr ""
 
 #: build/parseChangelog.c:155
 #, c-format
-msgid "%%changelog not in decending chronological order\n"
+msgid "%%changelog not in descending chronological order\n"
 msgstr ""
 
 #: build/parseChangelog.c:163 build/parseChangelog.c:174
@@ -2783,11 +2783,11 @@ msgstr ""
 msgid "cannot get %s lock on database\n"
 msgstr ""
 
-#: rpmdb/db1.c:573 rpmdb/db3.c:1213
+#: rpmdb/db1.c:573 rpmdb/db3.c:1230
 msgid "exclusive"
 msgstr ""
 
-#: rpmdb/db1.c:573 rpmdb/db3.c:1213
+#: rpmdb/db1.c:573 rpmdb/db3.c:1230
 msgid "shared"
 msgstr ""
 
@@ -2811,22 +2811,22 @@ msgstr ""
 msgid "closed   db index       %s/%s\n"
 msgstr ""
 
-#: rpmdb/db3.c:777
+#: rpmdb/db3.c:782
 #, c-format
 msgid "verified db index       %s/%s\n"
 msgstr ""
 
-#: rpmdb/db3.c:990
+#: rpmdb/db3.c:1007
 #, c-format
 msgid "opening  db index       %s/%s %s mode=0x%x\n"
 msgstr ""
 
-#: rpmdb/db3.c:1211
+#: rpmdb/db3.c:1228
 #, c-format
 msgid "cannot get %s lock on %s/%s\n"
 msgstr ""
 
-#: rpmdb/db3.c:1217
+#: rpmdb/db3.c:1234
 #, c-format
 msgid "locked   db index       %s/%s\n"
 msgstr ""
@@ -2993,121 +2993,121 @@ msgstr ""
 msgid "no dbpath has been set\n"
 msgstr ""
 
-#: rpmdb/rpmdb.c:1050
+#: rpmdb/rpmdb.c:1054
 msgid ""
 "old format database is present; use --rebuilddb to generate a new format "
 "database\n"
 msgstr ""
 
 #. error
-#: rpmdb/rpmdb.c:1315
+#: rpmdb/rpmdb.c:1319
 #, c-format
 msgid "error(%d) counting packages\n"
 msgstr ""
 
-#: rpmdb/rpmdb.c:2092 rpmdb/rpmdb.c:3345
+#: rpmdb/rpmdb.c:2096 rpmdb/rpmdb.c:3349
 #, c-format
 msgid "record number %u in database is bad -- skipping.\n"
 msgstr ""
 
-#: rpmdb/rpmdb.c:2145
+#: rpmdb/rpmdb.c:2149
 #, c-format
 msgid "rpmdb: damaged header instance #%u retrieved, skipping.\n"
 msgstr ""
 
-#: rpmdb/rpmdb.c:2415
+#: rpmdb/rpmdb.c:2419
 #, c-format
 msgid "%s: cannot read header at 0x%x\n"
 msgstr ""
 
-#: rpmdb/rpmdb.c:2487
+#: rpmdb/rpmdb.c:2491
 #, c-format
 msgid "removing \"%s\" from %s index.\n"
 msgstr ""
 
-#: rpmdb/rpmdb.c:2496
+#: rpmdb/rpmdb.c:2500
 #, c-format
 msgid "removing %d entries from %s index.\n"
 msgstr ""
 
-#: rpmdb/rpmdb.c:2697
+#: rpmdb/rpmdb.c:2701
 #, c-format
 msgid "error(%d) allocating new package instance\n"
 msgstr ""
 
-#: rpmdb/rpmdb.c:2778
+#: rpmdb/rpmdb.c:2782
 #, c-format
 msgid "adding \"%s\" to %s index.\n"
 msgstr ""
 
-#: rpmdb/rpmdb.c:2789
+#: rpmdb/rpmdb.c:2793
 #, c-format
 msgid "adding %d entries to %s index.\n"
 msgstr ""
 
-#: rpmdb/rpmdb.c:3231
+#: rpmdb/rpmdb.c:3235
 #, c-format
 msgid "removing %s after successful db3 rebuild.\n"
 msgstr ""
 
-#: rpmdb/rpmdb.c:3264
+#: rpmdb/rpmdb.c:3268
 msgid "no dbpath has been set"
 msgstr ""
 
-#: rpmdb/rpmdb.c:3291
+#: rpmdb/rpmdb.c:3295
 #, c-format
 msgid "rebuilding database %s into %s\n"
 msgstr ""
 
-#: rpmdb/rpmdb.c:3295
+#: rpmdb/rpmdb.c:3299
 #, c-format
 msgid "temporary database %s already exists\n"
 msgstr ""
 
-#: rpmdb/rpmdb.c:3301
+#: rpmdb/rpmdb.c:3305
 #, c-format
 msgid "creating directory %s\n"
 msgstr ""
 
-#: rpmdb/rpmdb.c:3303
+#: rpmdb/rpmdb.c:3307
 #, c-format
 msgid "creating directory %s: %s\n"
 msgstr ""
 
-#: rpmdb/rpmdb.c:3310
+#: rpmdb/rpmdb.c:3314
 #, c-format
 msgid "opening old database with dbapi %d\n"
 msgstr ""
 
-#: rpmdb/rpmdb.c:3321
+#: rpmdb/rpmdb.c:3325
 #, c-format
 msgid "opening new database with dbapi %d\n"
 msgstr ""
 
-#: rpmdb/rpmdb.c:3385
+#: rpmdb/rpmdb.c:3389
 #, c-format
 msgid "cannot add record originally at %u\n"
 msgstr ""
 
-#: rpmdb/rpmdb.c:3403
+#: rpmdb/rpmdb.c:3407
 msgid "failed to rebuild database: original database remains in place\n"
 msgstr ""
 
-#: rpmdb/rpmdb.c:3411
+#: rpmdb/rpmdb.c:3415
 msgid "failed to replace old database with new database!\n"
 msgstr ""
 
-#: rpmdb/rpmdb.c:3413
+#: rpmdb/rpmdb.c:3417
 #, c-format
 msgid "replace files in %s with files from %s to recover"
 msgstr ""
 
-#: rpmdb/rpmdb.c:3423
+#: rpmdb/rpmdb.c:3427
 #, c-format
 msgid "removing directory %s\n"
 msgstr ""
 
-#: rpmdb/rpmdb.c:3425
+#: rpmdb/rpmdb.c:3429
 #, c-format
 msgid "failed to remove directory %s: %s\n"
 msgstr ""
index f35a16d..07068af 100644 (file)
@@ -717,9 +717,14 @@ static int db3close(/*@only@*/ dbiIndex dbi, /*@unused@*/ unsigned int flags)
     dbi->dbi_dbinfo = _free(dbi->dbi_dbinfo);
 
     if (dbi->dbi_use_dbenv) {
-       /*@-nullstate@*/
-       xx = db_fini(dbi, (dbhome ? dbhome : ""), dbfile, dbsubfile);
-       /*@=nullstate@*/
+       if (dbi->dbi_dbenv == rpmdb->db_dbenv && rpmdb->db_opens == 1) {
+           /*@-nullstate@*/
+           xx = db_fini(dbi, (dbhome ? dbhome : ""), dbfile, dbsubfile);
+           /*@=nullstate@*/
+           rpmdb->db_dbenv = NULL;
+       }
+       dbi->dbi_dbenv = NULL;
+       rpmdb->db_opens--;
     }
 
     if (dbi->dbi_verify_on_close && !dbi->dbi_temporary) {
@@ -984,8 +989,20 @@ static int db3open(rpmdb rpmdb, int rpmtag, dbiIndex * dbip)
 
     dbi->dbi_dbinfo = NULL;
 
-    if (dbi->dbi_use_dbenv)
-       rc = db_init(dbi, dbhome, dbfile, dbsubfile, &dbenv);
+    if (dbi->dbi_use_dbenv) {
+       /*@-mods@*/
+       if (rpmdb->db_dbenv == NULL) {
+           rc = db_init(dbi, dbhome, dbfile, dbsubfile, &dbenv);
+           if (rc == 0) {
+               rpmdb->db_dbenv = dbenv;
+               rpmdb->db_opens = 1;
+           }
+       } else {
+           dbenv = rpmdb->db_dbenv;
+           rpmdb->db_opens++;
+       }
+       /*@=mods@*/
+    }
 
     rpmMessage(RPMMESS_DEBUG, _("opening  db index       %s/%s %s mode=0x%x\n"),
                dbhome, (dbfile ? dbfile : tagName(dbi->dbi_rpmtag)),
@@ -1223,7 +1240,9 @@ static int db3open(rpmdb rpmdb, int rpmtag, dbiIndex * dbip)
     }
 
     dbi->dbi_db = db;
+    /*@-kepttrans@*/
     dbi->dbi_dbenv = dbenv;
+    /*@=kepttrans@*/
 
     if (rc == 0 && dbi->dbi_db != NULL && dbip != NULL) {
        dbi->dbi_vec = &db3vec;
@@ -1235,9 +1254,9 @@ static int db3open(rpmdb rpmdb, int rpmtag, dbiIndex * dbip)
 
     urlfn = _free(urlfn);
 
-    /*@-nullstate@*/
+    /*@-nullstate -compmempass@*/
     return rc;
-    /*@=nullstate@*/
+    /*@=nullstate =compmempass@*/
 }
 
 /** \ingroup db3
index aaee8e4..f211378 100644 (file)
@@ -118,7 +118,7 @@ fprintf(stderr, "--> h  %p ++ %d %s at %s:%u\n", h, (h != NULL ? h->nrefs : 0),
  * @param h            header
  * @return             NULL always
  */
-HSTATIC
+HSTATIC /*@null@*/
 Header XheaderUnlink(/*@killref@*/ /*@null@*/ Header h,
                /*@null@*/ const char * msg, const char * fn, unsigned ln)
        /*@modifies h @*/
@@ -2889,7 +2889,7 @@ freeExtensionCache(const headerSprintfExtension extensions,
  * @retval errmsg      error message (if any)
  * @return             formatted output string (malloc'ed)
  */
-HSTATIC /*@only@*/
+HSTATIC /*@only@*/ /*@null@*/
 char * headerSprintf(Header h, const char * fmt,
                     const struct headerTagTableEntry_s * tbltags,
                     const struct headerSprintfExtension_s * extensions,
index 2323dd1..65b25d3 100644 (file)
@@ -682,7 +682,9 @@ struct HV_s {
     HDRfreeiter        hdrfreeiter;
     HDRinititer        hdrinititer;
     HDRnextiter        hdrnextiter;
+/*@null@*/
     void *     hdrvecs;
+/*@null@*/
     void *     hdrdata;
     int                hdrversion;
 };
index c6878f8..edb63b9 100644 (file)
@@ -53,6 +53,7 @@ struct indexEntry {
  */
 struct headerToken {
 /*@unused@*/ struct HV_s hv;   /*!< Header public methods. */
+/*@only@*/ /*@null@*/
     void * blob;               /*!< Header region blob. */
 /*@owned@*/ indexEntry index;  /*!< Array of tags. */
     int indexUsed;             /*!< Current size of tag array. */
index a6d99d4..59b5f8e 100644 (file)
@@ -934,41 +934,16 @@ static int openDatabase(/*@null@*/ const char * prefix,
     rpmdb db;
     int rc, xx;
     unsigned int gflags = 0;   /* dbiGet() flags */
-    static int _initialized = 0;
+    static int _tags_initialized = 0;
+    static int _dbenv_removed = 0;
     int justCheck = flags & RPMDB_FLAG_JUSTCHECK;
     int minimal = flags & RPMDB_FLAG_MINIMAL;
 
-    if (!_initialized || dbiTagsMax == 0) {
-
-#if 1
-       static int _enable_cdb = -1;
-
-       /* XXX hack in suoport for CDB, otherwise nuke the state. */
-       /*@-mods@*/
-       if (_enable_cdb < 0)
-           _enable_cdb = rpmExpandNumeric("%{?__dbi_cdb:1}");
-       /*@=mods@*/
-
-       if (!_enable_cdb) {
-           char * filename;
-           int i;
-
-           i = sizeof("//__db.000");
-           if (prefix) i += strlen(prefix);
-           if (dbpath) i += strlen(dbpath);
-           filename = alloca(i);
-           for (i = 0; i < 16; i++) {
-               sprintf(filename, "%s/%s/__db.%03d",
-                       (prefix ? prefix : ""), (dbpath ? dbpath : ""),  i);
-               (void) rpmCleanPath(filename);
-               xx = unlink(filename);
-           }
-       }
-#endif
+    if (!_tags_initialized || dbiTagsMax == 0) {
        /*@-mods@*/
        dbiTagsInit();
        /*@=mods@*/
-       _initialized++;
+       _tags_initialized++;
     }
 
     /* Insure that _dbapi has one of -1, 1, 2, or 3 */
@@ -987,6 +962,35 @@ static int openDatabase(/*@null@*/ const char * prefix,
     /*@=mods@*/
     if (db == NULL)
        return 1;
+
+    if (!_dbenv_removed) {
+       static int _enable_cdb = -1;
+
+       /* XXX hack in suoport for CDB, otherwise nuke the state. */
+       /*@-mods@*/
+       if (_enable_cdb < 0)
+           _enable_cdb = rpmExpandNumeric("%{?__dbi_cdb:1}");
+       /*@=mods@*/
+
+       if (!_enable_cdb) {
+           char * fn;
+           int i;
+
+           i = sizeof("//__db.000");
+           if (db->db_root) i += strlen(db->db_root);
+           if (db->db_home) i += strlen(db->db_home);
+           fn = alloca(i);
+           for (i = 0; i < 16; i++) {
+               sprintf(fn, "%s/%s/__db.%03d",
+                       (db->db_root ? db->db_root : ""),
+                       (db->db_home ? db->db_home : ""),  i);
+               (void) rpmCleanPath(fn);
+               (void) unlink(fn);
+           }
+       }
+       _dbenv_removed++;
+    }
+
     db->db_api = _dbapi;
 
     {  int dbix;
index 5b88438..10cb088 100644 (file)
@@ -327,6 +327,8 @@ struct rpmdb_s {
        /*@*/;
     void (*db_free) (/*@only@*/ void * ptr)
        /*@modifies *ptr @*/;
+    int                db_opens;
+/*@only@*//*@null@*/ void * db_dbenv;  /*!< Berkeley DB_ENV handle */
     int                db_ndbi;        /*!< No. of tag indices. */
     dbiIndex * _dbi;           /*!< Tag indices. */