Changeset 10423


Ignore:
Timestamp:
Mar 25, 2010, 8:03:56 PM (11 years ago)
Author:
charles
Message:

(trunk third-party) #2767 "DHT-formatted dictionaries are incorrect" -- fixed by upgrading our DHT snapshot to dht-0.15 from http://www.pps.jussieu.fr/~jch/software/files/dht-0.15.tar.gz

Location:
trunk/third-party/dht
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/third-party/dht/CHANGES

    r9777 r10423  
     125 March 2010: dht-0.14
     2
     3  * Fixed ordering of entries in parameter dictionaries.
     4
    1515 December 2009: dht-0.13
    26
  • trunk/third-party/dht/dht.c

    r9777 r10423  
    11/*
    2 Copyright (c) 2009 by Juliusz Chroboczek
     2Copyright (c) 2010 by Juliusz Chroboczek
    33
    44Permission is hereby granted, free of charge, to any person obtaining a copy
     
    263263static time_t expire_stuff_time;
    264264
    265 #define MAX_LEAKY_BUCKET_TOKENS 40
    266 static time_t leaky_bucket_time;
    267 static int leaky_bucket_tokens;
     265#define MAX_TOKEN_BUCKET_TOKENS 40
     266static time_t token_bucket_time;
     267static int token_bucket_tokens;
    268268
    269269FILE *dht_debug = NULL;
     
    989989                   omitting the token when storage tables are full.  While
    990990                   I don't think this makes a lot of sense -- just sending
    991                    a positive reply is just as good, let's deal with it. */
     991                   a positive reply is just as good --, let's deal with it. */
    992992                if(n->token_len == 0)
    993993                    n->acked = 1;
     
    15931593    next_blacklisted = 0;
    15941594
    1595     leaky_bucket_time = now.tv_sec;
    1596     leaky_bucket_tokens = MAX_LEAKY_BUCKET_TOKENS;
     1595    token_bucket_time = now.tv_sec;
     1596    token_bucket_tokens = MAX_TOKEN_BUCKET_TOKENS;
    15971597
    15981598    memset(secret, 0, sizeof(secret));
     
    16561656
    16571657static int
    1658 leaky_bucket(void)
    1659 {
    1660     if(leaky_bucket_tokens == 0) {
    1661         leaky_bucket_tokens = MIN(MAX_LEAKY_BUCKET_TOKENS,
    1662                                   4 * (now.tv_sec - leaky_bucket_time));
    1663         leaky_bucket_time = now.tv_sec;
    1664     }
    1665 
    1666     if(leaky_bucket_tokens == 0)
     1658token_bucket(void)
     1659{
     1660    if(token_bucket_tokens == 0) {
     1661        token_bucket_tokens = MIN(MAX_TOKEN_BUCKET_TOKENS,
     1662                                  4 * (now.tv_sec - token_bucket_time));
     1663        token_bucket_time = now.tv_sec;
     1664    }
     1665
     1666    if(token_bucket_tokens == 0)
    16671667        return 0;
    16681668
    1669     leaky_bucket_tokens--;
     1669    token_bucket_tokens--;
    16701670    return 1;
    16711671}
     
    18701870        if(message > REPLY) {
    18711871            /* Rate limit requests. */
    1872             if(!leaky_bucket()) {
     1872            if(!token_bucket()) {
    18731873                debugf("Dropping request due to rate limiting.\n");
    18741874                goto dontread;
     
    23742374    rc = snprintf(buf + i, 2048 - i, "d1:rd2:id20:"); INC(i, rc, 2048);
    23752375    COPY(buf, i, myid, 20, 2048);
     2376    if(nodes_len > 0) {
     2377        rc = snprintf(buf + i, 2048 - i, "5:nodes%d:", nodes_len);
     2378        INC(i, rc, 2048);
     2379        COPY(buf, i, nodes, nodes_len, 2048);
     2380    }
     2381    if(nodes6_len > 0) {
     2382         rc = snprintf(buf + i, 2048 - i, "6:nodes6%d:", nodes6_len);
     2383         INC(i, rc, 2048);
     2384         COPY(buf, i, nodes6, nodes6_len, 2048);
     2385    }
    23762386    if(token_len > 0) {
    23772387        rc = snprintf(buf + i, 2048 - i, "5:token%d:", token_len);
    23782388        INC(i, rc, 2048);
    23792389        COPY(buf, i, token, token_len, 2048);
    2380     }
    2381     if(nodes_len > 0) {
    2382         rc = snprintf(buf + i, 2048 - i, "5:nodes%d:", nodes_len);
    2383         INC(i, rc, 2048);
    2384         COPY(buf, i, nodes, nodes_len, 2048);
    2385     }
    2386     if(nodes6_len > 0) {
    2387          rc = snprintf(buf + i, 2048 - i, "6:nodes6%d:", nodes6_len);
    2388          INC(i, rc, 2048);
    2389          COPY(buf, i, nodes6, nodes6_len, 2048);
    23902390    }
    23912391
Note: See TracChangeset for help on using the changeset viewer.