Open maps with no blocking for reading

This commit is contained in:
Honza Horák 2013-01-28 14:06:48 +01:00
parent a6607b423c
commit b5e1c16543
2 changed files with 29 additions and 12 deletions

View File

@ -1,6 +1,6 @@
diff -up ypserv-2.29/lib/yp_db.c.dbopen ypserv-2.29/lib/yp_db.c
--- ypserv-2.29/lib/yp_db.c.dbopen 2012-05-30 13:28:49.000000000 +0200
+++ ypserv-2.29/lib/yp_db.c 2013-01-23 16:11:32.116224180 +0100
+++ ypserv-2.29/lib/yp_db.c 2013-01-28 12:07:28.555350199 +0100
@@ -173,11 +173,14 @@ _db_open (const char *domain, const char
sprintf (buf, "%s/%s", domain, map);
@ -21,7 +21,7 @@ diff -up ypserv-2.29/lib/yp_db.c.dbopen ypserv-2.29/lib/yp_db.c
}
diff -up ypserv-2.29/makedbm/makedbm.c.dbopen ypserv-2.29/makedbm/makedbm.c
--- ypserv-2.29/makedbm/makedbm.c.dbopen 2012-05-30 13:28:49.000000000 +0200
+++ ypserv-2.29/makedbm/makedbm.c 2013-01-23 16:13:32.896215921 +0100
+++ ypserv-2.29/makedbm/makedbm.c 2013-01-28 12:23:50.243283071 +0100
@@ -490,6 +490,9 @@ create_file (char *fileName, char *dbmNa
#endif
#else
@ -32,6 +32,15 @@ diff -up ypserv-2.29/makedbm/makedbm.c.dbopen ypserv-2.29/makedbm/makedbm.c
rename (filename, dbmName);
#endif
free (filename);
@@ -508,7 +511,7 @@ dump_file (char *dbmName)
dbm = dbm_open (dbmName, O_RDONLY, 0600);
#elif defined(HAVE_LIBTC)
dbm = tcbdbnew();
- if (!tcbdbopen (dbm, dbmName, BDBOREADER))
+ if (!tcbdbopen (dbm, dbmName, BDBOREADER | BDBONOLCK))
{
tcbdbdel(dbm);
dbm = NULL;
@@ -517,6 +520,7 @@ dump_file (char *dbmName)
if (dbm == NULL)
{
@ -42,7 +51,7 @@ diff -up ypserv-2.29/makedbm/makedbm.c.dbopen ypserv-2.29/makedbm/makedbm.c
#if defined(HAVE_COMPAT_LIBGDBM)
diff -up ypserv-2.29/yphelper/yphelper.c.dbopen ypserv-2.29/yphelper/yphelper.c
--- ypserv-2.29/yphelper/yphelper.c.dbopen 2012-05-30 13:28:50.000000000 +0200
+++ ypserv-2.29/yphelper/yphelper.c 2013-01-23 16:11:32.117224180 +0100
+++ ypserv-2.29/yphelper/yphelper.c 2013-01-28 12:24:14.378281420 +0100
@@ -507,10 +507,10 @@ get_dbm_entry (char *key, char *map, cha
#if defined(HAVE_COMPAT_LIBGDBM)
dbm = gdbm_open (mappath, 0, GDBM_READER, 0600, NULL);
@ -52,7 +61,7 @@ diff -up ypserv-2.29/yphelper/yphelper.c.dbopen ypserv-2.29/yphelper/yphelper.c
#elif defined(HAVE_LIBTC)
dbm = tcbdbnew();
- if (!tcbdbopen(dbm, mappath, BDBOWRITER | BDBOCREAT))
+ if (!tcbdbopen(dbm, mappath, BDBOREADER))
+ if (!tcbdbopen(dbm, mappath, BDBOREADER | BDBONOLCK))
{
tcbdbdel(dbm);
dbm = NULL;
@ -66,7 +75,7 @@ diff -up ypserv-2.29/yphelper/yphelper.c.dbopen ypserv-2.29/yphelper/yphelper.c
diff -up ypserv-2.29/yppush/yppush.c.dbopen ypserv-2.29/yppush/yppush.c
--- ypserv-2.29/yppush/yppush.c.dbopen 2012-08-30 09:53:16.000000000 +0200
+++ ypserv-2.29/yppush/yppush.c 2013-01-23 16:11:32.117224180 +0100
+++ ypserv-2.29/yppush/yppush.c 2013-01-28 12:23:59.161282461 +0100
@@ -290,10 +290,10 @@ get_dbm_entry (char *key)
#if defined(HAVE_COMPAT_LIBGDBM)
dbm = gdbm_open (mappath, 0, GDBM_READER, 0600, NULL);
@ -76,7 +85,7 @@ diff -up ypserv-2.29/yppush/yppush.c.dbopen ypserv-2.29/yppush/yppush.c
#elif defined(HAVE_LIBTC)
dbm = tcbdbnew();
- if (!tcbdbopen(dbm, mappath, BDBOWRITER | BDBOCREAT))
+ if (!tcbdbopen(dbm, mappath, BDBOREADER))
+ if (!tcbdbopen(dbm, mappath, BDBOREADER | BDBONOLCK))
{
tcbdbdel(dbm);
dbm = NULL;
@ -89,8 +98,8 @@ diff -up ypserv-2.29/yppush/yppush.c.dbopen ypserv-2.29/yppush/yppush.c
}
diff -up ypserv-2.29/ypxfr/ypxfr.c.dbopen ypserv-2.29/ypxfr/ypxfr.c
--- ypserv-2.29/ypxfr/ypxfr.c.dbopen 2013-01-23 16:11:32.068224183 +0100
+++ ypserv-2.29/ypxfr/ypxfr.c 2013-01-23 16:14:05.895213665 +0100
--- ypserv-2.29/ypxfr/ypxfr.c.dbopen 2013-01-28 12:07:28.475350204 +0100
+++ ypserv-2.29/ypxfr/ypxfr.c 2013-01-28 12:24:07.195281912 +0100
@@ -557,10 +557,10 @@ ypxfr (char *map, char *source_host, cha
#if defined(HAVE_COMPAT_LIBGDBM)
dbm = gdbm_open (dbName_orig, 0, GDBM_READER, 0600, NULL);
@ -100,7 +109,7 @@ diff -up ypserv-2.29/ypxfr/ypxfr.c.dbopen ypserv-2.29/ypxfr/ypxfr.c
#elif defined(HAVE_LIBTC)
dbm = tcbdbnew ();
- if (!tcbdbopen (dbm, dbName_orig, BDBOWRITER | BDBOCREAT))
+ if (!tcbdbopen (dbm, dbName_orig, BDBOREADER))
+ if (!tcbdbopen (dbm, dbName_orig, BDBOREADER | BDBONOLCK))
{
tcbdbdel (dbm);
dbm = NULL;

View File

@ -4,7 +4,7 @@ Summary: The NIS (Network Information Service) server
Url: http://www.linux-nis.org/nis/ypserv/index.html
Name: ypserv
Version: 2.29
Release: 6%{?dist}
Release: 7%{?dist}
License: GPLv2
Group: System Environment/Daemons
Source0: http://www.linux-nis.org/download/ypserv/ypserv-%{version}.tar.bz2
@ -184,6 +184,8 @@ fi
fi
%endif
%if 0%fedora>=18
# After switching from gdbm to Tokyo Cabinet we need to rebuild maps
# during update, but without pushing to slave servers
# In case domainname is not set, but it is defined in
@ -212,11 +214,12 @@ if [ $1 == 2 ] ; then
if [ "$newdomain" != "(none)" -a "x$newdomain" != "x" ]; then
pushd "/var/yp/$newdomain">/dev/null
echo "" > %rebuild_maps_script
chmod 0600 %rebuild_maps_script
# loop through maps
for map in * ; do
# this server is a master for this map
if %{_libdir}/yp/yphelper -i "$map" ; then
echo "mv `pwd`/$map `pwd`/${map}.bak" >> %rebuild_maps_script
if %{_libdir}/yp/yphelper -i "$map" >/dev/null 2>&1 ; then
echo "rm -f `pwd`/$map" >> %rebuild_maps_script
# this server is a slave for this map
else
master=`%{_libdir}/yp/makedbm -u $map 2>/dev/null | grep YP_MASTER_NAME | sed -e 's/YP_MASTER_NAME//'`
@ -236,6 +239,8 @@ if [ -e %rebuild_maps_script ] ; then
rm -f %rebuild_maps_script >/dev/null 2>&1
fi
%endif
%files
%doc AUTHORS README INSTALL ChangeLog TODO NEWS COPYING
%doc etc/ypserv.conf etc/securenets etc/README.etc
@ -251,6 +256,9 @@ fi
%{_includedir}/*/*
%changelog
* Mon Jan 28 2013 Honza Horak <hhorak@redhat.com> - 2.29-7
- Open maps with no blocking for reading
* Mon Jan 21 2013 Honza Horak <hhorak@redhat.com> - 2.29-6
- Open database files with correct mode
- Make rebuilding maps during upgrade a bit more clever