gnunet-service-dht_routing.c | gnunet-service-dht_routing.c | |||
---|---|---|---|---|
skipping to change at line 225 | skipping to change at line 225 | |||
("# Duplicate REPLIES matched against routing table"), | ("# Duplicate REPLIES matched against routing table"), | |||
1, GNUNET_NO); | 1, GNUNET_NO); | |||
return GNUNET_OK; | return GNUNET_OK; | |||
case GNUNET_BLOCK_EVALUATION_RESULT_INVALID: | case GNUNET_BLOCK_EVALUATION_RESULT_INVALID: | |||
GNUNET_STATISTICS_update (GDS_stats, | GNUNET_STATISTICS_update (GDS_stats, | |||
gettext_noop | gettext_noop | |||
("# Invalid REPLIES matched against routing t able"), | ("# Invalid REPLIES matched against routing t able"), | |||
1, GNUNET_NO); | 1, GNUNET_NO); | |||
return GNUNET_SYSERR; | return GNUNET_SYSERR; | |||
case GNUNET_BLOCK_EVALUATION_REQUEST_VALID: | case GNUNET_BLOCK_EVALUATION_REQUEST_VALID: | |||
GNUNET_break (0); | ||||
return GNUNET_OK; | ||||
case GNUNET_BLOCK_EVALUATION_REQUEST_INVALID: | case GNUNET_BLOCK_EVALUATION_REQUEST_INVALID: | |||
GNUNET_break (0); | GNUNET_break (0); | |||
return GNUNET_OK; | return GNUNET_OK; | |||
case GNUNET_BLOCK_EVALUATION_TYPE_NOT_SUPPORTED: | case GNUNET_BLOCK_EVALUATION_TYPE_NOT_SUPPORTED: | |||
GNUNET_STATISTICS_update (GDS_stats, | GNUNET_STATISTICS_update (GDS_stats, | |||
gettext_noop | gettext_noop | |||
("# Unsupported REPLIES matched against routi ng table"), | ("# Unsupported REPLIES matched against routi ng table"), | |||
1, GNUNET_NO); | 1, GNUNET_NO); | |||
return GNUNET_SYSERR; | return GNUNET_SYSERR; | |||
default: | default: | |||
skipping to change at line 277 | skipping to change at line 279 | |||
struct ProcessContext pc; | struct ProcessContext pc; | |||
pc.type = type; | pc.type = type; | |||
pc.expiration_time = expiration_time; | pc.expiration_time = expiration_time; | |||
pc.put_path_length = put_path_length; | pc.put_path_length = put_path_length; | |||
pc.put_path = put_path; | pc.put_path = put_path; | |||
pc.get_path_length = get_path_length; | pc.get_path_length = get_path_length; | |||
pc.get_path = get_path; | pc.get_path = get_path; | |||
pc.data = data; | pc.data = data; | |||
pc.data_size = data_size; | pc.data_size = data_size; | |||
if (NULL == data) | ||||
{ | ||||
/* Some apps might have an 'empty' reply as a valid reply; however, | ||||
'process' will call GNUNET_BLOCK_evaluate' which treats a 'NULL' | ||||
reply as request-validation (but we need response-validation). | ||||
So we set 'data' to a 0-byte non-NULL value just to be sure */ | ||||
GNUNET_break (0 == data_size); | ||||
data_size = 0; | ||||
pc.data = ""; /* something not null */ | ||||
} | ||||
GNUNET_CONTAINER_multihashmap_get_multiple (recent_map, key, &process, &p c); | GNUNET_CONTAINER_multihashmap_get_multiple (recent_map, key, &process, &p c); | |||
} | } | |||
/** | /** | |||
* Remove the oldest entry from the DHT routing table. Must only | ||||
* be called if it is known that there is at least one entry | ||||
* in the heap and hashmap. | ||||
*/ | ||||
static void | ||||
expire_oldest_entry () | ||||
{ | ||||
struct RecentRequest *recent_req; | ||||
GNUNET_STATISTICS_update (GDS_stats, | ||||
gettext_noop | ||||
("# Entries removed from routing table"), 1, | ||||
GNUNET_NO); | ||||
recent_req = GNUNET_CONTAINER_heap_peek (recent_heap); | ||||
GNUNET_assert (recent_req != NULL); | ||||
GNUNET_CONTAINER_heap_remove_node (recent_req->heap_node); | ||||
GNUNET_CONTAINER_bloomfilter_free (recent_req->reply_bf); | ||||
GNUNET_assert (GNUNET_YES == | ||||
GNUNET_CONTAINER_multihashmap_remove (recent_map, | ||||
&recent_req->key, | ||||
recent_req)); | ||||
GNUNET_free (recent_req); | ||||
} | ||||
/** | ||||
* Add a new entry to our routing table. | * Add a new entry to our routing table. | |||
* | * | |||
* @param sender peer that originated the request | * @param sender peer that originated the request | |||
* @param type type of the block | * @param type type of the block | |||
* @param options options for processing | * @param options options for processing | |||
* @param key key for the content | * @param key key for the content | |||
* @param xquery extended query | * @param xquery extended query | |||
* @param xquery_size number of bytes in xquery | * @param xquery_size number of bytes in xquery | |||
* @param reply_bf bloomfilter to filter duplicates | * @param reply_bf bloomfilter to filter duplicates | |||
* @param reply_bf_mutator mutator for reply_bf | * @param reply_bf_mutator mutator for reply_bf | |||
skipping to change at line 304 | skipping to change at line 341 | |||
enum GNUNET_BLOCK_Type type, | enum GNUNET_BLOCK_Type type, | |||
enum GNUNET_DHT_RouteOption options, | enum GNUNET_DHT_RouteOption options, | |||
const GNUNET_HashCode * key, const void *xquery, | const GNUNET_HashCode * key, const void *xquery, | |||
size_t xquery_size, | size_t xquery_size, | |||
const struct GNUNET_CONTAINER_BloomFilter *reply_bf, | const struct GNUNET_CONTAINER_BloomFilter *reply_bf, | |||
uint32_t reply_bf_mutator) | uint32_t reply_bf_mutator) | |||
{ | { | |||
struct RecentRequest *recent_req; | struct RecentRequest *recent_req; | |||
while (GNUNET_CONTAINER_heap_get_size (recent_heap) >= DHT_MAX_RECENT) | while (GNUNET_CONTAINER_heap_get_size (recent_heap) >= DHT_MAX_RECENT) | |||
{ | expire_oldest_entry (); | |||
GNUNET_STATISTICS_update (GDS_stats, | ||||
gettext_noop | ||||
("# Entries removed from routing table"), 1, | ||||
GNUNET_NO); | ||||
recent_req = GNUNET_CONTAINER_heap_peek (recent_heap); | ||||
GNUNET_assert (recent_req != NULL); | ||||
GNUNET_CONTAINER_heap_remove_node (recent_req->heap_node); | ||||
GNUNET_CONTAINER_bloomfilter_free (recent_req->reply_bf); | ||||
GNUNET_free (recent_req); | ||||
} | ||||
GNUNET_STATISTICS_update (GDS_stats, | GNUNET_STATISTICS_update (GDS_stats, | |||
gettext_noop ("# Entries added to routing table "), | gettext_noop ("# Entries added to routing table "), | |||
1, GNUNET_NO); | 1, GNUNET_NO); | |||
recent_req = GNUNET_malloc (sizeof (struct RecentRequest) + xquery_size); | recent_req = GNUNET_malloc (sizeof (struct RecentRequest) + xquery_size); | |||
recent_req->peer = *sender; | recent_req->peer = *sender; | |||
recent_req->key = *key; | recent_req->key = *key; | |||
recent_req->heap_node = | recent_req->heap_node = | |||
GNUNET_CONTAINER_heap_insert (recent_heap, recent_req, | GNUNET_CONTAINER_heap_insert (recent_heap, recent_req, | |||
GNUNET_TIME_absolute_get ().abs_value); | GNUNET_TIME_absolute_get ().abs_value); | |||
recent_req->reply_bf = GNUNET_CONTAINER_bloomfilter_copy (reply_bf); | recent_req->reply_bf = GNUNET_CONTAINER_bloomfilter_copy (reply_bf); | |||
skipping to change at line 352 | skipping to change at line 378 | |||
recent_heap = GNUNET_CONTAINER_heap_create (GNUNET_CONTAINER_HEAP_ORDER_M IN); | recent_heap = GNUNET_CONTAINER_heap_create (GNUNET_CONTAINER_HEAP_ORDER_M IN); | |||
recent_map = GNUNET_CONTAINER_multihashmap_create (DHT_MAX_RECENT * 4 / 3 ); | recent_map = GNUNET_CONTAINER_multihashmap_create (DHT_MAX_RECENT * 4 / 3 ); | |||
} | } | |||
/** | /** | |||
* Shutdown routing subsystem. | * Shutdown routing subsystem. | |||
*/ | */ | |||
void | void | |||
GDS_ROUTING_done () | GDS_ROUTING_done () | |||
{ | { | |||
struct RecentRequest *recent_req; | ||||
while (GNUNET_CONTAINER_heap_get_size (recent_heap) > 0) | while (GNUNET_CONTAINER_heap_get_size (recent_heap) > 0) | |||
{ | expire_oldest_entry (); | |||
GNUNET_STATISTICS_update (GDS_stats, | ||||
gettext_noop | ||||
("# Entries removed from routing table"), 1, | ||||
GNUNET_NO); | ||||
recent_req = GNUNET_CONTAINER_heap_peek (recent_heap); | ||||
GNUNET_assert (recent_req != NULL); | ||||
GNUNET_CONTAINER_heap_remove_node (recent_req->heap_node); | ||||
GNUNET_CONTAINER_bloomfilter_free (recent_req->reply_bf); | ||||
GNUNET_free (recent_req); | ||||
} | ||||
GNUNET_assert (0 == GNUNET_CONTAINER_heap_get_size (recent_heap)); | GNUNET_assert (0 == GNUNET_CONTAINER_heap_get_size (recent_heap)); | |||
GNUNET_CONTAINER_heap_destroy (recent_heap); | GNUNET_CONTAINER_heap_destroy (recent_heap); | |||
recent_heap = NULL; | recent_heap = NULL; | |||
GNUNET_assert (0 == GNUNET_CONTAINER_multihashmap_size (recent_map)); | ||||
GNUNET_CONTAINER_multihashmap_destroy (recent_map); | GNUNET_CONTAINER_multihashmap_destroy (recent_map); | |||
recent_map = NULL; | recent_map = NULL; | |||
} | } | |||
/* end of gnunet-service-dht_routing.c */ | /* end of gnunet-service-dht_routing.c */ | |||
End of changes. 7 change blocks. | ||||
25 lines changed or deleted | 40 lines changed or added | |||
This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/ |