Ticket #12: diablo-hashfeed.patch

File diablo-hashfeed.patch, 4.7 KB (added by eagle, 12 years ago)

Patch against INN 2.4.2

  • doc/pod/newsfeeds.pod

    old new  
    382382new process will run with.  This flag can be used to raise the priority to
    383383normal if you're using the I<nicekids> parameter in F<inn.conf>.
    384384
     385=item B<Q> I<hashfeed>
     386
     387The hashfeed value for this site. The message-id of the article is
     388hashed using a quick (and dirty) hash method (31-bits sum of the value
     389of all characters). The hashfeed value must be given as value/mod
     390or as start-end/mod. If the message-id hash modulus "mod" plus one
     391equals "number" or is between "start" and "end", the article will be
     392fed to the site.
     393
     394Example:
     395
     396    Q1/2     Feeds about 50% of the messages to this site
     397    Q2/2     Feeds the other 50% of the messages
     398
     399    Q1-3/10  Feeds about 30% of the messages
     400    Q4-5/10  Feeds about 30% of the messages
     401    Q6/10    Feeds about 50% of the messages
     402
     403If this flag is specified multiple times the contents will be
     404logically ORed together (just one match needed).
     405
     406The algorithm is compatible with the one used by Diablo.
     407
    385408=item B<S> I<size>
    386409
    387410If the amount of data queued for the site gets to be larger than I<size>
  • innd/art.c

    diff -ruN inn-2.4.2/innd/art.c inn-2.4.2-new/innd/art.c
    old new  
    15471547}
    15481548
    15491549/*
     1550**  Return true if an element of the QHASHLIST matches the
     1551**  quickhash of the message-id.
     1552*/
     1553static bool
     1554QHashMatch(QHASHLIST *qh, char *MessageID)
     1555{
     1556  unsigned char *p = (unsigned char *)MessageID;
     1557  int h = 0;
     1558
     1559  while (*p)
     1560    h += *p++;
     1561
     1562  while (qh) {
     1563    if ((h % qh->mod + 1) >= qh->begin &&
     1564        (h % qh->mod + 1) <= qh->end)
     1565          return true;
     1566    qh = qh->next;
     1567  }
     1568
     1569  return false;
     1570}
     1571
     1572/*
    15501573**  Propagate an article to the sites have "expressed an interest."
    15511574*/
    15521575static void
     
    16191642       * cross-posting. */
    16201643      continue;
    16211644
     1645    if (sp->QHashList && !QHashMatch(sp->QHashList, HDR(HDR__MESSAGE_ID)))
     1646      /* quickhash doesn't match */
     1647      continue;
     1648
    16221649    if (list && *list != NULL && sp->Distributions &&
    16231650      !DISTwantany(sp->Distributions, list))
    16241651      /* Not in the site's desired list of distributions. */
  • innd/innd.h

    diff -ruN inn-2.4.2/innd/innd.h inn-2.4.2-new/innd/innd.h
    old new  
    407407
    408408
    409409/*
     410**  Diablo-style hashed feeds or hashfeeds.
     411*/
     412typedef struct _QHASHLIST {
     413  int                   begin;
     414  int                   end;
     415  int                   mod;
     416  struct _QHASHLIST     *next;
     417} QHASHLIST;
     418
     419
     420/*
    410421**  A site may reject something in its subscription list if it has
    411422**  too many hops, or a bad distribution.
    412423*/
     
    458469  struct buffer   Buffer;
    459470  bool            Buffered;
    460471  char        **  Originator;
     472  QHASHLIST    *  QHashList;
    461473  int             Next;
    462474  int             Prev;
    463475} SITE;
  • innd/newsfeeds.c

    diff -ruN inn-2.4.2/innd/newsfeeds.c inn-2.4.2-new/innd/newsfeeds.c
    old new  
    448448    int                 isp;
    449449    SITE                *nsp;
    450450    struct buffer       b;
     451    QHASHLIST           *qh;
    451452
    452453    b = sp->Buffer;
    453454    *sp = SITEnull;
     
    467468    sp->NeedOverviewCreation = false;
    468469    sp->FeedwithoutOriginator = false;
    469470    sp->DropFiltered = false;
     471    sp->QHashList = NULL;
    470472
    471473    /* Nip off the first field, the site name. */
    472474    if ((f2 = strchr(Entry, NF_FIELD_SEP)) == NULL)
     
    603605            if (*++p && CTYPE(isdigit, *p))
    604606                sp->Nice = atoi(p);
    605607            break;
     608        case 'Q':
     609            qh = xmalloc(sizeof(QHASHLIST));
     610            p++;
     611            if (sscanf(p, "%d/%d", &qh->begin, &qh->mod) == 2) {
     612                qh->end = qh->begin;
     613            } else if (sscanf(p, "%d-%d/%d", &qh->begin, &qh->end, &qh->mod) != 3) {
     614                free(qh);
     615                return "hash not in x/z or x-y/z format";
     616            }
     617            qh->next = sp->QHashList;
     618            sp->QHashList = qh;
     619            break;
    606620        case 'S':
    607621            if (*++p && CTYPE(isdigit, *p))
    608622                sp->StartSpooling = atol(p);
  • innd/site.c

    diff -ruN inn-2.4.2/innd/site.c inn-2.4.2-new/innd/site.c
    old new  
    997997SITEfree(SITE *sp)
    998998{
    999999    SITE                *s;
     1000    QHASHLIST           *qh, *qn;
    10001001    int                 new;
    10011002    int                 i;
    10021003   
     
    10511052        sp->FNLnames.data = NULL;
    10521053        sp->FNLnames.size = 0;
    10531054    }
     1055    if (sp->QHashList) {
     1056        for (qh = sp->QHashList; qh; qh = qn) {
     1057            qn = qh->next;
     1058            free(qh);
     1059        }
     1060        sp->QHashList = NULL;
     1061    }
    10541062
    10551063    /* If this site was a master, find a new one. */
    10561064    if (sp->IsMaster) {