rpms/inn/devel inn-2.5.0-loadaverage.patch, NONE, 1.1 inn.spec, 1.63, 1.64

Ondrej Vasik ovasik at fedoraproject.org
Wed Jun 24 08:09:46 UTC 2009


Author: ovasik

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

Modified Files:
	inn.spec 
Added Files:
	inn-2.5.0-loadaverage.patch 
Log Message:
add support for load average to makehistory(#276061)

inn-2.5.0-loadaverage.patch:

--- NEW FILE inn-2.5.0-loadaverage.patch ---
diff -urNp inn-2.5.0-orig/doc/pod/makehistory.pod inn-2.5.0/doc/pod/makehistory.pod
--- inn-2.5.0-orig/doc/pod/makehistory.pod	2009-06-24 09:54:24.000000000 +0200
+++ inn-2.5.0/doc/pod/makehistory.pod	2009-06-24 09:56:58.000000000 +0200
@@ -5,7 +5,7 @@ makehistory - Initialize or rebuild INN 
 =head1 SYNOPSIS
 
 B<makehistory> [B<-abFIOSx>] [B<-f> I<filename>] [B<-l> I<count>]
-[B<-s> I<size>] [B<-T> I<tmpdir>]
+[B<-L> I<load-average>] [B<-s> I<size>] [B<-T> I<tmpdir>]
 
 =head1 DESCRIPTION
 
@@ -89,6 +89,16 @@ specify the temporary storage location. 
 with buffindexed, because buffindexed does not need sorted
 overview and no batching is done.
 
+=item B<-L> I<load-average>
+
+Temporarily pause activities if the system load average exceeds the
+specified level I<load-average>.  This allows B<makehistory> to run
+on a system being used for other purposes without monopolizing system
+resources and thus making the response time for other applications
+unacceptably slow.  Using nice(1) does not help much for that because
+the problem comes from disk I/O usage, and ionice(1) is not always
+available or efficient.
+
 =item B<-O>
 
 Create the overview database as well as the F<history> file.  Overview
diff -urNp inn-2.5.0-orig/expire/makehistory.c inn-2.5.0/expire/makehistory.c
--- inn-2.5.0-orig/expire/makehistory.c	2009-06-24 09:54:24.000000000 +0200
+++ inn-2.5.0/expire/makehistory.c	2009-06-24 10:05:02.000000000 +0200
@@ -24,8 +24,28 @@
 #include "inn/vector.h"
 #include "inn/wire.h"
 
+/*
+**  If we have getloadavg, include the appropriate header file.  Otherwise,
+**  just assume that we always have a load of 0.
+*/
+#if HAVE_GETLOADAVG
+# if HAVE_SYS_LOADAVG_H
+#  include <sys/loadavg.h>
+# endif
+#else
+static int
+getloadavg(double loadavg[], int nelem)
+{
+   int i;
+
+   for (i = 0; i < nelem && i < 3; i++)
+        loadavg[i] = 0;
+   return i;
+}
+#endif
+
 static const char usage[] = "\
-Usage: makehistory [-abFIOSx] [-f file] [-l count] [-s size] [-T tmpdir]\n\
+Usage: makehistory [-abFIOSx] [-f file] [-l count] [-L load] [-s size] [-T tmpdir]\n\
 \n\
     -a          open output history file in append mode\n\
     -b          delete bad articles from spool\n\
@@ -33,6 +53,7 @@ Usage: makehistory [-abFIOSx] [-f file] 
     -f file     write history entries to file (default $pathdb/history)\n\
     -I          do not create overview for articles numbered below lowmark\n\
     -l count    size of overview updates (default 10000)\n\
+    -L load     pause when load average exceeds threshold\n\
     -O          create overview entries for articles\n\
     -S          write overview data to standard output\n\
     -s size     size new history database for approximately size entries\n\
@@ -810,6 +831,8 @@ main(int argc, char **argv)
 {
     ARTHANDLE *art = NULL;
     bool AppendMode;
+    int LoadAverage;
+    double load[1];
     int i;
     bool val;
     char *HistoryDir;
@@ -837,9 +860,10 @@ main(int argc, char **argv)
     DoOverview = false;
     Fork = false;
     AppendMode = false;
+    LoadAverage = 0;
     NoHistory = false;
 
-    while ((i = getopt(argc, argv, "abFf:Il:OSs:T:x")) != EOF) {
+    while ((i = getopt(argc, argv, "abFf:Il:L:OSs:T:x")) != EOF) {
 	switch(i) {
 	case 'a':
 	    AppendMode = true;
@@ -859,6 +883,9 @@ main(int argc, char **argv)
 	case 'l':
 	    OverTmpSegSize = atoi(optarg);
 	    break;
+	case 'L':
+	    LoadAverage = atoi(optarg);
+	    break;
 	case 'O':
 	    DoOverview = true;
 	    break;
@@ -956,7 +983,7 @@ main(int argc, char **argv)
 
     /*
      * Scan the entire spool, nuke any bad arts if needed, and process each
-     * article.
+     * article. We take a break when the load is too high.
      */
 	
     while ((art = SMnext(art, RETR_ALL)) != NULL) {
@@ -965,7 +992,15 @@ main(int argc, char **argv)
 		SMcancel(*art->token);
 	    continue;
 	}
+
 	DoArt(art);
+
+        if (LoadAverage > 0) {
+            while (getloadavg(load, 1) > 0 &&
+                   (int) (load[0]) >= LoadAverage) {
+                 sleep(1);
+            }
+        }
     }
 
     if (!NoHistory) {


Index: inn.spec
===================================================================
RCS file: /cvs/extras/rpms/inn/devel/inn.spec,v
retrieving revision 1.63
retrieving revision 1.64
diff -u -p -r1.63 -r1.64
--- inn.spec	10 Jun 2009 14:13:51 -0000	1.63
+++ inn.spec	24 Jun 2009 08:09:45 -0000	1.64
@@ -1,7 +1,7 @@
 Summary: The InterNetNews system, an Usenet news server
 Name: inn
 Version: 2.5.0
-Release: 1
+Release: 2
 #see LICENSE file for details
 License: GPL+ and BSD and MIT and Public Domain
 Group: System Environment/Daemons
@@ -354,6 +354,9 @@ exit 0
 %{_mandir}/man1/inews*
 
 %changelog
+* Wed Jun 24 2009 Ondrej Vasik <ovasik at redhat.com> - 2.5.0-2
+- add support for load average to makehistory(#276061)
+
 * Tue Jun 09 2009 Ondrej Vasik <ovasik at redhat.com> - 2.5.0-1
 - new upstream release 2.5.0
 - remove applied and adjust modified patches




More information about the fedora-extras-commits mailing list