[Rpm-maint] Rally: minor API requests

Maxim Udushlivy udushlivy at mail.ru
Thu Nov 15 13:51:33 UTC 2007

Panu Matilainen wrote:
> The problem with this is that we're not really interested in db mtime 
> as such, we're interested in "has the database changed since we last 
> looked". Mtime is one (fairly unreliable) way to implement it. The way 
> to go would be a more abstract rpmtsGetState() or such that returns 
> something - maybe a string hash - that clients can store and compare 
> against later on. Whether it internally uses mtime or something more 
> sophisticated is something API users don't need to know.
I also think that it is unreliable; the alternative is, as I said 
earlier, to return the number of rpmtsRun invocations in non-testing 
mode. This requires a global integer counter - something that I am not 
sure how to implement in accordance with RPM coding standards.

> The above guarantees nothing, you might just as well not lock at all.
> If you want to protect against rpmdb changing underneath you, 
> explicitly open the DB in write-mode to guarantee exclusive access to it:
> rpmts ts = rpmtsCreate()
> rpmtsOpenDB(ts, O_RDWR)
> ....and now you have an exclusive lock on the whole db until you close 
> it.
What about opening the DB in read-only mode? Will that guarantee full 
transaction isolation from DB changes that may be done in parallel by 
another process with RW access? They call it "serializable transactions" 
if I recall correctly and this isolation would be helpful for the 
unprivileged client running in test mode, for example.

I care about this because "rpmtsGetState" is useless outside of a lock 
or an isolated DB transaction.

> The rpm "key ring" is the transaction set (and the underlying db) - so 
> you should be able to do this already by opening a ts on alternative 
> database you use only for the (custom) keys. Something like (from the 
> top of my head, certainly not tested)
> rpmts ts = rpmtsCreate()
> addMacro(NULL, "_dbpath", NULL, "/path/to/custom/keydb", RMIL_DEFAULT);
> rpmtsImportPubkey(ts, pkg, pktlen);
> rpmRC rc= rpmReadPackageFile(ts, fd, path_to_rpm, &header);
> delMacro(NULL, "_dbpath");
> Nice, convenient and obvious... probably not :) But should be possible...
Interesting solution, thanks for the hint.

More information about the Rpm-maint mailing list