[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: broken database locking (at least in rpm 4.0.4)



Sigh.  -Now- it's attached.

On Fri, 2002-07-26 at 13:14, Ian Peters wrote:
> The attached test program demonstrates -- once you've opened the rpm
> database once, and then closed it, successive openings (with O_RDWR)
> will not lock the database.
> 
> To compile the attached program, run
> 
> gcc -o testcase -I/usr/include/rpm -lrpm -lrpmdb -lrpmio -lpopt
> testcase.c
> 
> To test, you'll need two terminals.  In one, as root, run:
> 
> # ./testcase
> 
> In the other, run
> 
> $ rpm -qa
> 
> You should get a locking error.
> 
> Now, ^C the testcase, and run it again, as:
> 
> # ./testcase 1
> 
> In the other, run
> 
> $ rpm -qa
> 
> It will work, which is bad, I think.  Note that instead of that being a
> -qa, it could be a -i.  Even if the other process were in the middle of
> a transaction.  Which will corrupt the rpm database.
> 
> Is this known and/or intentional?  I've worked around it by using fcntl
> to manually lock /var/lib/rpm/Packages after rpmdbOpen, but... should I
> file a bug?
> 
> Ian
> 
> -- 
> Ian Peters <itp@ximian.com>
> Ximian, Inc.
> 
> 
> 
> _______________________________________________
> Rpm-list mailing list
> Rpm-list@redhat.com
> https://listman.redhat.com/mailman/listinfo/rpm-list
-- 
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;

    rpmReadConfigFiles (NULL, NULL);

    if (argc > 1) {
        rpmdbOpen ("/", &db, O_RDWR, 0644);
        rpmdbClose (db);
   }

    rpmdbOpen ("/", &db, O_RDWR, 0644);

    sleep (10000);
}

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index] []