SHA256
6
0
forked from pool/rpm

- update to rpm-4.13.0

OBS-URL: https://build.opensuse.org/package/show/Base:System/rpm?expand=0&rev=378
This commit is contained in:
2017-01-19 15:41:55 +00:00
committed by Git OBS Bridge
parent ad32f0a6f5
commit e1e20a716d
34 changed files with 481 additions and 493 deletions

View File

@@ -2,151 +2,114 @@ Suspend exclusive database lock when scriptlets get called, allowing
read access in scriptlets. Only needed for DB_PRIVATE (aka global)
locking.
--- ./lib/backend/db3.c.orig 2014-08-04 12:25:29.288759808 +0000
+++ ./lib/backend/db3.c 2014-08-04 12:30:30.829430726 +0000
@@ -625,6 +625,63 @@ static int dbiFlock(dbiIndex dbi, int mo
return rc;
}
--- ./lib/backend/db3.c.orig 2017-01-19 15:31:32.166569447 +0000
+++ ./lib/backend/db3.c 2017-01-19 15:32:29.239335811 +0000
@@ -541,6 +541,46 @@ static void db3_dbSetFSync(rpmdb rdb, in
+int dbiSuspendDBLock(dbiIndex dbi, unsigned int flags)
+{
static int db3_Ctrl(rpmdb rdb, dbCtrlOp ctrl)
{
+ struct flock l;
+ int rc = 0;
+ int fdno = -1;
+ DB * db = dbi->dbi_db;
+
+ if (!dbi->dbi_lockdbfd)
+ return 0;
+ if (!(dbi->dbi_rpmdb->db_mode & (O_RDWR|O_WRONLY)))
+ return 0;
+ if (_lockdbfd == 0)
+ return 0;
+ if (!(db->fd(db, &fdno) == 0 && fdno >= 0))
+ return 1;
+ memset(&l, 0, sizeof(l));
+ l.l_whence = 0;
+ l.l_start = 0;
+ l.l_len = 0;
+ l.l_type = F_RDLCK;
+ rc = fcntl(fdno, F_SETLK, (void *)&l);
+ if (rc)
+ rpmlog(RPMLOG_WARNING, _("could not suspend database lock\n"));
+ return rc;
+}
+
+int dbiResumeDBLock(dbiIndex dbi, unsigned int flags)
+{
+ struct flock l;
+ int rc = 0;
+ int tries;
+ int fdno = -1;
+ DB * db = dbi->dbi_db;
+ dbiIndex dbi;
+ DB * db;
+
+ if (!dbi->dbi_lockdbfd)
+ return 0;
+ if (!(dbi->dbi_rpmdb->db_mode & (O_RDWR|O_WRONLY)))
+ return 0;
+ if (_lockdbfd == 0)
+ return 0;
+ if (!(db->fd(db, &fdno) == 0 && fdno >= 0))
+ switch (ctrl) {
+ case DB_CTRL_SUSPEND_DBLOCK:
+ case DB_CTRL_RESUME_DBLOCK:
+ dbi = rdb->db_pkgs; /* packages db only */
+ if (!dbi)
+ return 1;
+ if (!dbi->cfg.dbi_lockdbfd || (dbi->dbi_flags & DBI_VERIFYONLY) != 0)
+ return 0;
+ if (!(dbi->dbi_rpmdb->db_mode & (O_RDWR|O_WRONLY)))
+ return 0;
+ if (_lockdbfd == 0)
+ return 0;
+ db = dbi->dbi_db;
+ if (!(db->fd(db, &fdno) == 0 && fdno >= 0))
+ return 1;
+ for (tries = 0; tries < 2; tries++) {
+ memset(&l, 0, sizeof(l));
+ l.l_whence = 0;
+ l.l_start = 0;
+ l.l_len = 0;
+ l.l_type = ctrl == DB_CTRL_SUSPEND_DBLOCK ? F_RDLCK : F_WRLCK;
+ if (!fcntl(fdno, tries ? F_SETLKW : F_SETLK, (void *)&l))
+ return 0;
+ if (ctrl == DB_CTRL_SUSPEND_DBLOCK) {
+ rpmlog(RPMLOG_WARNING, _("could not suspend database lock\n"));
+ return 1;
+ }
+ if (tries == 0)
+ rpmlog(RPMLOG_WARNING, _("waiting to reestablish exclusive database lock\n"));
+ }
+ return 1;
+ for (tries = 0; tries < 2; tries++) {
+ memset(&l, 0, sizeof(l));
+ l.l_whence = 0;
+ l.l_start = 0;
+ l.l_len = 0;
+ l.l_type = F_WRLCK;
+ rc = fcntl(fdno, tries ? F_SETLKW : F_SETLK, (void *)&l);
+ if (!rc)
+ break;
+ if (tries == 0)
+ rpmlog(RPMLOG_WARNING, _("waiting to reestablish exclusive database lock\n"));
+ default:
+ break;
+ }
+ return rc;
+}
+
int dbiOpen(rpmdb rdb, rpmDbiTagVal rpmtag, dbiIndex * dbip, int flags)
{
const char *dbhome = rpmdbHome(rdb);
--- ./lib/backend/dbi.h.orig 2014-06-26 06:51:54.101820242 +0000
+++ ./lib/backend/dbi.h 2014-08-04 12:25:29.288759808 +0000
@@ -92,6 +92,24 @@ struct dbiIndex_s {
extern "C" {
#endif
return 0;
}
+/** \ingroup dbi
+ * Suspend the exclusive lock on the dbi
+ * @param dbi index database handle
+ * @param flags (unused)
+ * @return 0 on success
+ */
+RPM_GNUC_INTERNAL
+int dbiSuspendDBLock(dbiIndex dbi, unsigned int flags);
+
+/** \ingroup dbi
+ * Reacquire an exclusive lock on the dbi
+ * @param dbi index database handle
+ * @param flags (unused)
+ * @return 0 on success
+ */
+RPM_GNUC_INTERNAL
+int dbiResumeDBLock(dbiIndex dbi, unsigned int flags);
+
--- ./lib/backend/dbi.h.orig 2017-01-19 15:31:32.166569447 +0000
+++ ./lib/backend/dbi.h 2017-01-19 15:31:34.816559478 +0000
@@ -17,7 +17,9 @@ typedef enum dbCtrlOp_e {
DB_CTRL_UNLOCK_RO = 2,
DB_CTRL_LOCK_RW = 3,
DB_CTRL_UNLOCK_RW = 4,
- DB_CTRL_INDEXSYNC = 5
+ DB_CTRL_INDEXSYNC = 5,
+ DB_CTRL_SUSPEND_DBLOCK = 100,
+ DB_CTRL_RESUME_DBLOCK = 101
} dbCtrlOp;
RPM_GNUC_INTERNAL
/* Globally enable/disable fsync in the backend */
--- ./lib/psm.c.orig 2014-08-04 12:25:29.289759769 +0000
+++ ./lib/psm.c 2014-08-04 12:27:04.230340235 +0000
@@ -291,10 +291,12 @@ static rpmRC runScript(rpmts ts, rpmte t
typedef struct dbiIndex_s * dbiIndex;
--- ./lib/rpmdb.c.orig 2017-01-19 15:31:32.162569461 +0000
+++ ./lib/rpmdb.c 2017-01-19 15:31:34.817559474 +0000
@@ -2706,6 +2706,12 @@ int rpmdbCtrl(rpmdb db, rpmdbCtrlOp ctrl
case RPMDB_CTRL_INDEXSYNC:
dbctrl = DB_CTRL_INDEXSYNC;
break;
+ case RPMDB_CTRL_SUSPEND_DBLOCK:
+ dbctrl = DB_CTRL_SUSPEND_DBLOCK;
+ break;
+ case RPMDB_CTRL_RESUME_DBLOCK:
+ dbctrl = DB_CTRL_RESUME_DBLOCK;
+ break;
}
return dbctrl ? dbCtrl(db, dbctrl) : 1;
}
--- ./lib/rpmdb.h.orig 2016-10-03 08:08:36.582686286 +0000
+++ ./lib/rpmdb.h 2017-01-19 15:31:34.818559471 +0000
@@ -35,7 +35,9 @@ typedef enum rpmdbCtrlOp_e {
RPMDB_CTRL_UNLOCK_RO = 2,
RPMDB_CTRL_LOCK_RW = 3,
RPMDB_CTRL_UNLOCK_RW = 4,
- RPMDB_CTRL_INDEXSYNC = 5
+ RPMDB_CTRL_INDEXSYNC = 5,
+ RPMDB_CTRL_SUSPEND_DBLOCK = 100,
+ RPMDB_CTRL_RESUME_DBLOCK = 101
} rpmdbCtrlOp;
/** \ingroup rpmdb
--- ./lib/transaction.c.orig 2016-10-21 09:44:00.309962086 +0000
+++ ./lib/transaction.c 2017-01-19 15:31:34.818559471 +0000
@@ -1425,15 +1425,18 @@ rpmRC runScript(rpmts ts, rpmte te, ARGV
stag != RPMTAG_PREUN &&
stag != RPMTAG_PRETRANS &&
stag != RPMTAG_VERIFYSCRIPT);
+ rpmdb rdb = rpmtsGetRdb(ts);
sfd = rpmtsNotify(ts, te, RPMCALLBACK_SCRIPT_START, stag, 0);
if (sfd == NULL)
sfd = rpmtsScriptFd(ts);
+ rpmtsSuspendResumeDBLock(ts, 0);
+ rpmdbCtrl(rdb, RPMDB_CTRL_SUSPEND_DBLOCK);
rpmswEnter(rpmtsOp(ts, RPMTS_OP_SCRIPTLETS), 0);
rc = rpmScriptRun(script, arg1, arg2, sfd,
prefixes, warn_only, rpmtsPlugins(ts));
rpmswExit(rpmtsOp(ts, RPMTS_OP_SCRIPTLETS), 0);
+ rpmtsSuspendResumeDBLock(ts, 1);
+ rpmdbCtrl(rdb, RPMDB_CTRL_RESUME_DBLOCK);
/* Map warn-only errors to "notfound" for script stop callback */
stoprc = (rc != RPMRC_OK && warn_only) ? RPMRC_NOTFOUND : rc;
--- ./lib/rpmdb.c.orig 2014-08-04 12:25:15.106821818 +0000
+++ ./lib/rpmdb.c 2014-08-04 12:25:29.289759769 +0000
@@ -475,6 +475,12 @@ exit:
return rc;
}
+int rpmdbSuspendResumeDBLock(rpmdb db, int mode)
+{
+ if (db == NULL) return 0;
+ return dbiForeach(db->db_indexes, db->db_ndbi, mode ? dbiResumeDBLock : dbiSuspendDBLock, 0);
+}
+
static rpmdb newRpmdb(const char * root, const char * home,
int mode, int perms, int flags)
{
--- ./lib/rpmts.c.orig 2014-06-26 06:51:54.653818721 +0000
+++ ./lib/rpmts.c 2014-08-04 12:25:29.289759769 +0000
@@ -101,6 +101,11 @@ int rpmtsOpenDB(rpmts ts, int dbmode)
return rc;
}
+int rpmtsSuspendResumeDBLock(rpmts ts, int mode)
+{
+ return rpmdbSuspendResumeDBLock(ts->rdb, mode);
+}
+
int rpmtsInitDB(rpmts ts, int dbmode)
{
rpmtxn txn = rpmtxnBegin(ts, RPMTXN_WRITE);
--- ./lib/rpmts.h.orig 2014-06-26 06:51:54.655818716 +0000
+++ ./lib/rpmts.h 2014-08-04 12:25:29.290759730 +0000
@@ -441,6 +441,8 @@ rpmdb rpmtsGetRdb(rpmts ts);
void * rpmtsNotify(rpmts ts, rpmte te,
rpmCallbackType what, rpm_loff_t amount, rpm_loff_t total);
+int rpmtsSuspendResumeDBLock(rpmts ts, int mode);
+
/** \ingroup rpmts
* Return number of (ordered) transaction set elements.
* @param ts transaction set