Bug fix in ov3.c
Richard Michael Todd
rmtodd at mailhost.ecn.ou.edu
Wed Aug 25 06:09:21 UTC 1999
OV3packgroup sometimes (quite often, actually, during makehistory) fails with
"tradindexed: packgroup cant write to %s: %m" error message. The reason is
this: The code attempts to, after mmap()ing the old index file, write out
all the data from "low" to "high" in the old index file to the new index
file in one fell swoop. But the old index file may be smaller than
the number of bytes nbytes=(ge->high - ge->low + 1)*sizeof(INDEXENTRY).
This happens because entries for the article numbers around ge->high were
never written to the .idx file, because
a) we're doing makehistory and just haven't seen those articles yet, or
b) those articles were canceled, so no overview was written for them in the
last expireover.
The following patch causes OV3packgroup to only write as many bytes as are
actually present in the old index file.
P.S. I think that case b) above may also be the reason for the
"truncated overview" errors from expireover, which indicates that said
error message is spurious and can be silenced. But I'm still not entirely
sure of this, so I didn't send a patch to change that.
Index: storage/ov3/ov3.c
===================================================================
RCS file: /home/rmtodd/TempCVS/Temp-CVS-Repository/inn-current/storage/ov3/ov3.c,v
retrieving revision 1.2
diff -u -r1.2 ov3.c
--- ov3.c 1999/08/25 04:44:27 1.2
+++ ov3.c 1999/08/25 05:53:40
@@ -1032,9 +1032,28 @@
return FALSE;
}
+ /* stat old index file so we know its actual size. */
+ if (fstat(fd, &sb) < 0) {
+ syslog(L_ERROR, "tradindexed: could not stat %s: %m", newidx);
+ close(fd);
+ OV3closegroup(gh, FALSE);
+ GROUPlock(gloc, LOCK_UNLOCK);
+ return FALSE;
+ }
+
+
/* write old index records to new file */
numentries = ge->high - ge->low + 1;
nbytes = numentries * sizeof(INDEXENTRY);
+
+ /*
+ ** check to see if the actual file length is less than nbytes (since the
+ ** article numbers may be sparse) and if so, only read/write that amount.
+ */
+ if (nbytes > sb.st_size) {
+ nbytes = sb.st_size;
+ }
+
if (pwrite(fd, &gh->indexmem[ge->low - ge->base] , nbytes,
sizeof(INDEXENTRY)*(ge->low - ge->base + delta)) != nbytes) {
syslog(L_ERROR, "tradindexed: packgroup cant write to %s: %m", newidx);
More information about the inn-patches
mailing list