INN commit: trunk (doc/pod/news.pod storage/tradindexed/tdx-group.c)

INN Commit rra at isc.org
Tue May 5 18:51:27 UTC 2015


    Date: Tuesday, May 5, 2015 @ 11:51:27
  Author: iulius
Revision: 9852

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:
  trunk/doc/pod/news.pod
  trunk/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-05 17:23:25 UTC (rev 9851)
+++ doc/pod/news.pod	2015-05-05 18:51:27 UTC (rev 9852)
@@ -274,6 +274,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-05 17:23:25 UTC (rev 9851)
+++ storage/tradindexed/tdx-group.c	2015-05-05 18:51:27 UTC (rev 9852)
@@ -279,7 +279,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)
@@ -503,11 +504,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