From 4f6281c2bb1292e646276bea5aafc08cae886ceb Mon Sep 17 00:00:00 2001 From: Panu Matilainen Date: Thu, 8 Apr 2010 16:04:37 +0300 Subject: [PATCH] Lose redundant dbi_use_env check - its always enabled when we get here, but might get turned off in the initialization process (at least for now) --- lib/backend/db3.c | 59 ++++++++++++++++++++++++++----------------------------- 1 file changed, 28 insertions(+), 31 deletions(-) diff --git a/lib/backend/db3.c b/lib/backend/db3.c index 942ccb1..9f6348e 100644 --- a/lib/backend/db3.c +++ b/lib/backend/db3.c @@ -468,48 +468,45 @@ int dbiOpen(rpmdb rpmdb, rpmTag rpmtag, dbiIndex * dbip) /* * Avoid incompatible DB_CREATE/DB_RDONLY flags on DBENV->open. */ - if (dbi->dbi_use_dbenv) { + if (access(dbhome, W_OK) == -1) { - if (access(dbhome, W_OK) == -1) { + /* dbhome is unwritable, don't attempt DB_CREATE on DB->open ... */ + oflags &= ~DB_CREATE; - /* dbhome is unwritable, don't attempt DB_CREATE on DB->open ... */ - oflags &= ~DB_CREATE; + /* ... but DBENV->open might still need DB_CREATE ... */ + if (dbi->dbi_eflags & DB_PRIVATE) { + dbi->dbi_eflags &= ~DB_JOINENV; + } else { + dbi->dbi_eflags |= DB_JOINENV; + dbi->dbi_oeflags &= ~DB_CREATE; + dbi->dbi_oeflags &= ~DB_THREAD; + /* ... but, unless DB_PRIVATE is used, skip DBENV. */ + dbi->dbi_use_dbenv = 0; + } + + /* ... DB_RDONLY maps dbhome perms across files ... */ + oflags |= DB_RDONLY; + /* ... and DB_WRITECURSOR won't be needed ... */ + dbi->dbi_oflags |= DB_RDONLY; - /* ... but DBENV->open might still need DB_CREATE ... */ + } else { /* dbhome is writable, check for persistent dbenv. */ + char * dbf = rpmGetPath(dbhome, "/__db.001", NULL); + + if (access(dbf, F_OK) == -1) { + /* ... non-existent (or unwritable) DBENV, will create ... */ + dbi->dbi_oeflags |= DB_CREATE; + dbi->dbi_eflags &= ~DB_JOINENV; + } else { + /* ... pre-existent (or bogus) DBENV, will join ... */ if (dbi->dbi_eflags & DB_PRIVATE) { dbi->dbi_eflags &= ~DB_JOINENV; } else { dbi->dbi_eflags |= DB_JOINENV; dbi->dbi_oeflags &= ~DB_CREATE; dbi->dbi_oeflags &= ~DB_THREAD; - /* ... but, unless DB_PRIVATE is used, skip DBENV. */ - dbi->dbi_use_dbenv = 0; - } - - /* ... DB_RDONLY maps dbhome perms across files ... */ - oflags |= DB_RDONLY; - /* ... and DB_WRITECURSOR won't be needed ... */ - dbi->dbi_oflags |= DB_RDONLY; - - } else { /* dbhome is writable, check for persistent dbenv. */ - char * dbf = rpmGetPath(dbhome, "/__db.001", NULL); - - if (access(dbf, F_OK) == -1) { - /* ... non-existent (or unwritable) DBENV, will create ... */ - dbi->dbi_oeflags |= DB_CREATE; - dbi->dbi_eflags &= ~DB_JOINENV; - } else { - /* ... pre-existent (or bogus) DBENV, will join ... */ - if (dbi->dbi_eflags & DB_PRIVATE) { - dbi->dbi_eflags &= ~DB_JOINENV; - } else { - dbi->dbi_eflags |= DB_JOINENV; - dbi->dbi_oeflags &= ~DB_CREATE; - dbi->dbi_oeflags &= ~DB_THREAD; - } } - dbf = _free(dbf); } + dbf = _free(dbf); } /* -- 2.7.4