summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbiao716.wang <biao716.wang@samsung.com>2021-01-25 17:58:12 +0900
committerbiao716.wang <biao716.wang@samsung.com>2021-01-25 17:58:12 +0900
commit3a32c23a16ded3a5efc395235f28bfd9df2f0f29 (patch)
tree630e482c639786fed22c9a1b382f1102d366b234
parent38cdf5113127519d0a13b7789166ed57c0e821a5 (diff)
downloadrpm-3a32c23a16ded3a5efc395235f28bfd9df2f0f29.tar.gz
rpm-3a32c23a16ded3a5efc395235f28bfd9df2f0f29.tar.bz2
rpm-3a32c23a16ded3a5efc395235f28bfd9df2f0f29.zip
Remove timeout logic to wait for shared lock in db3.c filesubmit/tizen_base/20210222.062837
Change-Id: Ia689033d2c145335fcc0038651a6b6ee66dad518 Signed-off-by: biao716.wang <biao716.wang@samsung.com>
-rw-r--r--lib/backend/db3.c55
1 files changed, 17 insertions, 38 deletions
diff --git a/lib/backend/db3.c b/lib/backend/db3.c
index 7a86d3525..771018467 100644
--- a/lib/backend/db3.c
+++ b/lib/backend/db3.c
@@ -410,7 +410,7 @@ static int db_init(rpmdb rdb, const char * dbhome)
int rdonly = ((rdb->db_mode & O_ACCMODE) == O_RDONLY);
struct dbConfig_s * cfg = &rdb->cfg;
/* This is our setup, thou shall not have other setups before us */
- uint32_t eflags = (DB_CREATE|DB_INIT_MPOOL|DB_INIT_CDB);
+ uint32_t eflags = (DB_CREATE|DB_INIT_MPOOL|DB_INIT_CDB|DB_PRIVATE);
if (rdb->db_dbenv != NULL) {
rdb->db_opens++;
@@ -734,8 +734,6 @@ static int db3_dbiVerify(dbiIndex dbi, unsigned int flags)
return rc;
}
-static int _lockdbfd = 0;
-
static int db3_dbiClose(dbiIndex dbi, unsigned int flags)
{
rpmdb rdb = dbi->dbi_rpmdb;
@@ -753,8 +751,6 @@ static int db3_dbiClose(dbiIndex dbi, unsigned int flags)
rpmlog(RPMLOG_DEBUG, "closed db index %s/%s\n",
dbhome, dbi->dbi_file);
- if (dbi->cfg.dbi_lockdbfd && _lockdbfd)
- _lockdbfd--;
}
db_fini(rdb, dbhome ? dbhome : "");
@@ -794,7 +790,6 @@ static int dbiFlock(dbiIndex dbi, int mode)
rc = 1;
} else {
const char *dbhome = rpmdbHome(dbi->dbi_rpmdb);
- int tries;
struct flock l;
memset(&l, 0, sizeof(l));
l.l_whence = 0;
@@ -804,38 +799,20 @@ static int dbiFlock(dbiIndex dbi, int mode)
? F_RDLCK : F_WRLCK;
l.l_pid = 0;
- for (tries = 0; ; tries++) {
- rc = fcntl(fdno, F_SETLK, (void *) &l);
- if (rc) {
- uint32_t eflags = db_envflags(db);
- /* Warning iff using non-private CDB locking. */
- rc = (((eflags & DB_INIT_CDB) && !(eflags & DB_PRIVATE)) ? 0 : 1);
- if (errno == EAGAIN && rc) {
- struct timespec ts;
- if (tries == 0)
- rpmlog(RPMLOG_WARNING,
- _("waiting for %s lock on %s/%s\n"),
- ((mode & O_ACCMODE) == O_RDONLY)
- ? _("shared") : _("exclusive"),
- dbhome, dbi->dbi_file);
- ts.tv_sec = (time_t)0;
- ts.tv_nsec = 100000000; /* .1 seconds */
- if (tries < 10*60*3) { /* 3 minutes */
- nanosleep(&ts, (struct timespec *)0);
- continue;
- }
- }
- rpmlog( (rc ? RPMLOG_ERR : RPMLOG_WARNING),
- _("cannot get %s lock on %s/%s\n"),
- ((mode & O_ACCMODE) == O_RDONLY)
- ? _("shared") : _("exclusive"),
- dbhome, dbi->dbi_file);
- } else {
- rpmlog(RPMLOG_DEBUG,
- "locked db index %s/%s\n",
- dbhome, dbi->dbi_file);
- }
- break;
+ rc = fcntl(fdno, F_SETLK, (void *) &l);
+ if (rc) {
+ uint32_t eflags = db_envflags(db);
+ /* Warning iff using non-private CDB locking. */
+ rc = (((eflags & DB_INIT_CDB) && !(eflags & DB_PRIVATE)) ? 0 : 1);
+ rpmlog( (rc ? RPMLOG_ERR : RPMLOG_WARNING),
+ _("cannot get %s lock on %s/%s\n"),
+ ((mode & O_ACCMODE) == O_RDONLY)
+ ? _("shared") : _("exclusive"),
+ dbhome, dbi->dbi_file);
+ } else {
+ rpmlog(RPMLOG_DEBUG,
+ "locked db index %s/%s\n",
+ dbhome, dbi->dbi_file);
}
}
return rc;
@@ -852,6 +829,7 @@ static int db3_dbiOpen(rpmdb rdb, rpmDbiTagVal rpmtag, dbiIndex * dbip, int flag
DB * db = NULL;
DBTYPE dbtype = DB_UNKNOWN;
uint32_t oflags;
+ static int _lockdbfd = 0;
if (dbip)
*dbip = NULL;
@@ -944,6 +922,7 @@ static int db3_dbiOpen(rpmdb rdb, rpmDbiTagVal rpmtag, dbiIndex * dbip, int flag
return rc;
}
+
/**
* Convert retrieved data to index set.
* @param dbi index database handle