rpms/ypbind/devel ypbind-mt-1.20.4-smartwrite.patch, NONE, 1.1 ypbind.spec, 1.50, 1.51

Vitezslav Crhonek vcrhonek at fedoraproject.org
Tue Oct 21 10:49:47 UTC 2008


Author: vcrhonek

Update of /cvs/extras/rpms/ypbind/devel
In directory cvs1.fedora.phx.redhat.com:/tmp/cvs-serv26942

Modified Files:
	ypbind.spec 
Added Files:
	ypbind-mt-1.20.4-smartwrite.patch 
Log Message:
Rewrite binding files only when they are changed

ypbind-mt-1.20.4-smartwrite.patch:

--- NEW FILE ypbind-mt-1.20.4-smartwrite.patch ---
diff -up ypbind-mt-1.20.4/src/serv_list.c_old ypbind-mt-1.20.4/src/serv_list.c
--- ypbind-mt-1.20.4/src/serv_list.c_old	2008-10-21 11:37:59.000000000 +0200
+++ ypbind-mt-1.20.4/src/serv_list.c	2008-10-21 11:38:20.000000000 +0200
@@ -81,6 +81,7 @@ struct binding
   struct bound_server server[_MAXSERVER];
   struct bound_server ypset;
   CLIENT *client_handle;
+  struct bound_server last; /* last written */
 };
 static inline char *
 bound_host(struct binding *bptr)
@@ -133,26 +134,44 @@ update_bindingfile (struct binding *entr
   sprintf (path1, "%s/%s.1", BINDINGDIR, entry->domain);
   sprintf (path2, "%s/%s.2", BINDINGDIR, entry->domain);
 
-  iov[0].iov_base = (caddr_t) &sport;
-  iov[0].iov_len = sizeof (sport);
-  iov[1].iov_base = (caddr_t) &ybres;
-  iov[1].iov_len = sizeof ybres;
-
   memset(&ybres, 0, sizeof (ybres));
   ybres.ypbind_status = YPBIND_SUCC_VAL;
   if (entry->active >= 0)
     {
+      if (entry->last.host &&
+          !memcmp(&entry->server[entry->active].addr, &entry->last.addr,
+		  sizeof(struct in_addr)) &&
+          entry->server[entry->active].port == entry->last.port)
+        {
+	  if (debug_flag)
+	    log_msg (LOG_DEBUG, "Entry for %s unchanged, skipping writeout",
+		     entry->domain);
+          return;
+        }
+
       memcpy (&ybres.ypbind_resp_u.ypbind_bindinfo.ypbind_binding_addr,
 	      &entry->server[entry->active].addr, sizeof (struct in_addr));
       memcpy (&ybres.ypbind_resp_u.ypbind_bindinfo.ypbind_binding_port,
 	      &entry->server[entry->active].port, sizeof (unsigned short int));
+      entry->last= entry->server[entry->active];
     }
   else if (entry->active == -2) /* ypset was used */
     {
+      if (entry->last.host &&
+          !memcmp(&entry->ypset.addr, &entry->last.addr,
+		  sizeof(struct in_addr)) &&
+          entry->ypset.port == entry->last.port)
+        {
+	  if (debug_flag)
+	    log_msg (LOG_DEBUG, "Entry for %s unchanged, skipping writeout",
+		     entry->domain);
+          return;
+        }
       memcpy (&ybres.ypbind_resp_u.ypbind_bindinfo.ypbind_binding_addr,
 	      &entry->ypset.addr, sizeof (struct in_addr));
       memcpy (&ybres.ypbind_resp_u.ypbind_bindinfo.ypbind_binding_port,
 	      &entry->ypset.port, sizeof (unsigned short int));
+      entry->last= entry->ypset;
     }
   else
     {
@@ -160,10 +179,16 @@ update_bindingfile (struct binding *entr
           libc will query ypbind direct. */
        unlink (path1);
        unlink (path2);
+       entry->last.host = NULL;
        log_msg (LOG_ERR, "INTERNAL ERROR: update_bindingfile called without valid data!");
        return;
     }
 
+  iov[0].iov_base = (caddr_t) &sport;
+  iov[0].iov_len = sizeof (sport);
+  iov[1].iov_base = (caddr_t) &ybres;
+  iov[1].iov_len = sizeof ybres;
+
   len = iov[0].iov_len + iov[1].iov_len;
 
   if ((fd = open(path1, O_CREAT | O_RDWR | O_TRUNC, FILE_MODE )) != -1)
@@ -171,6 +196,7 @@ update_bindingfile (struct binding *entr
       if (writev (fd, iov, 2) != len )
         {
           log_msg (LOG_ERR, "writev (%s): %s", path1, strerror (errno));
+	  entry->last.host = NULL;
           unlink (path1);
         }
       close (fd);
@@ -183,6 +209,7 @@ update_bindingfile (struct binding *entr
       if (writev (fd, iov, 2) != len )
         {
           log_msg (LOG_ERR, "writev (%s): %s", path2, strerror (errno));
+	   entry->last.host = NULL;
           unlink (path2);
         }
       close (fd);
@@ -403,6 +430,7 @@ get_entry (const char *domain, struct bi
       domainlist[max_domains - 1].ypset.host = NULL;
       domainlist[max_domains - 1].active = (-1);
       domainlist[max_domains - 1].use_broadcast = FALSE;
+      domainlist[max_domains - 1].last.host = NULL;
       memset (domainlist[max_domains - 1].server, 0,
 	      (_MAXSERVER * sizeof (struct bound_server)));
       *entry = &domainlist[max_domains - 1];


Index: ypbind.spec
===================================================================
RCS file: /cvs/extras/rpms/ypbind/devel/ypbind.spec,v
retrieving revision 1.50
retrieving revision 1.51
diff -u -r1.50 -r1.51
--- ypbind.spec	12 Aug 2008 00:13:46 -0000	1.50
+++ ypbind.spec	21 Oct 2008 10:49:17 -0000	1.51
@@ -1,7 +1,7 @@
 Summary: The NIS daemon which binds NIS clients to an NIS domain.
 Name: ypbind
 Version: 1.20.4
-Release: 7%{?dist}
+Release: 8%{?dist}
 License: GPLv2
 Group: System Environment/Daemons
 Source0: ftp://ftp.us.kernel.org/pub/linux/utils/net/NIS/ypbind-mt-%{PACKAGE_VERSION}.tar.bz2
@@ -12,6 +12,7 @@
 Patch3: ypbind-mt-1.19-port-leak.patch
 Patch4: ypbind-mt-1.19-log-binds.patch
 Patch5: ypbind-1.19-debuginfo.patch
+Patch6: ypbind-mt-1.20.4-smartwrite.patch
 
 Prereq: /sbin/chkconfig
 Requires: rpcbind, yp-tools, bash >= 2.0
@@ -45,6 +46,7 @@
 %patch3 -p1
 %patch4 -p1
 #%patch5 -p1
+%patch6 -p1 -b .smartwrite
 
 %build
 autoreconf
@@ -91,6 +93,10 @@
 %doc README NEWS
 
 %changelog
+* Tue Oct 21 2008 Vitezslav Crhonek <vcrhonek at redhat.com> - 1.20.4-8
+- Rewrite binding files only when they are changed
+  Resolves: #454581
+
 * Mon Aug 11 2008 Jason L Tibbitts III <tibbs at math.uh.edu> - 1.20.4-7
 - Fix license tag.
 




More information about the fedora-extras-commits mailing list