INN commit: trunk (8 files)

INN Commit rra at isc.org
Fri Jan 15 22:30:31 UTC 2021


    Date: Friday, January 15, 2021 @ 14:30:30
  Author: iulius
Revision: 10512

inndf:  report buffindexed usage with 2 decimals

Output was previously truncated at the inferior number (e.g. 37.00%).

Modified:
  trunk/expire/makehistory.c
  trunk/innd/art.c
  trunk/storage/buffindexed/buffindexed.c
  trunk/storage/ovdb/ovdb.c
  trunk/storage/overview.c
  trunk/storage/ovsqlite/ovsqlite.c
  trunk/storage/tradindexed/tradindexed.c
  trunk/tests/util/inndf.t

-----------------------------------+
 expire/makehistory.c              |    8 +++++---
 innd/art.c                        |    3 ++-
 storage/buffindexed/buffindexed.c |    5 +++--
 storage/ovdb/ovdb.c               |    5 +++--
 storage/overview.c                |    4 ++--
 storage/ovsqlite/ovsqlite.c       |    2 +-
 storage/tradindexed/tradindexed.c |    5 +++--
 tests/util/inndf.t                |    2 +-
 8 files changed, 20 insertions(+), 14 deletions(-)

Modified: expire/makehistory.c
===================================================================
--- expire/makehistory.c	2021-01-15 11:13:05 UTC (rev 10511)
+++ expire/makehistory.c	2021-01-15 22:30:30 UTC (rev 10512)
@@ -154,6 +154,7 @@
     char temp[SMBUF];
     char *SortedTmpPath;
     int i, pid, fd;
+    float f;
     TOKEN token;
     QIOSTATE *qp;
     int count;
