INN commit: branches/2.5 (2 files)

INN Commit rra at isc.org
Thu May 14 13:42:56 UTC 2015


    Date: Thursday, May 14, 2015 @ 06:42:55
  Author: iulius
Revision: 9865

Correct remap check in tradindexed group lookup

Previously the remap check had an off-by-one bug and moreover
would never be done due to the loop condition (making the
off-by-one bug moot).

This one could be a problem in real life; if creating a group
causes innd to expand the index then an already-running nnrpd
will not automatically notice, and so won't be able to find the
group.

Thanks to Richard Kettlewell for the patch.

Modified:
  branches/2.5/doc/pod/news.pod
  branches/2.5/storage/tradindexed/tdx-group.c

---------------------------------+
 doc/pod/news.pod                |    6 ++++++
 storage/tradindexed/tdx-group.c |   16 ++++++++++++----
 2 files changed, 18 insertions(+), 4 deletions(-)

Modified: doc/pod/news.pod
===================================================================
--- doc/pod/news.pod	2015-05-14 13:41:41 UTC (rev 9864)
+++ doc/pod/news.pod	2015-05-14 13:42:55 UTC (rev 9865)
@@ -49,6 +49,12 @@
 
 =item *
 
+When the creation of a newsgroup needed expanding the tradindexed group
+index, an already-running B<nnrpd> was not automatically noticing newly
+created newsgroups.  Richard Kettlewell fixed that issue.
+
+=item *
+
 Fixed how B<innupgrade> is executed during an update of an INN
 installation; on a few systems like AIX, it fails to run because its
 taint mode was unproperly declared.

Modified: storage/tradindexed/tdx-group.c
===================================================================
--- storage/tradindexed/tdx-group.c	2015-05-14 13:41:41 UTC (rev 9864)
+++ storage/tradindexed/tdx-group.c	2015-05-14 13:42:55 UTC (rev 9865)
@@ -278,7 +278,8 @@
 /*
 **  Given a group location, remap the index file if our existing mapping isn't
 **  large enough to include that group.  (This can be the case when another
-**  writer is appending entries to the group index.)
+**  writer is appending entries to the group index.)  Returns true on success
+**  (which includes "did not need to remap") and false on failure.
 */
 static bool
 index_maybe_remap(struct group_index *index, long loc)
@@ -502,11 +503,18 @@
 	return -1;
     loc = index->header->hash[index_bucket(hash)].recno;
 
-    while (loc >= 0 && loc < index->count) {
+    while (loc >= 0) {
         struct group_entry *entry;
 
-        if (loc > index->count && !index_maybe_remap(index, loc))
-            return -1;
+        if (loc >= index->count) {
+            if (!index_maybe_remap(index, loc)) {
+                return -1;
+            }
+            if (loc >= index->count) {
+                syswarn("tradindexed: entry %ld out of range", loc);
+                return -1;
+            }
+        }
         entry = index->entries + loc;
         if (entry->deleted == 0)
             if (memcmp(&hash, &entry->hash, sizeof(hash)) == 0)



More information about the inn-committers mailing list