[leafnode-list] Bug in listgroup?

Matthias Andree ma at dt.e-technik.uni-dortmund.de
Sun Jan 2 23:37:34 CET 2005


Matthias Andree <ma at dt.e-technik.uni-dortmund.de> writes:

> In leafnode, LISTGROUP looks into the .over.view file to figure which
> articles are available, and updating the .over.view is a quite expensive
> operation, as we have flat text files, without index or "active"
> marks. I therefore do not intend to change the current behaviour in the
> near future.

Turns out we had most utility functions in place and reading a directory
linearly should not be too expensive, please try this patch for
LISTGROUP (do not copy & paste, but save the body of this article to a
file and redirect patch's input) and let me know if it works - seems
fine for me and is already committed to the DARCS repository (see
<http://home.pages.de/~mandree/leafnode/beta/darcs/>):

diff -rN -u leafnode-2-darcs-old/NEWS leafnode-2-darcs-new/NEWS
--- leafnode-2-darcs-old/NEWS	2005-01-02 16:22:03.000000000 +0100
+++ leafnode-2-darcs-new/NEWS	2005-01-02 23:28:50.000000000 +0100
@@ -2,6 +2,11 @@
 * Valgrind-2.1.X will interfere with writeactive, break fchmod. Use 2.0.
 * The code sometimes uses timeout_client where it should use a server timeout.
 |
+Changes since 20050102a:
+- Change: obtain LISTGROUP article numbers directly from the directory
+  rather than from the overview, to let cancel/supersedes take effect
+  before the next texpire run. Suggested by Frank Wein.
+
 20050102a: Changes since 20041227a:
 - Bugfix: fetchnews will only try to obtain low/high marks for a group
   if it matches the only_group_pcre, to avoid wasting time on data that
diff -rN -u leafnode-2-darcs-old/nntpd.c leafnode-2-darcs-new/nntpd.c
--- leafnode-2-darcs-old/nntpd.c	2004-12-28 12:13:21.000000000 +0100
+++ leafnode-2-darcs-new/nntpd.c	2005-01-02 23:27:38.000000000 +0100
@@ -2012,12 +2012,17 @@
     }
 }
 
+static int str_comp(const void *p1, const void *p2) {
+    char *const *s1 = p1;
+    char *const *s2 = p2;
+    return strcmp(*s1, *s2);
+}
+
 static /*@null@*/ /*@dependent@*/ struct newsgroup *
 dolistgroup(/*@null@*/ struct newsgroup *group, const char *arg, unsigned long *artno)
 {
     struct newsgroup *g;
     int emptygroup = FALSE;
-    unsigned long idx;
     int pseudogroup;
 
     if (arg && strlen(arg)) {
@@ -2052,18 +2057,21 @@
     markinterest(group->name);
     if (pseudogroup) {
 	nntpprintf_as("211 Article list for %s follows (pseudo)", g->name);
-	printf("%lu\r\n", g->first ? g->first : 1);
+	nntpprintf_as("%lu", g->first ? g->first : 1);
     } else if (emptygroup) {
 	nntpprintf("211 No articles in %s", g->name);
     } else {
-	nntpprintf_as("211 Article list for %s (%lu-%lu) follows",
-		   g->name, xfirst, xlast);
-	for (idx = 0; idx < xcount; idx++) {
-	    if (xoverinfo[idx].text)
-		printf("%lu\r\n", xoverinfo[idx].artno);
+	unsigned long ul;
+	char **t = dirlist(".", DIRLIST_ALLNUM, &ul), **i;
+	nntpprintf_as("211 Article list for %s follows", g->name);
+	if (t) {
+	    qsort(t, ul, sizeof(char *), str_comp);
+	    for (i = t; *i; i++)
+		nntpprintf_as("%s", *i);
+	    free_dirlist(t);
 	}
     }
-    fputs(".\r\n", stdout);
+    nntpprintf(".");
     return group;
 }
 
-- 
Matthias Andree



More information about the leafnode-list mailing list