Article View: news.software.nntp
Article #79682Re: Documentation: actsync program.
From: Julien ÉLIE
Date: Wed, 19 Nov 2008 09:40
Date: Wed, 19 Nov 2008 09:40
181 lines
6736 bytes
6736 bytes
Hi D. Stussy,
The problem you are reporting was fixed by Jeff in INN 2.5.
I hope we will /soon/ manage to release INN 2.5 -- another reason to!
> I had to look at the source code to figure out why the "-T" option wasn't working.
> It works by looking at the top directories in "patharticle" - i.e. the top of
> the spool for the TRADSPOOL storage type. As I use CNFS, I don't have any such
> directories - and I guess the tool hasn't been updated to account for the existence
> of other storage types (whereby it should scan the active file from "host1" for
> any other group of the same top level hierarchy; possibly building a list
> as the "host1" active file is read).
I tried to see where the problem was but as I did not find it, I searched in
the history of actsync and saw that Jeffrey already fixed that bug:
Revision 7579 (October, 17th 2006):
Fix bug in which -T flag could not work with the storage API. Reported
by Mike Brudenell.
The previous implementation required the on-disk representation of the
spool to check for the existence of a top-level hierarchy; this was
fundamentally insufficient at best, and broke completely with the
storage API.
The new implementation uses a hash table to keep track of which
top-level hierarchies exist in the host1 active file, and thus can
detect new hierarchy creation (when -T is used).
Here is the patch (which may not work on INN 2.4):
http://inn.eyrie.org/viewcvs/trunk/backends/actsync.c?r1=6755&r2=7579&view=patch
--- trunk/backends/actsync.c 2004/05/17 03:01:26 6755
+++ trunk/backends/actsync.c 2006/10/17 00:50:43 7579
@@ -70,6 +70,7 @@
#include "inn/innconf.h"
#include "inn/messages.h"
+#include "inn/hashtab.h"
#include "inn/qio.h"
#include "libinn.h"
#include "paths.h"
@@ -322,7 +323,9 @@
char *host2);
static int exec_cmd(int mode, const char *cmd, char *grp, char *type,
const char *who);
-static int new_top_hier(char *name);
+static int new_top_hier(char *name, struct hash *existing_hier);
+static const void *string_key(const void *entry);
+static bool string_equal(const void *key, const void *entry);
int
main(int argc, char *argv[])
@@ -1803,6 +1806,8 @@
int top_ignore; /* number of groups ignored because of no top level */
int restore; /* host1 groups restored due to -o a1 */
double host1_same; /* % of host1 that is the same */
+ struct hash *existing_hier; /* hash of existing hierarchies for -T */
+ char *p, *q;
int i;
/* firewall */
@@ -1838,12 +1843,24 @@
* If -T, ignore new top level groups from host2
*/
if (no_new_hier) {
+ existing_hier = hash_create(32, hash_string, string_key,
+ string_equal, free);
+ for (i=0; i < grplen; ++i) {
+ if (grp[i].hostid == HOSTID2)
+ continue;
+ p = xstrdup(grp[i].name);
+ q = strchr(p, '.');
+ if (q != NULL)
+ *q = '\0';
+ if (!hash_insert(existing_hier, p, p))
+ free(p);
+ }
top_ignore = 0;
for (i=0; i < grplen; ++i) {
/* look at new newsgroups */
if (grp[i].hostid == HOSTID2 &&
grp[i].output != 0 &&
- new_top_hier(grp[i].name)) {
+ new_top_hier(grp[i].name, existing_hier)) {
/* no top level ignore this new group */
grp[i].ignore |= CHECK_HIER;
grp[i].output = 0;
@@ -1853,6 +1870,7 @@
++top_ignore;
}
}
+ hash_free(existing_hier);
if (D_SUMMARY)
warn("STATUS: ignored %d new newsgroups due to new hierarchy",
top_ignore);
@@ -2688,17 +2706,15 @@
*
* given:
* name name of newsgroup to check
+ * existing_hier hash table of existing hierarchies
*
* returns:
* false hierarchy already exists
* true hierarchy does not exist, name represents a new hierarchy
- *
- * NOTE: This function assumes that we are at the top of the news spool.
*/
static int
-new_top_hier(char *name)
+new_top_hier(char *name, struct hash *existing_hier)
{
- struct stat statbuf; /* stat of the hierarchy */
int result; /* return result */
char *dot;
@@ -2713,7 +2729,8 @@
/*
* determine if we can find this top level hierarchy directory
*/
- result = !(stat(name, &statbuf) >= 0 && S_ISDIR(statbuf.st_mode));
+ result = (hash_lookup(existing_hier, name) == NULL);
+
/* restore name */
if (dot != NULL) {
*dot = '.';
@@ -2724,3 +2741,43 @@
*/
return result;
}
+
+/*
+ * string_key - identity function, for use with hashtab library
+ *
+ * Returns its only argument.
+ *
+ * given:
+ * entry void* pointer representing a string
+ *
+ * returns:
+ * the same void* pointer
+ */
+static const void *
+string_key(const void *entry)
+{
+ return entry;
+}
+
+/*
+ * string_equal - string comparison function, for use with hashtab library
+ *
+ * Compares two strings.
+ *
+ * given:
+ * key void* pointer representing a hash table key
+ * entry void* pointer representing a hash table entry
+ *
+ * returns:
+ * 0 arguments are not equal
+ * 1 arguments are equal
+ */
+static bool
+string_equal(const void *key, const void *entry)
+{
+ const char *p, *q;
+
+ p = key;
+ q = entry;
+ return !strcmp(p, q);
+}
--
Julien ÉLIE
« Le sel de l'existence est essentiellement dans le poivre qu'on y met. »
Technical Details
Message-ID:
<gg0mv6$9th$1@news.trigofacile.com>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.20141118.mbox.gz!border1.nntp.ams.giganews.com!nntp.giganews.com!club-internet.fr!feedme-small.clubint.net!usenet-fr.net!gegeweb.org!news.trigofacile.com!not-for-mailReferences:
<gg0i9t$cjo$1@snarked.org>Show Full Headers
Complete Article Headers
Message-ID: <gg0mv6$9th$1@news.trigofacile.com> Subject: Re: Documentation: actsync program. Date: Wed, 19 Nov 2008 10:40:40 +0100 From: Julien ÉLIE <iulius@nom-de-mon-site.com.invalid> References: <gg0i9t$cjo$1@snarked.org> Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.20141118.mbox.gz!border1.nntp.ams.giganews.com!nntp.giganews.com!club-internet.fr!feedme-small.clubint.net!usenet-fr.net!gegeweb.org!news.trigofacile.com!not-for-mail Newsgroups: news.software.nntp Organization: TrigoFACILE -- http://www.trigofacile.com/ Lines: 181 NNTP-Posting-Host: amontpellier-152-1-24-66.w81-251.abo.wanadoo.fr Mime-Version: 1.0 Content-Type: text/plain; format=flowed; charset="Windows-1252"; reply-type=original Content-Transfer-Encoding: 8bit X-Trace: news.trigofacile.com 1227087655 10161 81.251.57.66 (19 Nov 2008 X-Complaints-To: abuse@trigofacile.com NNTP-Posting-Date: Wed, 19 Nov 2008 09:40:55 +0000 (UTC) In-Reply-To: <gg0i9t$cjo$1@snarked.org> X-MSMail-Priority: Normal X-Newsreader: Microsoft Windows Mail 6.0.6001.18000 X-MimeOLE: Produced By Microsoft MimeOLE V6.0.6001.18049