[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]
database locking woes part 2
- From: Ian Peters <itp ximian com>
- To: rpm-list redhat com
- Subject: database locking woes part 2
- Date: 29 Jul 2002 16:41:43 -0400
I've come up with another testcase to better demonstrate what I feel to
be the actual problem with database locking, at least in RPM 4.0.4.
I'll try these programs with RPM 4.1 as soon as I can -- but this
problem is affecting me now, with deployed versions of RPM,
unfortunately.
The programs are called lock-maker and lock-breaker. lock-maker opens
the rpm database O_RDWR, which should hold an exclusive lock, and then
sleeps for a good long time to hold that lock open. lock-breaker
attempts to open the rpm database O_RDONLY. If it fails, it immediately
tries to open the database again (also O_RDONLY).
To run the test, compile both programs:
gcc -o lock-maker lock-maker.c -I/usr/include/rpm -lrpm -lrpmio -lrpmdb -lpopt
gcc -o lock-breaker lock-breaker.c -I/usr/include/rpm -lrpm -lrpmio -lrpmdb -lpopt
Now, in one terminal, as root, run lock-maker.
# ./lock-maker
Opened rpm database O_RDWR
Now, to verify that the lock is held, run rpm -qa -- both as root and as
non-root, just for verification. (The multiple runs will explain
themselves in a second.)
$ rpm -qa
error: cannot get shared lock on /var/lib/rpm/Packages
error: cannot open Packages index using db3 - Operation not permitted (1)
$ rpm -qa
error: cannot get shared lock on /var/lib/rpm/Packages
error: cannot open Packages index using db3 - Operation not permitted (1)
$ su
Password:
# rpm -qa
error: cannot get shared lock on /var/lib/rpm/Packages
error: cannot open Packages index using db3 - Operation not permitted (1)
# rpm -qa
error: cannot get shared lock on /var/lib/rpm/Packages
error: cannot open Packages index using db3 - Operation not permitted (1)
Now, run lock-breaker:
$ ./lock-breaker
error: cannot get shared lock on /var/lib/rpm/Packages
error: cannot open Packages index using db3 - Operation not permitted (1)
Failed to open rpm database O_RDONLY
error: cannot get shared lock on /var/lib/rpm/Packages
Failed to open rpm database O_RDONLY
$ su
Password:
# ./lock-breaker
error: cannot get shared lock on /var/lib/rpm/Packages
error: cannot open Packages index using db3 - Operation not permitted (1)
Failed to open rpm database O_RDONLY
Opened rpm database O_RDONLY
That second open really should not have succeeded.
Am I totally off-base, or missing something obvious here?
Ian
--
Ian Peters <itp@ximian.com>
Ximian, Inc.
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <rpm/rpmlib.h>
int
main (int argc, char **argv)
{
rpmdb db;
int rc;
rpmReadConfigFiles (NULL, NULL);
if ((rc = rpmdbOpen ("/", &db, O_RDONLY, 0644))) {
printf ("Failed to open rpm database O_RDONLY\n");
if ((rc = rpmdbOpen ("/", &db, O_RDONLY, 0644)))
printf ("Failed to open rpm database O_RDONLY\n");
else
printf ("Opened rpm database O_RDONLY\n");
} else
printf ("Opened rpm database O_RDONLY\n");
}
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <rpm/rpmlib.h>
int
main (int argc, char **argv)
{
rpmdb db;
int rc;
rpmReadConfigFiles (NULL, NULL);
if ((rc = rpmdbOpen ("/", &db, O_RDWR, 0645)))
printf ("Failed to open rpm database O_RDWR\n");
else
printf ("Opened rpm database O_RDWR\n");
sleep (10000);
}
[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]
[]