diff options
-rw-r--r-- | src/dht/gnunet-service-dht_neighbours.c | 33 | ||||
-rw-r--r-- | src/dht/gnunet-service-dht_routing.c | 19 |
2 files changed, 45 insertions, 7 deletions
diff --git a/src/dht/gnunet-service-dht_neighbours.c b/src/dht/gnunet-service-dht_neighbours.c index 20bdc0ce4d..7f3a445888 100644 --- a/src/dht/gnunet-service-dht_neighbours.c +++ b/src/dht/gnunet-service-dht_neighbours.c @@ -49,6 +49,11 @@ #define LOG_TRAFFIC(kind,...) GNUNET_log_from (kind, "dht-traffic",__VA_ARGS__) /** + * Enable slow sanity checks to debug issues. + */ +#define SANITY_CHECKS 1 + +/** * How many buckets will we allow total. */ #define MAX_BUCKETS sizeof (struct GNUNET_HashCode) * 8 @@ -1746,6 +1751,20 @@ handle_dht_p2p_put (void *cls, /* extend 'put path' by sender */ if (0 != (options & GNUNET_DHT_RO_RECORD_ROUTE)) { +#if SANITY_CHECKS + for (unsigned int i=0;i<=putlen;i++) + { + for (unsigned int j=0;j<i;j++) + { + GNUNET_break (0 != memcmp (&pp[i], + &pp[j], + sizeof (struct GNUNET_PeerIdentity))); + } + GNUNET_break (0 != memcmp (&pp[i], + peer->id, + sizeof (struct GNUNET_PeerIdentity))); + } +#endif GNUNET_memcpy (pp, put_path, putlen * sizeof (struct GNUNET_PeerIdentity)); @@ -2280,6 +2299,20 @@ handle_dht_p2p_result (void *cls, { struct GNUNET_PeerIdentity xget_path[get_path_length + 1]; +#if SANITY_CHECKS + for (unsigned int i=0;i<=get_path_length;i++) + { + for (unsigned int j=0;j<i;j++) + { + GNUNET_break (0 != memcmp (&get_path[i], + &get_path[j], + sizeof (struct GNUNET_PeerIdentity))); + } + GNUNET_break (0 != memcmp (&get_path[i], + peer->id, + sizeof (struct GNUNET_PeerIdentity))); + } +#endif GNUNET_memcpy (xget_path, get_path, get_path_length * sizeof (struct GNUNET_PeerIdentity)); diff --git a/src/dht/gnunet-service-dht_routing.c b/src/dht/gnunet-service-dht_routing.c index 978c46d73a..71240a5035 100644 --- a/src/dht/gnunet-service-dht_routing.c +++ b/src/dht/gnunet-service-dht_routing.c @@ -128,17 +128,17 @@ struct ProcessContext struct GNUNET_TIME_Absolute expiration_time; /** - * Number of entries in 'put_path'. + * Number of entries in @e put_path. */ unsigned int put_path_length; /** - * Number of entries in 'get_path'. + * Number of entries in @e get_path. */ unsigned int get_path_length; /** - * Number of bytes in 'data'. + * Number of bytes in @e data. */ size_t data_size; @@ -223,8 +223,13 @@ process (void *cls, gettext_noop ("# Good REPLIES matched against routing table"), 1, GNUNET_NO); - GDS_NEIGHBOURS_handle_reply (&rr->peer, pc->type, pc->expiration_time, key, - ppl, pc->put_path, gpl, pc->get_path, pc->data, + GDS_NEIGHBOURS_handle_reply (&rr->peer, + pc->type, + pc->expiration_time, + key, + ppl, pc->put_path, + gpl, pc->get_path, + pc->data, pc->data_size); break; case GNUNET_BLOCK_EVALUATION_OK_DUPLICATE: @@ -275,9 +280,9 @@ process (void *cls, * @param type type of the block * @param expiration_time when does the content expire * @param key key for the content - * @param put_path_length number of entries in put_path + * @param put_path_length number of entries in @a put_path * @param put_path peers the original PUT traversed (if tracked) - * @param get_path_length number of entries in get_path + * @param get_path_length number of entries in @a get_path * @param get_path peers this reply has traversed so far (if tracked) * @param data payload of the reply * @param data_size number of bytes in data |