@@ -279,7 +280,7 @@
 	}
 	token = TextToToken(q);
 	if (OVadd(token, r, strlen(r), arrived, expires) == OVADDFAILED) {
-	    if (OVctl(OVSPACE, (void *)&i) && i == OV_NOSPACE) {
+	    if (OVctl(OVSPACE, (void *)&f) && (int)(f+0.01f) == OV_NOSPACE) {
                 warn("no space left for overview");
 		OVclose();
 		Fork ? _exit(1) : exit(1);
@@ -315,7 +316,8 @@
 {
     char temp[SMBUF];
     const char *p, *q, *r;
-    int i, fd;
+    int fd;
+    float f;
 
     /* If WriteStdout is set, just print the overview information to standard
        output and return. */
@@ -337,7 +339,7 @@
                 sysdie("writing overview failed");
 	    fputc('\n', Overchan);
 	} else if (OVadd(*token, overdata, overlen, arrived, expires) == OVADDFAILED) {
-	    if (OVctl(OVSPACE, (void *)&i) && i == OV_NOSPACE) {
+	    if (OVctl(OVSPACE, (void *)&f) && (int)(f+0.01f) == OV_NOSPACE) {
                 warn("no space left for overview");
 		OVclose();
 		exit(1);

Modified: innd/art.c
===================================================================
--- innd/art.c	2021-01-15 11:13:05 UTC (rev 10511)
+++ innd/art.c	2021-01-15 22:30:30 UTC (rev 10512)
@@ -1939,6 +1939,7 @@
 {
   char		*p, **groups, ControlWord[SMBUF], **hops, *controlgroup;
   int		i, j, *isp, hopcount, oerrno, canpost;
+  float         f;
   size_t        n;
   NEWSGROUP	*ngp, **ngptr;
   NEWSGROUP     *ngpjunk;
@@ -2532,7 +2533,7 @@
     if (innconf->enableoverview && !innconf->useoverchan) {
       if ((result = OVadd(token, data->Overview.data, data->Overview.left,
 	data->Arrived, data->Expires)) == OVADDFAILED) {
-	if (OVctl(OVSPACE, (void *)&i) && i == OV_NOSPACE)
+	if (OVctl(OVSPACE, (void *)&f) && (int)(f+0.01f) == OV_NOSPACE)
 	  IOError("creating overview", ENOSPC);
 	else
 	  IOError("creating overview", 0);

Modified: storage/buffindexed/buffindexed.c
===================================================================
--- storage/buffindexed/buffindexed.c	2021-01-15 11:13:05 UTC (rev 10511)
+++ storage/buffindexed/buffindexed.c	2021-01-15 22:30:30 UTC (rev 10512)
@@ -2210,6 +2210,7 @@
 
 bool buffindexed_ctl(OVCTLTYPE type, void *val) {
   int			total, used, *i, j;
+  float                 *f;
   OVBUFF		*ovbuff = ovbufftab;
   OVSORTTYPE		*sorttype;
   bool			*boolval;
@@ -2224,8 +2225,8 @@
       used += ovbuff->usedblk;
       ovlock(ovbuff, INN_LOCK_UNLOCK);
     }
-    i = (int *)val;
-    *i = (used * 100) / total;
+    f = (float *)val;
+    *f = ((float)used / total) * 100;
     return true;
   case OVSORT:
     sorttype = (OVSORTTYPE *)val;

Modified: storage/ovdb/ovdb.c
===================================================================
--- storage/ovdb/ovdb.c	2021-01-15 11:13:05 UTC (rev 10511)
+++ storage/ovdb/ovdb.c	2021-01-15 22:30:30 UTC (rev 10512)
@@ -2987,13 +2987,14 @@
 bool ovdb_ctl(OVCTLTYPE type, void *val)
 {
     int *i;
+    float *f;
     OVSORTTYPE *sorttype;
     bool *boolval;
 
     switch (type) {
     case OVSPACE:
-        i = (int *)val;
-        *i = -1;
+        f = (float *)val;
+        *f = -1.0f;
         return true;
     case OVSORT:
         sorttype = (OVSORTTYPE *)val;

Modified: storage/overview.c
===================================================================
--- storage/overview.c	2021-01-15 11:13:05 UTC (rev 10511)
+++ storage/overview.c	2021-01-15 22:30:30 UTC (rev 10512)
@@ -409,10 +409,10 @@
 float
 overview_free_space(struct overview *overview)
 {
-    int space;
+    float space;
 
     if (overview->method->ctl(OVSPACE, &space))
         return space;
     else
-        return -1;
+        return -1.0f;
 }

Modified: storage/ovsqlite/ovsqlite.c
===================================================================
--- storage/ovsqlite/ovsqlite.c	2021-01-15 11:13:05 UTC (rev 10511)
+++ storage/ovsqlite/ovsqlite.c	2021-01-15 22:30:30 UTC (rev 10512)
@@ -970,7 +970,7 @@
     }
     switch (type) {
     case OVSPACE:
-        *(int *)val = -1;
+        *(float *)val = -1.0f;
         return true;
     case OVSORT:
         *(OVSORTTYPE *)val = OVNEWSGROUP;

Modified: storage/tradindexed/tradindexed.c
===================================================================
--- storage/tradindexed/tradindexed.c	2021-01-15 11:13:05 UTC (rev 10511)
+++ storage/tradindexed/tradindexed.c	2021-01-15 22:30:30 UTC (rev 10512)
@@ -372,6 +372,7 @@
 tradindexed_ctl(OVCTLTYPE type, void *val)
 {
     int *i;
+    float *f;
     bool *b;
     OVSORTTYPE *sort;
 
@@ -382,8 +383,8 @@
 
     switch (type) {
     case OVSPACE:
-        i = (int *) val;
-        *i = -1;
+        f = (float *) val;
+        *f = -1.0f;
         return true;
     case OVSORT:
         sort = (OVSORTTYPE *) val;

Modified: tests/util/inndf.t
===================================================================
--- tests/util/inndf.t	2021-01-15 11:13:05 UTC (rev 10511)
+++ tests/util/inndf.t	2021-01-15 22:30:30 UTC (rev 10512)
@@ -130,7 +130,7 @@
     printcount "not ok"
 fi
 out=`$inndf -o`
-if [ "$out" = "3.00% overview space used" ] ; then
+if [ "$out" = "3.17% overview space used" ] ; then
     printcount "ok"
 else
     echo "$out"



More information about the inn-committers mailing list