aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/dht/dht_api.c2
-rw-r--r--src/dht/dht_api_get_put.c3
-rw-r--r--src/dht/gnunet-dht-driver.c33
-rw-r--r--src/dht/gnunet-service-dht.c6
-rw-r--r--src/dht/plugin_dhtlog_mysql.c15
-rw-r--r--src/dht/plugin_dhtlog_mysql_dump.c5
6 files changed, 33 insertions, 31 deletions
diff --git a/src/dht/dht_api.c b/src/dht/dht_api.c
index 68e662269..285ec1a30 100644
--- a/src/dht/dht_api.c
+++ b/src/dht/dht_api.c
@@ -555,7 +555,7 @@ void
555GNUNET_DHT_disconnect (struct GNUNET_DHT_Handle *handle) 555GNUNET_DHT_disconnect (struct GNUNET_DHT_Handle *handle)
556{ 556{
557 struct PendingMessage *pm; 557 struct PendingMessage *pm;
558 558 GNUNET_assert(handle != NULL);
559 GNUNET_assert (0 == GNUNET_CONTAINER_multihashmap_size(handle->active_requests)); 559 GNUNET_assert (0 == GNUNET_CONTAINER_multihashmap_size(handle->active_requests));
560 if (handle->th != NULL) 560 if (handle->th != NULL)
561 { 561 {
diff --git a/src/dht/dht_api_get_put.c b/src/dht/dht_api_get_put.c
index c6cd2c57a..98ee8d822 100644
--- a/src/dht/dht_api_get_put.c
+++ b/src/dht/dht_api_get_put.c
@@ -247,6 +247,9 @@ GNUNET_DHT_get_start (struct GNUNET_DHT_Handle *handle,
247 * Stop async DHT-get. 247 * Stop async DHT-get.
248 * 248 *
249 * @param get_handle handle to the GET operation to stop 249 * @param get_handle handle to the GET operation to stop
250 *
251 * On return get_handle will no longer be valid, caller
252 * must not use again!!!
250 */ 253 */
251void 254void
252GNUNET_DHT_get_stop (struct GNUNET_DHT_GetHandle *get_handle) 255GNUNET_DHT_get_stop (struct GNUNET_DHT_GetHandle *get_handle)
diff --git a/src/dht/gnunet-dht-driver.c b/src/dht/gnunet-dht-driver.c
index 1e238c620..39e5eec72 100644
--- a/src/dht/gnunet-dht-driver.c
+++ b/src/dht/gnunet-dht-driver.c
@@ -414,8 +414,6 @@ static struct GNUNET_TIME_Relative malicious_put_frequency;
414 414
415static unsigned long long settle_time; 415static unsigned long long settle_time;
416 416
417static unsigned long long trial_to_run;
418
419static struct GNUNET_DHTLOG_Handle *dhtlog_handle; 417static struct GNUNET_DHTLOG_Handle *dhtlog_handle;
420 418
421static unsigned long long trialuid; 419static unsigned long long trialuid;
@@ -466,7 +464,7 @@ static unsigned int *churn_array;
466/** 464/**
467 * Hash map of stats contexts. 465 * Hash map of stats contexts.
468 */ 466 */
469struct GNUNET_CONTAINER_MultiHashMap *stats_map; 467static struct GNUNET_CONTAINER_MultiHashMap *stats_map;
470 468
471/** 469/**
472 * LL of malicious settings. 470 * LL of malicious settings.
@@ -507,7 +505,7 @@ static struct GNUNET_TESTING_PeerGroup *pg;
507/** 505/**
508 * Global config handle. 506 * Global config handle.
509 */ 507 */
510const struct GNUNET_CONFIGURATION_Handle *config; 508static const struct GNUNET_CONFIGURATION_Handle *config;
511 509
512/** 510/**
513 * Total number of peers to run, set based on config file. 511 * Total number of peers to run, set based on config file.
@@ -693,8 +691,8 @@ reset_meter(struct ProgressMeter *meter)
693static void 691static void
694free_meter(struct ProgressMeter *meter) 692free_meter(struct ProgressMeter *meter)
695{ 693{
696 GNUNET_free_non_null(meter->startup_string); 694 GNUNET_free_non_null (meter->startup_string);
697 GNUNET_free_non_null(meter); 695 GNUNET_free (meter);
698} 696}
699 697
700/** 698/**
@@ -1125,6 +1123,7 @@ static void add_new_connection(struct FindPeerContext *find_peer_context,
1125 if (GNUNET_CONTAINER_multihashmap_contains(find_peer_context->peer_hash, &first->hashPubKey)) 1123 if (GNUNET_CONTAINER_multihashmap_contains(find_peer_context->peer_hash, &first->hashPubKey))
1126 { 1124 {
1127 first_count = GNUNET_CONTAINER_multihashmap_get(find_peer_context->peer_hash, &first->hashPubKey); 1125 first_count = GNUNET_CONTAINER_multihashmap_get(find_peer_context->peer_hash, &first->hashPubKey);
1126 GNUNET_assert(first_count != NULL);
1128 first_count->count++; 1127 first_count->count++;
1129 GNUNET_CONTAINER_heap_update_cost(find_peer_context->peer_min_heap, first_count->heap_node, first_count->count); 1128 GNUNET_CONTAINER_heap_update_cost(find_peer_context->peer_min_heap, first_count->heap_node, first_count->count);
1130 } 1129 }
@@ -1140,6 +1139,7 @@ static void add_new_connection(struct FindPeerContext *find_peer_context,
1140 if (GNUNET_CONTAINER_multihashmap_contains(find_peer_context->peer_hash, &second->hashPubKey)) 1139 if (GNUNET_CONTAINER_multihashmap_contains(find_peer_context->peer_hash, &second->hashPubKey))
1141 { 1140 {
1142 second_count = GNUNET_CONTAINER_multihashmap_get(find_peer_context->peer_hash, &second->hashPubKey); 1141 second_count = GNUNET_CONTAINER_multihashmap_get(find_peer_context->peer_hash, &second->hashPubKey);
1142 GNUNET_assert(second_count != NULL);
1143 second_count->count++; 1143 second_count->count++;
1144 GNUNET_CONTAINER_heap_update_cost(find_peer_context->peer_min_heap, second_count->heap_node, second_count->count); 1144 GNUNET_CONTAINER_heap_update_cost(find_peer_context->peer_min_heap, second_count->heap_node, second_count->count);
1145 } 1145 }
@@ -1179,10 +1179,12 @@ static int iterate_min_heap_peers (void *cls,
1179 if (cost == 0) 1179 if (cost == 0)
1180 { 1180 {
1181 d1 = GNUNET_TESTING_daemon_get_by_id (pg, &peer_count->peer_id); 1181 d1 = GNUNET_TESTING_daemon_get_by_id (pg, &peer_count->peer_id);
1182 GNUNET_assert(d1 != NULL);
1182 d2 = d1; 1183 d2 = d1;
1183 while ((d2 == d1) || (GNUNET_YES != GNUNET_TESTING_daemon_running(d2))) 1184 while ((d2 == d1) || (GNUNET_YES != GNUNET_TESTING_daemon_running(d2)))
1184 { 1185 {
1185 d2 = GNUNET_TESTING_daemon_get(pg, GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_WEAK, num_peers)); 1186 d2 = GNUNET_TESTING_daemon_get(pg, GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_WEAK, num_peers));
1187 GNUNET_assert(d2 != NULL);
1186 } 1188 }
1187 1189
1188 /** Just try to connect the peers, don't worry about callbacks, etc. **/ 1190 /** Just try to connect the peers, don't worry about callbacks, etc. **/
@@ -1233,7 +1235,7 @@ count_peers_churn_cb (void *cls,
1233 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Peer count finished (%u connections)\n", 1235 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Peer count finished (%u connections)\n",
1234 find_peer_context->current_peers); 1236 find_peer_context->current_peers);
1235 peer_count = GNUNET_CONTAINER_heap_peek(find_peer_context->peer_min_heap); 1237 peer_count = GNUNET_CONTAINER_heap_peek(find_peer_context->peer_min_heap);
1236 1238 GNUNET_assert(peer_count != NULL);
1237 /* WAIT. When peers are churned they will come back with their peers (at least in peerinfo), because the HOSTS file doesn't likely get removed. CRAP. */ 1239 /* WAIT. When peers are churned they will come back with their peers (at least in peerinfo), because the HOSTS file doesn't likely get removed. CRAP. */
1238 /* NO they won't, because we have disabled peerinfo writing to disk (remember?) so we WILL have to give them new connections */ 1240 /* NO they won't, because we have disabled peerinfo writing to disk (remember?) so we WILL have to give them new connections */
1239 /* Best course of action: have DHT automatically try to add peers from peerinfo on startup. This way IF peerinfo writes to file 1241 /* Best course of action: have DHT automatically try to add peers from peerinfo on startup. This way IF peerinfo writes to file
@@ -1363,6 +1365,7 @@ schedule_churn_find_peer_requests (void *cls, const struct GNUNET_SCHEDULER_Task
1363 test_find_peer = GNUNET_malloc(sizeof(struct TestFindPeer)); 1365 test_find_peer = GNUNET_malloc(sizeof(struct TestFindPeer));
1364 /* If we have sent requests, choose peers with a low number of connections to send requests from */ 1366 /* If we have sent requests, choose peers with a low number of connections to send requests from */
1365 peer_count = GNUNET_CONTAINER_heap_remove_root(find_peer_ctx->peer_min_heap); 1367 peer_count = GNUNET_CONTAINER_heap_remove_root(find_peer_ctx->peer_min_heap);
1368 GNUNET_assert(peer_count != NULL);
1366 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Sending find peer request from peer with %u connections\n", peer_count->count); 1369 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Sending find peer request from peer with %u connections\n", peer_count->count);
1367 GNUNET_CONTAINER_multihashmap_remove(find_peer_ctx->peer_hash, &peer_count->peer_id.hashPubKey, peer_count); 1370 GNUNET_CONTAINER_multihashmap_remove(find_peer_ctx->peer_hash, &peer_count->peer_id.hashPubKey, peer_count);
1368 test_find_peer->daemon = GNUNET_TESTING_daemon_get_by_id(pg, &peer_count->peer_id); 1371 test_find_peer->daemon = GNUNET_TESTING_daemon_get_by_id(pg, &peer_count->peer_id);
@@ -1902,10 +1905,10 @@ count_peers_cb (void *cls,
1902 connection_estimate(num_peers, DEFAULT_BUCKET_SIZE), 1905 connection_estimate(num_peers, DEFAULT_BUCKET_SIZE),
1903 2 * connection_estimate(num_peers, DEFAULT_BUCKET_SIZE)); 1906 2 * connection_estimate(num_peers, DEFAULT_BUCKET_SIZE));
1904 1907
1905 if ((find_peer_context->last_sent > 8) && 1908 if ((find_peer_context->last_sent < 8) ||
1906 (find_peer_context->current_peers - find_peer_context->previous_peers > FIND_PEER_THRESHOLD) && 1909 ((find_peer_context->current_peers - find_peer_context->previous_peers > FIND_PEER_THRESHOLD) &&
1907 (find_peer_context->current_peers < 2 * connection_estimate(num_peers, DEFAULT_BUCKET_SIZE)) && 1910 (find_peer_context->current_peers < 2 * connection_estimate(num_peers, DEFAULT_BUCKET_SIZE)) &&
1908 (GNUNET_TIME_absolute_get_remaining(find_peer_context->endtime).rel_value > 0)) 1911 (GNUNET_TIME_absolute_get_remaining(find_peer_context->endtime).rel_value > 0)))
1909 { 1912 {
1910 GNUNET_SCHEDULER_add_now(&schedule_find_peer_requests, find_peer_context); 1913 GNUNET_SCHEDULER_add_now(&schedule_find_peer_requests, find_peer_context);
1911 } 1914 }
@@ -2469,6 +2472,7 @@ run (void *cls,
2469 char *hostfile; 2472 char *hostfile;
2470 float topology_probability; 2473 float topology_probability;
2471 unsigned long long temp_config_number; 2474 unsigned long long temp_config_number;
2475 unsigned long long trial_to_run;
2472 int stop_closest; 2476 int stop_closest;
2473 int stop_found; 2477 int stop_found;
2474 int strict_kademlia; 2478 int strict_kademlia;
@@ -2480,6 +2484,7 @@ run (void *cls,
2480 int ret; 2484 int ret;
2481 int line_number; 2485 int line_number;
2482 2486
2487
2483 config = cfg; 2488 config = cfg;
2484 rounds_finished = 0; 2489 rounds_finished = 0;
2485 memset(&trial_info, 0, sizeof(struct GNUNET_DHTLOG_TrialInfo)); 2490 memset(&trial_info, 0, sizeof(struct GNUNET_DHTLOG_TrialInfo));
@@ -2533,6 +2538,8 @@ run (void *cls,
2533 if (GNUNET_OK != GNUNET_DISK_file_test (churn_filename)) 2538 if (GNUNET_OK != GNUNET_DISK_file_test (churn_filename))
2534 { 2539 {
2535 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Error reading churn file!\n"); 2540 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Error reading churn file!\n");
2541 GNUNET_free_non_null(trialmessage);
2542 GNUNET_free(churn_filename);
2536 return; 2543 return;
2537 } 2544 }
2538 if ((0 != STAT (churn_filename, &frstat)) || (frstat.st_size == 0)) 2545 if ((0 != STAT (churn_filename, &frstat)) || (frstat.st_size == 0))
@@ -2571,10 +2578,10 @@ run (void *cls,
2571 churn_data[count] = '\0'; 2578 churn_data[count] = '\0';
2572 if (1 != sscanf(buf, "%u", &churn_rounds)) 2579 if (1 != sscanf(buf, "%u", &churn_rounds))
2573 { 2580 {
2574 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Failed to read number of rounds from %s, ending test!\n", churn_filename); 2581 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Failed to read number of rounds from churn file, ending test!\n");
2575 GNUNET_free_non_null(trialmessage);
2576 GNUNET_free(churn_filename);
2577 ret = 4200; 2582 ret = 4200;
2583 GNUNET_free_non_null(trialmessage);
2584 GNUNET_free_non_null(churn_data);
2578 return; 2585 return;
2579 } 2586 }
2580 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Read %u rounds from churn file\n", churn_rounds); 2587 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Read %u rounds from churn file\n", churn_rounds);
diff --git a/src/dht/gnunet-service-dht.c b/src/dht/gnunet-service-dht.c
index d74309e21..ae57c0ea7 100644
--- a/src/dht/gnunet-service-dht.c
+++ b/src/dht/gnunet-service-dht.c
@@ -1672,7 +1672,7 @@ static void forward_message (const struct GNUNET_MessageHeader *msg,
1672 size_t psize; 1672 size_t psize;
1673 1673
1674 increment_stats(STAT_ROUTE_FORWARDS); 1674 increment_stats(STAT_ROUTE_FORWARDS);
1675 1675 GNUNET_assert(peer != NULL);
1676 if ((msg_ctx->closest != GNUNET_YES) && (peer == find_closest_peer(&msg_ctx->key))) 1676 if ((msg_ctx->closest != GNUNET_YES) && (peer == find_closest_peer(&msg_ctx->key)))
1677 increment_stats(STAT_ROUTE_FORWARDS_CLOSEST); 1677 increment_stats(STAT_ROUTE_FORWARDS_CLOSEST);
1678 1678
@@ -2434,6 +2434,7 @@ handle_dht_find_peer (const struct GNUNET_MessageHeader *find_msg,
2434 else /* We don't want this peer! */ 2434 else /* We don't want this peer! */
2435 { 2435 {
2436 route_message (find_msg, message_context); 2436 route_message (find_msg, message_context);
2437 GNUNET_free (other_hello);
2437 return; 2438 return;
2438 } 2439 }
2439#endif 2440#endif
@@ -2512,6 +2513,7 @@ handle_dht_find_peer (const struct GNUNET_MessageHeader *find_msg,
2512 } 2513 }
2513 else 2514 else
2514 { 2515 {
2516 GNUNET_free(recent_hash);
2515 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Received duplicate find peer request too soon!\n"); 2517 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Received duplicate find peer request too soon!\n");
2516 } 2518 }
2517 2519
@@ -3912,7 +3914,6 @@ malicious_get_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
3912 get_message.header.type = htons(GNUNET_MESSAGE_TYPE_DHT_GET); 3914 get_message.header.type = htons(GNUNET_MESSAGE_TYPE_DHT_GET);
3913 get_message.type = htonl(GNUNET_BLOCK_DHT_MALICIOUS_MESSAGE_TYPE); 3915 get_message.type = htonl(GNUNET_BLOCK_DHT_MALICIOUS_MESSAGE_TYPE);
3914 memset(&message_context, 0, sizeof(struct DHT_MessageContext)); 3916 memset(&message_context, 0, sizeof(struct DHT_MessageContext));
3915 message_context.client = NULL;
3916 random_key = GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_WEAK, (uint32_t)-1); 3917 random_key = GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_WEAK, (uint32_t)-1);
3917 GNUNET_CRYPTO_hash(&random_key, sizeof(uint32_t), &key); 3918 GNUNET_CRYPTO_hash(&random_key, sizeof(uint32_t), &key);
3918 memcpy(&message_context.key, &key, sizeof(GNUNET_HashCode)); 3919 memcpy(&message_context.key, &key, sizeof(GNUNET_HashCode));
@@ -4539,6 +4540,7 @@ void handle_core_disconnect (void *cls,
4539 increment_stats(STAT_DISCONNECTS); 4540 increment_stats(STAT_DISCONNECTS);
4540 GNUNET_assert(GNUNET_CONTAINER_multihashmap_contains(all_known_peers, &peer->hashPubKey)); 4541 GNUNET_assert(GNUNET_CONTAINER_multihashmap_contains(all_known_peers, &peer->hashPubKey));
4541 to_remove = GNUNET_CONTAINER_multihashmap_get(all_known_peers, &peer->hashPubKey); 4542 to_remove = GNUNET_CONTAINER_multihashmap_get(all_known_peers, &peer->hashPubKey);
4543 GNUNET_assert (to_remove != NULL);
4542 GNUNET_assert(0 == memcmp(peer, &to_remove->id, sizeof(struct GNUNET_PeerIdentity))); 4544 GNUNET_assert(0 == memcmp(peer, &to_remove->id, sizeof(struct GNUNET_PeerIdentity)));
4543 current_bucket = find_current_bucket(&to_remove->id.hashPubKey); 4545 current_bucket = find_current_bucket(&to_remove->id.hashPubKey);
4544 delete_peer(to_remove, current_bucket); 4546 delete_peer(to_remove, current_bucket);
diff --git a/src/dht/plugin_dhtlog_mysql.c b/src/dht/plugin_dhtlog_mysql.c
index b31a41f4c..127db015d 100644
--- a/src/dht/plugin_dhtlog_mysql.c
+++ b/src/dht/plugin_dhtlog_mysql.c
@@ -1356,8 +1356,6 @@ add_route (unsigned long long *sqlqueryuid, unsigned long long queryid,
1356 1356
1357 if (from_node != NULL) 1357 if (from_node != NULL)
1358 get_node_uid (&from_uid, &from_node->hashPubKey); 1358 get_node_uid (&from_uid, &from_node->hashPubKey);
1359 else
1360 from_uid = 0;
1361 1359
1362 if (to_node != NULL) 1360 if (to_node != NULL)
1363 get_node_uid (&to_uid, &to_node->hashPubKey); 1361 get_node_uid (&to_uid, &to_node->hashPubKey);
@@ -1456,9 +1454,8 @@ update_current_topology (unsigned int connections)
1456 } 1454 }
1457 if (ret > 0) 1455 if (ret > 0)
1458 return GNUNET_OK; 1456 return GNUNET_OK;
1459 else 1457 return GNUNET_SYSERR;
1460 return GNUNET_SYSERR; 1458
1461 return GNUNET_OK;
1462} 1459}
1463 1460
1464/* 1461/*
@@ -1487,9 +1484,7 @@ add_topology (int num_connections)
1487 } 1484 }
1488 if (ret > 0) 1485 if (ret > 0)
1489 return GNUNET_OK; 1486 return GNUNET_OK;
1490 else 1487 return GNUNET_SYSERR;
1491 return GNUNET_SYSERR;
1492 return GNUNET_OK;
1493} 1488}
1494 1489
1495/* 1490/*
@@ -1535,9 +1530,7 @@ add_extended_topology (const struct GNUNET_PeerIdentity *first, const struct GNU
1535 } 1530 }
1536 if (ret > 0) 1531 if (ret > 0)
1537 return GNUNET_OK; 1532 return GNUNET_OK;
1538 else 1533 return GNUNET_SYSERR;
1539 return GNUNET_SYSERR;
1540 return GNUNET_OK;
1541} 1534}
1542 1535
1543 1536
diff --git a/src/dht/plugin_dhtlog_mysql_dump.c b/src/dht/plugin_dhtlog_mysql_dump.c
index f8a2811b1..6b6133068 100644
--- a/src/dht/plugin_dhtlog_mysql_dump.c
+++ b/src/dht/plugin_dhtlog_mysql_dump.c
@@ -490,10 +490,7 @@ add_node (unsigned long long *nodeuid, struct GNUNET_PeerIdentity * node)
490 if (outfile == NULL) 490 if (outfile == NULL)
491 return GNUNET_SYSERR; 491 return GNUNET_SYSERR;
492 492
493 if (node != NULL) 493 ret = fprintf(outfile, "set @node = \"%s\";\n", GNUNET_h2s_full(&node->hashPubKey));
494 ret = fprintf(outfile, "set @node = \"%s\";\n", GNUNET_h2s_full(&node->hashPubKey));
495 else
496 return GNUNET_SYSERR;
497 494
498 if (ret < 0) 495 if (ret < 0)
499 return GNUNET_SYSERR; 496 return GNUNET_SYSERR;