2006-12-19 00:17:44 +01:00
|
|
|
Suspend exclusive database lock when scriptlets get called, allowing
|
|
|
|
read access in scriptlets. Only needed for DB_PRIVATE (aka global)
|
|
|
|
locking.
|
|
|
|
|
2020-10-27 11:36:01 +01:00
|
|
|
--- ./lib/backend/db3.c.orig 2020-09-30 12:25:06.516375109 +0000
|
|
|
|
+++ ./lib/backend/db3.c 2020-09-30 12:25:10.312366497 +0000
|
|
|
|
@@ -549,6 +549,46 @@ static void db3_dbSetFSync(rpmdb rdb, in
|
2014-09-16 14:03:10 +02:00
|
|
|
|
2017-01-19 16:41:55 +01:00
|
|
|
static int db3_Ctrl(rpmdb rdb, dbCtrlOp ctrl)
|
|
|
|
{
|
2006-12-19 00:17:44 +01:00
|
|
|
+ struct flock l;
|
|
|
|
+ int tries;
|
|
|
|
+ int fdno = -1;
|
2017-01-19 16:41:55 +01:00
|
|
|
+ dbiIndex dbi;
|
|
|
|
+ DB * db;
|
2006-12-19 00:17:44 +01:00
|
|
|
+
|
2017-01-19 16:41:55 +01:00
|
|
|
+ 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"));
|
|
|
|
+ }
|
2006-12-19 00:17:44 +01:00
|
|
|
+ return 1;
|
2017-01-19 16:41:55 +01:00
|
|
|
+ default:
|
|
|
|
+ break;
|
2006-12-19 00:17:44 +01:00
|
|
|
+ }
|
2017-01-19 16:41:55 +01:00
|
|
|
return 0;
|
|
|
|
}
|
2010-03-26 11:56:28 +01:00
|
|
|
|
2020-10-27 11:36:01 +01:00
|
|
|
--- ./lib/backend/dbi.h.orig 2020-09-30 12:25:06.516375109 +0000
|
|
|
|
+++ ./lib/backend/dbi.h 2020-09-30 12:25:10.312366497 +0000
|
|
|
|
@@ -18,7 +18,9 @@ typedef enum dbCtrlOp_e {
|
2017-01-19 16:41:55 +01:00
|
|
|
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;
|
2012-08-28 15:31:44 +02:00
|
|
|
|
2017-01-19 16:41:55 +01:00
|
|
|
typedef struct dbiIndex_s * dbiIndex;
|
2020-10-27 11:36:01 +01:00
|
|
|
--- ./lib/rpmdb.c.orig 2020-09-30 12:25:06.516375109 +0000
|
|
|
|
+++ ./lib/rpmdb.c 2020-09-30 12:25:10.312366497 +0000
|
|
|
|
@@ -2637,6 +2637,12 @@ int rpmdbCtrl(rpmdb db, rpmdbCtrlOp ctrl
|
2017-01-19 16:41:55 +01:00
|
|
|
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;
|
|
|
|
}
|
2020-10-27 11:36:01 +01:00
|
|
|
--- ./lib/rpmdb.h.orig 2020-05-28 10:04:25.037136686 +0000
|
|
|
|
+++ ./lib/rpmdb.h 2020-09-30 12:25:10.312366497 +0000
|
|
|
|
@@ -36,7 +36,9 @@ typedef enum rpmdbCtrlOp_e {
|
2017-01-19 16:41:55 +01:00
|
|
|
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
|
2020-10-27 11:36:01 +01:00
|
|
|
--- ./lib/transaction.c.orig 2020-09-30 07:48:01.215567727 +0000
|
|
|
|
+++ ./lib/transaction.c 2020-09-30 12:25:10.312366497 +0000
|
|
|
|
@@ -1692,6 +1692,7 @@ rpmRC runScript(rpmts ts, rpmte te, Head
|
2019-10-02 15:28:11 +02:00
|
|
|
rpmTagVal stag = rpmScriptTag(script);
|
|
|
|
FD_t sfd = NULL;
|
|
|
|
int warn_only = !(rpmScriptFlags(script) & RPMSCRIPT_FLAG_CRITICAL);
|
2017-01-19 16:41:55 +01:00
|
|
|
+ rpmdb rdb = rpmtsGetRdb(ts);
|
|
|
|
|
2020-10-27 11:36:01 +01:00
|
|
|
if (rpmChrootIn())
|
|
|
|
return RPMRC_FAIL;
|
|
|
|
@@ -1706,10 +1707,12 @@ rpmRC runScript(rpmts ts, rpmte te, Head
|
2012-08-28 15:31:44 +02:00
|
|
|
if (sfd == NULL)
|
2014-09-16 14:03:10 +02:00
|
|
|
sfd = rpmtsScriptFd(ts);
|
2010-03-26 11:56:28 +01:00
|
|
|
|
2017-01-19 16:41:55 +01:00
|
|
|
+ rpmdbCtrl(rdb, RPMDB_CTRL_SUSPEND_DBLOCK);
|
2014-09-16 14:03:10 +02:00
|
|
|
rpmswEnter(rpmtsOp(ts, RPMTS_OP_SCRIPTLETS), 0);
|
2012-08-28 15:31:44 +02:00
|
|
|
rc = rpmScriptRun(script, arg1, arg2, sfd,
|
2019-10-02 15:28:11 +02:00
|
|
|
prefixes, rpmtsPlugins(ts));
|
2014-09-16 14:03:10 +02:00
|
|
|
rpmswExit(rpmtsOp(ts, RPMTS_OP_SCRIPTLETS), 0);
|
2017-01-19 16:41:55 +01:00
|
|
|
+ rpmdbCtrl(rdb, RPMDB_CTRL_RESUME_DBLOCK);
|
2011-05-16 18:07:44 +02:00
|
|
|
|
2012-08-28 15:31:44 +02:00
|
|
|
/* Map warn-only errors to "notfound" for script stop callback */
|
|
|
|
stoprc = (rc != RPMRC_OK && warn_only) ? RPMRC_NOTFOUND : rc;
|