[gdbm] Added ndbmlock patch
Karel Klíč
kklic at fedoraproject.org
Mon Jan 3 15:27:04 UTC 2011
commit 0cb413922ddc9fa2b62128d69c4f9666dea4e41d
Author: Karel Klic <kklic at redhat.com>
Date: Mon Jan 3 16:26:42 2011 +0100
Added ndbmlock patch
gdbm-1.8.3-ndbmlock.patch | 94 +++++++++++++++++++++++++++++++++++++++++++++
gdbm.spec | 18 ++++++--
2 files changed, 107 insertions(+), 5 deletions(-)
---
diff --git a/gdbm-1.8.3-ndbmlock.patch b/gdbm-1.8.3-ndbmlock.patch
new file mode 100644
index 0000000..7bc86c3
--- /dev/null
+++ b/gdbm-1.8.3-ndbmlock.patch
@@ -0,0 +1,94 @@
+diff -up gdbm-1.8.3/dbmopen.c.dbmlock gdbm-1.8.3/dbmopen.c
+--- gdbm-1.8.3/dbmopen.c.dbmlock 1999-05-19 02:16:05.000000000 +0200
++++ gdbm-1.8.3/dbmopen.c 2011-01-03 16:17:13.847173371 +0100
+@@ -35,6 +35,28 @@
+ #include "gdbmerrno.h"
+ #include "extern.h"
+
++static int
++get_env_bool(env_var, def)
++ const char *env_var;
++ int def;
++{
++ const char *v = getenv(env_var);
++ if (!v)
++ return def;
++
++ if (!strcasecmp(v, "yes") ||
++ !strcasecmp(v, "true") ||
++ !strcasecmp(v, "on"))
++ return 1;
++
++ if (!strcasecmp(v, "no") ||
++ !strcasecmp(v, "false") ||
++ !strcasecmp(v, "off"))
++ return 0;
++
++ return !!atoi(v);
++}
++
+ /* Initialize ndbm system. FILE is a pointer to the file name. In
+ standard dbm, the database is found in files called FILE.pag and
+ FILE.dir. To make gdbm compatable with dbm using the dbminit call,
+@@ -62,7 +84,7 @@ dbm_open (file, flags, mode)
+ char* dir_file; /* Used to construct "file.dir". */
+ struct stat dir_stat; /* Stat information for "file.dir". */
+ gdbm_file_info *temp_dbf; /* Temporary file pointer storage. */
+-
++ int gdbm_mode = 0;
+
+ /* Prepare the correct names of "file.pag" and "file.dir". */
+ pag_file = (char *) malloc (strlen (file)+5);
+@@ -77,26 +99,22 @@ dbm_open (file, flags, mode)
+ strcat (pag_file, ".pag");
+ strcpy (dir_file, file);
+ strcat (dir_file, ".dir");
+-
++
++ if (!get_env_bool("NDBM_LOCK", 1))
++ gdbm_mode |= GDBM_NOLOCK;
+
+ /* Call the actual routine, saving the pointer to the file information. */
+ flags &= O_RDONLY | O_RDWR | O_CREAT | O_TRUNC;
+ if (flags == O_RDONLY)
+- {
+- temp_dbf = gdbm_open (pag_file, 0, GDBM_READER, 0, NULL);
+- }
++ gdbm_mode |= GDBM_READER;
+ else if (flags == (O_RDWR | O_CREAT))
+- {
+- temp_dbf = gdbm_open (pag_file, 0, GDBM_WRCREAT, mode, NULL);
+- }
+- else if ( (flags & O_TRUNC) == O_TRUNC)
+- {
+- temp_dbf = gdbm_open (pag_file, 0, GDBM_NEWDB, mode, NULL);
+- }
++ gdbm_mode |= GDBM_WRCREAT;
++ else if ((flags & O_TRUNC) == O_TRUNC)
++ gdbm_mode |= GDBM_NEWDB;
+ else
+- {
+- temp_dbf = gdbm_open (pag_file, 0, GDBM_WRITER, 0, NULL);
+- }
++ gdbm_mode |= GDBM_WRITER;
++
++ temp_dbf = gdbm_open (pag_file, 0, gdbm_mode, mode, NULL);
+
+ /* Did we successfully open the file? */
+ if (temp_dbf == NULL)
+diff -up gdbm-1.8.3/gdbm.3.dbmlock gdbm-1.8.3/gdbm.3
+--- gdbm-1.8.3/gdbm.3.dbmlock 2011-01-03 15:59:15.684729255 +0100
++++ gdbm-1.8.3/gdbm.3 2011-01-03 16:17:49.957570637 +0100
+@@ -543,7 +543,11 @@ you must link in the \fIgdbm_compat\fR l
+ .sp
+ gcc -o prog proc.c -lgdbm -lgdbm_compat
+
+-.SH BUGS
++.SH "ENVIRONMENT VARIABLES"
++\fINDBM_LOCK\fR - When the NDBM interface is used, the database file
++is locked by default. Locking might degrade performance when used on a
++NFS share. This environment variable can be set to false to tell GDBM
++not to lock the database file.
+
+ .SH "SEE ALSO"
+ dbm, ndbm
diff --git a/gdbm.spec b/gdbm.spec
index a1bc5a9..36f0096 100644
--- a/gdbm.spec
+++ b/gdbm.spec
@@ -1,7 +1,7 @@
Summary: A GNU set of database routines which use extensible hashing
Name: gdbm
Version: 1.8.3
-Release: 6%{?dist}
+Release: 7%{?dist}
Source: http://ftp.gnu.org/gnu/gdbm/gdbm-%{version}.tar.gz
# Prevent gdbm from storing uninitialized memory content
# to database files.
@@ -17,10 +17,15 @@ Patch1: gdbm-1.8.3-fhs.patch
# Make gdbm handle read(2) returning less data than it was asked for.
# http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=274417
Patch2: gdbm-1.8.3-shortread.patch
+# dbm_open compatibility function will not lock the database if
+# NDBM_LOCK environment variable is set to false. This is useful:
+# * old applications handle locks themselves (POSIX man page says that
+# ndbm did not use to lock files, see dbm_clearerr(3p))
+# * locks are degrading performance a lot on NFS shares
+Patch3: gdbm-1.8.3-ndbmlock.patch
License: GPLv2+
URL: http://www.gnu.org/software/gdbm/
Group: System Environment/Libraries
-BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)
BuildRequires: libtool
%description
@@ -54,6 +59,7 @@ gdbm database library. You'll also need to install the gdbm package.
%patch0 -p1 -b .zeroheaders
%patch1 -p1 -b .fhs
%patch2 -p1 -b .shortread
+%patch3 -p1 -b .ndbmlock
libtoolize --force --copy
aclocal
@@ -107,10 +113,12 @@ fi
%{_infodir}/*.info*
%{_mandir}/man3/*
-%clean
-rm -rf ${RPM_BUILD_ROOT}
-
%changelog
+* Mon Jan 03 2011 Karel Klic <kklic at redhat.com> - 1.8.3-7
+- Removed BuildRoot tag
+- Removed %%clean section
+- Added ndbmlock patch (#663932)
+
* Mon Apr 12 2010 Karel Klic <kklic at redhat.com> - 1.8.3-6
- Use fcntl instead of flock for locking to make nfs safe (#477300)
More information about the scm-commits
mailing list