Red Hat Bugzilla – Bug 136305
gdbm prefers flock over fcntl when being built
Last modified: 2015-01-07 19:08:44 EST
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7)
Gecko/20040808 Lightninganemone/0.9.3 (Firefox/0.9.3 gotcha)
Description of problem:
With gdbm it is not possible to lock files via nfs, as gdbm has been
built against flock, which "the sourcecode" prefers over fcntl (in
systems.h HAVE_FLOCK is tested, if - and only then - this fails,
locking gets defined for fcntl).
As no Posix locking is available, using gdbm via NFS fails with "No
When being built, availability of fcntl should be checked first, only
if it is not available do a fallback on flock.
Version-Release number of selected component (if applicable):
Steps to Reproduce:
1. install gdbm
2. try dbm_open() on a file exported via NFS
Actual Results: The program fails with "No locks available"
Expected Results: It should have opened the database.
Created attachment 105433 [details]
Patch for systems.h which checks for fcntl first
When being rebuild with this patch, gdbm uses fcntl over flock, so that posix
locking is possible
See also bug #123415
Created attachment 108815 [details]
patch to allow gdbm to use fcntl even if flock is present
This patch adds a configure script option to gdbm so that even if flock is
detected during configuration, fcntl will be used to lock files. This will
allow the package to be rebuilt to work over NFS by adding a
--enable-force-fcntl flag on the %configure line of the gdbm spec file.
Is there any reason ever to prefer flock to fcntl if both are available?
If not, I would prefer the first approach - it's better to
automatically always make the right decision rather requiring the
person building the package to override the wrong decision via
--enable-force-fcntl. Unless you have some other reasons I haven't
thought of for taking this latter approach?
Created attachment 108884 [details]
Fixed version of patch for systems.h which checks for fcntl first
The first patch didn't apply to 1.8.0 cleanly for me. Attaching a version
which does; should be identical in functionality.