Skip Menu |

This queue is for tickets about the BerkeleyDB CPAN distribution.

Report information
The Basics
Id: 46313
Status: resolved
Priority: 0/
Queue: BerkeleyDB

People
Owner: Nobody in particular
Requestors: at [...] altlinux.ru
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: 0.39



Subject: set_msgfile API
Date: Sat, 23 May 2009 12:33:09 +0400
To: bug-BerkeleyDB [...] rt.cpan.org
From: Alexey Tourbin <at [...] altlinux.ru>
Hello again, Actually I'm trying to implement memoization cache with BerkeleyDB, using CDS to provide smooth multiple-reader+single-writer access, with automatic recovery for stale read locks. http://git.altlinux.org/people/at/packages/perl-qa-cache.git (I am going to release the code under GPL.) When failchk removes stale read locks, it prints a messages, for which it uses stdout by default. lock/lock_failchk.c: __db_msg(env, "Freeing read locks for locker %#lx: %s", Now, this is a problem: stdout is reserved for normal output, in a way to be usable by other programs. "Freeing read locks" message then simply spoils stdout. Currently there seems to be no easy way to suppress or redirect such messages. However, the library provides set_msgfile method: http://www.oracle.com/technology/documentation/berkeley-db/db/api_c/env_set_msgfile.html I believe it would be nice to add corresponding -MsgFile parameter, akin to -ErrFile, to BerkeleyDB.
Download (untitled)
application/pgp-signature 197b

Message body not shown because it is not plain text.

MsgFile option created. Paul
Unfortunately, -MsgFile => *STDERR option does not work (silently), but -MsgFile => \*STDERR (using reference) does work. The problem seems to be with "readHash" function - bare *STDERR glob is not SvOK, but \*STDERR glob reference is SvOK. Here is a patch. --- BerkeleyDB.xs- 2009-06-12 23:52:28 +0400 +++ BerkeleyDB.xs 2009-06-13 01:26:43 +0400 @@ -1715,8 +1715,13 @@ readHash(HV * hash, char * key) { SV ** svp; svp = hv_fetch(hash, key, strlen(key), FALSE); - if (svp && SvOK(*svp)) - return *svp ; + if (svp) { + if (SvGMAGICAL(*svp)) + mg_get(*svp); + if (SvOK(*svp)) + return *svp; + fprintf(stderr, "readHash key=%s sv=%p SvOK=0\n", key, svp); + } return NULL ; } It seems that if mg_get is invoked for bare globs like *STDERR, it gets SvOK then. The same technique is actually used before calling set_msgfile. The patch also prints debugging output - options which are not SvOK and thus silently ignored (but perhaps should not be ignored). Here is what it prints for my code. readHash key=Config sv=0xa5c2b8 SvOK=0 readHash key=Server sv=0xa5c240 SvOK=0 readHash key=SharedMemKey sv=0xa5c2e8 SvOK=0 -- Alexey Tourbin ALT Linux Team