From 05186db103486d199c2dc9357264a265e9c33117 Mon Sep 17 00:00:00 2001 From: "Nathan S. Evans" Date: Wed, 1 Sep 2010 13:19:43 +0000 Subject: [PATCH] klocwork fixes, dht routing changes (hopefully fixes) --- src/dht/dht_api.c | 2 +- src/dht/gnunet-dht-driver.c | 4 +- src/dht/gnunet-service-dht.c | 68 +++++++++++++--- src/dht/plugin_dhtlog_mysql.c | 2 + src/dht/plugin_dhtlog_mysql_dump.c | 41 +++++++++- src/dht/plugin_dhtlog_mysql_dump_load.c | 100 ++++++++++++++++++++++-- src/dht/test_dhtlog.c | 15 ++++ 7 files changed, 209 insertions(+), 23 deletions(-) diff --git a/src/dht/dht_api.c b/src/dht/dht_api.c index ca1aa0d4b..5d17e996e 100644 --- a/src/dht/dht_api.c +++ b/src/dht/dht_api.c @@ -1087,7 +1087,7 @@ GNUNET_DHT_route_start (struct GNUNET_DHT_Handle *handle, message->header.type = htons (GNUNET_MESSAGE_TYPE_DHT_LOCAL_ROUTE); memcpy (&message->key, key, sizeof (GNUNET_HashCode)); message->options = htonl (options); - message->desired_replication_level = htonl (options); + message->desired_replication_level = htonl (desired_replication_level); message->unique_id = GNUNET_htonll (route_handle->uid); memcpy (&message[1], enc, ntohs (enc->size)); pending = GNUNET_malloc (sizeof (struct PendingMessage)); diff --git a/src/dht/gnunet-dht-driver.c b/src/dht/gnunet-dht-driver.c index 174ea9e94..623a7b533 100644 --- a/src/dht/gnunet-dht-driver.c +++ b/src/dht/gnunet-dht-driver.c @@ -51,7 +51,7 @@ #define DEFAULT_PUT_DELAY GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 10) /* Timeout for waiting for puts to be sent to the service */ -#define DEFAULT_FIND_PEER_DELAY GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 40) +#define DEFAULT_FIND_PEER_DELAY GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 90) #define DEFAULT_SECONDS_PER_PEER_START GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 45) @@ -63,7 +63,7 @@ #define DEFAULT_MAX_OUTSTANDING_PUTS 10 -#define DEFAULT_MAX_OUTSTANDING_FIND_PEERS 10 +#define DEFAULT_MAX_OUTSTANDING_FIND_PEERS 5 #define DEFAULT_FIND_PEER_OFFSET GNUNET_TIME_relative_divide (DEFAULT_FIND_PEER_DELAY, DEFAULT_MAX_OUTSTANDING_FIND_PEERS) diff --git a/src/dht/gnunet-service-dht.c b/src/dht/gnunet-service-dht.c index 958b1d8b2..f2379d72c 100644 --- a/src/dht/gnunet-service-dht.c +++ b/src/dht/gnunet-service-dht.c @@ -99,7 +99,7 @@ /** * Default replication parameter for find peer messages sent by the dht service. */ -#define DHT_DEFAULT_FIND_PEER_REPLICATION 1 +#define DHT_DEFAULT_FIND_PEER_REPLICATION 2 /** * Default options for find peer requests sent by the dht service. @@ -153,7 +153,7 @@ * Real maximum number of hops, at which point we refuse * to forward the message. */ -#define MAX_HOPS 20 +#define MAX_HOPS 10 /** * How many time differences between requesting a core send and @@ -198,7 +198,6 @@ struct P2PPendingMessage }; - /** * Per-peer information. */ @@ -2119,7 +2118,10 @@ static void remove_recent_find_peer(void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { GNUNET_HashCode *key = cls; - GNUNET_CONTAINER_multihashmap_remove(recent_find_peer_requests, key, key); + if (GNUNET_YES == GNUNET_CONTAINER_multihashmap_remove(recent_find_peer_requests, key, key)) + { + GNUNET_free(key); + } } /** @@ -2142,6 +2144,9 @@ handle_dht_find_peer (void *cls, size_t hello_size; size_t tsize; GNUNET_HashCode *recent_hash; +#if RESTRICT_FIND_PEER + struct GNUNET_PeerIdentity peer_id; +#endif find_peer_message = (struct GNUNET_DHT_FindPeerMessage *)find_msg; #if DEBUG_DHT @@ -2175,10 +2180,28 @@ handle_dht_find_peer (void *cls, increment_stats("# dht find peer requests ignored (recently seen!)"); return; } + +#if RESTRICT_FIND_PEER + /** + * Use this check to only allow the peer to respond to find peer requests if + * it would be beneficial to have the requesting peer in this peers routing + * table. Can be used to thwart peers flooding the network with find peer + * requests that we don't care about. However, if a new peer is joining + * the network and has no other peers this is a problem (assume all buckets + * full, no one will respond!). + */ + memcpy(&peer_id.hashPubKey, &message_context->key, sizeof(GNUNET_HashCode)); + if (GNUNET_NO == consider_peer(&peer_id)) + { + increment_stats("# dht find peer requests ignored (do not need!)"); + return; + } +#endif + recent_hash = GNUNET_malloc(sizeof(GNUNET_HashCode)); memcpy(recent_hash, &message_context->key, sizeof(GNUNET_HashCode)); GNUNET_CONTAINER_multihashmap_put (recent_find_peer_requests, &message_context->key, NULL, GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY); - GNUNET_SCHEDULER_add_delayed (sched, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 30), &remove_recent_find_peer, &message_context->key); + GNUNET_SCHEDULER_add_delayed (sched, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 120), &remove_recent_find_peer, &recent_hash); /* Simplistic find_peer functionality, always return our hello */ hello_size = ntohs(my_hello->size); @@ -2325,7 +2348,12 @@ static unsigned int estimate_diameter() static unsigned int get_forward_count (unsigned int hop_count, size_t target_replication) { +#if DOUBLE double target_count; + double random_probability; +#else + uint32_t random_value; +#endif unsigned int target_value; unsigned int diameter; @@ -2366,17 +2394,35 @@ get_forward_count (unsigned int hop_count, size_t target_replication) #endif return 0; } + +#if DOUBLE + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Replication %d, hop_count %u, diameter %u\n", target_replication, hop_count, diameter); + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Numerator %f, denominator %f\n", (double)target_replication, ((double)target_replication * (hop_count + 1) + diameter)); target_count = /* target_count is ALWAYS < 1 unless replication is < 1 */ (double)target_replication / ((double)target_replication * (hop_count + 1) + diameter); + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Target count is %f\n", target_count); + random_probability = ((double)GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, + RAND_MAX)) / RAND_MAX; + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Random is %f\n", random_probability); target_value = 0; - while (target_value < target_count) + //while (target_value < target_count) + if (target_value < target_count) target_value++; /* target_value is ALWAYS 1 after this "loop", right? Because target_count is always > 0, right? Or does it become 0.00000... at some point because the hop count is so high? */ - if ((target_count + 1 - target_value) > - GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, - RAND_MAX) / RAND_MAX) + + //if ((target_count + 1 - (double)target_value) > random_probability) + if ((target_count) > random_probability) target_value++; +#endif + + random_value = GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_WEAK, target_replication * (hop_count + 1) + diameter) + 1; + GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "replication %u, at hop %d, will split with probability %f\n", target_replication, hop_count, target_replication / (double)((target_replication * (hop_count + 1) + diameter) + 1)); + target_value = 1; + GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "random %u, target %u, max %u\n", random_value, target_replication, target_replication * (hop_count + 1) + diameter); + if (random_value < target_replication) + target_value++; + return target_value; } @@ -2776,10 +2822,9 @@ static int route_message(void *cls, if (message_context->bloom == NULL) message_context->bloom = GNUNET_CONTAINER_bloomfilter_init (NULL, DHT_BLOOM_SIZE, DHT_BLOOM_K); - if ((stop_on_closest == GNUNET_YES) && (message_context->closest == GNUNET_YES) && (ntohs(msg->type) == GNUNET_MESSAGE_TYPE_DHT_PUT)) + if ((stop_on_closest == GNUNET_YES) && (global_closest == GNUNET_YES) && (ntohs(msg->type) == GNUNET_MESSAGE_TYPE_DHT_PUT)) forward_count = 0; - #if DEBUG_DHT_ROUTING if (forward_count == 0) ret = GNUNET_SYSERR; @@ -2804,6 +2849,7 @@ static int route_message(void *cls, break; case GNUNET_MESSAGE_TYPE_DHT_PUT: /* Check if closest, if so insert data. FIXME: thresholding to reduce complexity?*/ increment_stats(STAT_PUTS); + message_context->closest = global_closest; handle_dht_put (cls, msg, message_context); break; case GNUNET_MESSAGE_TYPE_DHT_FIND_PEER: /* Check if closest and not started by us, check options, add to requests seen */ diff --git a/src/dht/plugin_dhtlog_mysql.c b/src/dht/plugin_dhtlog_mysql.c index 3c74dc1fc..32eb07853 100644 --- a/src/dht/plugin_dhtlog_mysql.c +++ b/src/dht/plugin_dhtlog_mysql.c @@ -1061,6 +1061,8 @@ add_dhtkey (unsigned long long *dhtkeyuid, const GNUNET_HashCode * dhtkey) *dhtkeyuid = curr_dhtkeyuid; return GNUNET_OK; } + else if (ret == GNUNET_SYSERR) + return GNUNET_SYSERR; if (GNUNET_OK != (ret = prepared_statement_run (insert_dhtkey, diff --git a/src/dht/plugin_dhtlog_mysql_dump.c b/src/dht/plugin_dhtlog_mysql_dump.c index 1965d1c80..21ddc238e 100644 --- a/src/dht/plugin_dhtlog_mysql_dump.c +++ b/src/dht/plugin_dhtlog_mysql_dump.c @@ -203,6 +203,8 @@ add_topology (int num_connections) return GNUNET_SYSERR; ret = fprintf(outfile, "execute insert_topology using " "@date, @num;\n"); + if (ret < 0) + return GNUNET_SYSERR; ret = fprintf(outfile, "execute select_topology;\n"); @@ -324,7 +326,8 @@ int add_trial (unsigned long long *trialuid, unsigned int num_nodes, unsigned in "@m_gets, @m_puts, @m_drops," "@m_g_f, @m_p_f, @s_c, @s_f," "@s_k, @g_s, @message;\n"); - + if (ret < 0) + return GNUNET_SYSERR; ret = fprintf(outfile, "execute select_trial;\n"); if (ret >= 0) @@ -357,6 +360,9 @@ add_generic_stat (const struct GNUNET_PeerIdentity *peer, else ret = fprintf(outfile, "set @temp_node = 0;\n"); + if (ret < 0) + return GNUNET_SYSERR; + ret = fprintf(outfile, "set @temp_section = \"%s\", @temp_stat = \"%s\", @temp_value = %llu;\n", section, name, (unsigned long long)value); @@ -365,6 +371,8 @@ add_generic_stat (const struct GNUNET_PeerIdentity *peer, ret = fprintf(outfile, "execute insert_generic_stat;\n"); + if (ret < 0) + return GNUNET_SYSERR; return GNUNET_OK; } @@ -411,6 +419,8 @@ add_stat (const struct GNUNET_PeerIdentity *peer, unsigned int route_requests, ret = fprintf(outfile, "select nodeuid from nodes where trialuid = @temp_trial and nodeid = \"%s\" into @temp_node;\n", GNUNET_h2s_full(&peer->hashPubKey)); else ret = fprintf(outfile, "set @temp_node = 0;\n"); + if (ret < 0) + return GNUNET_SYSERR; ret = fprintf(outfile, "set @r_r = %u, @r_f = %u, @res_r = %u, @c_r = %u, " "@res_f = %u, @gets = %u, @puts = %u, @d_i = %u, " @@ -431,7 +441,8 @@ add_stat (const struct GNUNET_PeerIdentity *peer, unsigned int route_requests, "@res_f, @gets, @puts, @d_i, " "@f_p_r, @f_p_s, @g_s, @p_s, " "@f_p_r_r, @g_r_r, @f_p_r_s, @g_r_s;\n"); - + if (ret < 0) + return GNUNET_SYSERR; return GNUNET_OK; } /* @@ -663,11 +674,17 @@ add_query (unsigned long long *sqlqueryuid, unsigned long long queryid, else ret = fprintf(outfile, "set @temp_dhtkey = 0;\n"); + if (ret < 0) + return GNUNET_SYSERR; + if (node != NULL) ret = fprintf(outfile, "select nodeuid from nodes where trialuid = @temp_trial and nodeid = \"%s\" into @temp_node;\n", GNUNET_h2s_full(&node->hashPubKey)); else ret = fprintf(outfile, "set @temp_node = 0;\n"); + if (ret < 0) + return GNUNET_SYSERR; + ret = fprintf(outfile, "set @qid = %llu, @type = %u, @hops = %u, @succ = %d;\n", queryid, type, hops, succeeded); if (ret < 0) @@ -716,21 +733,33 @@ add_route (unsigned long long *sqlqueryuid, unsigned long long queryid, else ret = fprintf(outfile, "set @temp_dhtkey = 0;\n"); + if (ret < 0) + return GNUNET_SYSERR; + if (node != NULL) ret = fprintf(outfile, "select nodeuid from nodes where trialuid = @temp_trial and nodeid = \"%s\" into @temp_node;\n", GNUNET_h2s_full(&node->hashPubKey)); else ret = fprintf(outfile, "set @temp_node = 0;\n"); + if (ret < 0) + return GNUNET_SYSERR; + if (from_node != NULL) ret = fprintf(outfile, "select nodeuid from nodes where trialuid = @temp_trial and nodeid = \"%s\" into @temp_from_node;\n", GNUNET_h2s_full(&from_node->hashPubKey)); else ret = fprintf(outfile, "set @temp_from_node = 0;\n"); + if (ret < 0) + return GNUNET_SYSERR; + if (to_node != NULL) ret = fprintf(outfile, "select nodeuid from nodes where trialuid = @temp_trial and nodeid = \"%s\" into @temp_to_node;\n", GNUNET_h2s_full(&to_node->hashPubKey)); else ret = fprintf(outfile, "set @temp_to_node = 0;\n"); + if (ret < 0) + return GNUNET_SYSERR; + ret = fprintf(outfile, "set @qid = %llu, @type = %u, @hops = %u, @succ = %d;\n", queryid, type, hops, succeeded); if (ret < 0) @@ -780,6 +809,14 @@ libgnunet_plugin_dhtlog_mysql_dump_init (void * cls) fn = GNUNET_STRINGS_filename_expand (outfile_name); + if (fn == NULL) + { + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, _("Failed to get full path for `%s'\n"), outfile_name); + GNUNET_free(outfile_path); + GNUNET_free(outfile_name); + return NULL; + } + dirwarn = (GNUNET_OK != GNUNET_DISK_directory_create_for_file (fn)); outfile = FOPEN (fn, "w"); diff --git a/src/dht/plugin_dhtlog_mysql_dump_load.c b/src/dht/plugin_dhtlog_mysql_dump_load.c index d3124328e..5e0abca1b 100644 --- a/src/dht/plugin_dhtlog_mysql_dump_load.c +++ b/src/dht/plugin_dhtlog_mysql_dump_load.c @@ -101,6 +101,8 @@ add_topology (int num_connections) return GNUNET_SYSERR; ret = fprintf(outfile, "insert into topology (trialuid, date, connections) values (@temp_trial, \"%s\", %d);\n", get_sql_time(), num_connections); + if (ret < 0) + return GNUNET_SYSERR; ret = fprintf(outfile, "select max(topology_uid) from topology into @temp_topology;\n"); if (ret >= 0) return GNUNET_OK; @@ -123,6 +125,8 @@ add_extended_topology (const struct GNUNET_PeerIdentity *first, const struct GNU return GNUNET_SYSERR; ret = fprintf(extended_topology_outfile, "insert into extended_topology (topology_uid, uid_first, uid_second) values (%u, %s,", topology_count, GNUNET_h2s_full(&first->hashPubKey)); + if (ret < 0) + return GNUNET_SYSERR; ret = fprintf(extended_topology_outfile, "%s);\n", GNUNET_h2s_full(&second->hashPubKey)); if (ret >= 0) @@ -197,11 +201,15 @@ int add_trial (unsigned long long *trialuid, unsigned int num_nodes, unsigned in malicious_droppers, malicious_get_frequency, malicious_put_frequency, stop_closest, stop_found, strict_kademlia, gets_succeeded, message); + if (ret < 0) + return GNUNET_SYSERR; + ret = fprintf(outfile, "SELECT MAX( trialuid ) FROM trials into @temp_trial;\n"); if (ret >= 0) return GNUNET_OK; - return GNUNET_SYSERR; + else + return GNUNET_SYSERR; } @@ -278,10 +286,13 @@ add_stat (const struct GNUNET_PeerIdentity *peer, unsigned int route_requests, get_responses_received, find_peer_responses_sent, get_responses_sent); - if (ret < 0) + else return GNUNET_SYSERR; - return GNUNET_OK; + if (ret >= 0) + return GNUNET_OK; + else + return GNUNET_SYSERR; } /* * Inserts the specified dhtkey into the dhttests.dhtkeys table, @@ -299,15 +310,15 @@ add_dhtkey (unsigned long long *dhtkeyuid, const GNUNET_HashCode * dhtkey) if (dhtkeyuid != NULL) *dhtkeyuid = 0; - if (dhtkey_outfile == NULL) + if ((dhtkey_outfile == NULL) || (dhtkey == NULL)) return GNUNET_SYSERR; - if (dhtkey != NULL) - ret = fprintf(dhtkey_outfile, "TRIALUID\t%s\n", GNUNET_h2s_full(dhtkey)); + ret = fprintf(dhtkey_outfile, "TRIALUID\t%s\n", GNUNET_h2s_full(dhtkey)); if (ret >= 0) return GNUNET_OK; - return GNUNET_SYSERR; + else + return GNUNET_SYSERR; } /* @@ -471,6 +482,10 @@ add_query (unsigned long long *sqlqueryuid, unsigned long long queryid, *sqlqueryuid = 0; ret = fprintf(query_outfile, "TRIALUID\t%s\t", GNUNET_h2s_full(key)); + + if (ret < 0) + return GNUNET_SYSERR; + ret = fprintf(query_outfile, "%s\t%llu\t%u\t%u\t%u\n", GNUNET_h2s_full(&node->hashPubKey), queryid, type, hops, succeeded); if (ret >= 0) @@ -510,11 +525,18 @@ add_route (unsigned long long *sqlqueryuid, unsigned long long queryid, *sqlqueryuid = 0; ret = fprintf(route_outfile, "TRIALUID\t%s\t", GNUNET_h2s_full(key)); + if (ret < 0) + return GNUNET_SYSERR; + ret = fprintf(route_outfile, "%s\t", GNUNET_h2s_full(&node->hashPubKey)); + if (ret < 0) + return GNUNET_SYSERR; if (from_node == NULL) ret = fprintf(route_outfile, "0\t"); else ret = fprintf(route_outfile, "%s\t", GNUNET_h2s_full(&from_node->hashPubKey)); + if (ret < 0) + return GNUNET_SYSERR; if (to_node == NULL) ret = fprintf(route_outfile, "0\t%llu\t%u\t%u\t%d\n", queryid, type, hops, succeeded); @@ -563,6 +585,14 @@ libgnunet_plugin_dhtlog_mysql_dump_load_init (void * cls) fn = GNUNET_STRINGS_filename_expand (outfile_name); + if (fn == NULL) + { + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, _("Failed to get full path for `%s'\n"), outfile_name); + GNUNET_free(outfile_path); + GNUNET_free(outfile_name); + return NULL; + } + dirwarn = (GNUNET_OK != GNUNET_DISK_directory_create_for_file (fn)); outfile = FOPEN (fn, "w"); @@ -587,6 +617,14 @@ libgnunet_plugin_dhtlog_mysql_dump_load_init (void * cls) fn = GNUNET_STRINGS_filename_expand (outfile_name); + if (fn == NULL) + { + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, _("Failed to get full path for `%s'\n"), outfile_name); + GNUNET_free(outfile_path); + GNUNET_free(outfile_name); + return NULL; + } + dirwarn = (GNUNET_OK != GNUNET_DISK_directory_create_for_file (fn)); node_outfile = FOPEN (fn, "w"); @@ -611,6 +649,14 @@ libgnunet_plugin_dhtlog_mysql_dump_load_init (void * cls) fn = GNUNET_STRINGS_filename_expand (outfile_name); + if (fn == NULL) + { + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, _("Failed to get full path for `%s'\n"), outfile_name); + GNUNET_free(outfile_path); + GNUNET_free(outfile_name); + return NULL; + } + dirwarn = (GNUNET_OK != GNUNET_DISK_directory_create_for_file (fn)); route_outfile = FOPEN (fn, "w"); @@ -635,6 +681,14 @@ libgnunet_plugin_dhtlog_mysql_dump_load_init (void * cls) fn = GNUNET_STRINGS_filename_expand (outfile_name); + if (fn == NULL) + { + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, _("Failed to get full path for `%s'\n"), outfile_name); + GNUNET_free(outfile_path); + GNUNET_free(outfile_name); + return NULL; + } + dirwarn = (GNUNET_OK != GNUNET_DISK_directory_create_for_file (fn)); query_outfile = FOPEN (fn, "w"); @@ -659,6 +713,14 @@ libgnunet_plugin_dhtlog_mysql_dump_load_init (void * cls) fn = GNUNET_STRINGS_filename_expand (outfile_name); + if (fn == NULL) + { + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, _("Failed to get full path for `%s'\n"), outfile_name); + GNUNET_free(outfile_path); + GNUNET_free(outfile_name); + return NULL; + } + dirwarn = (GNUNET_OK != GNUNET_DISK_directory_create_for_file (fn)); stat_outfile = FOPEN (fn, "w"); @@ -683,6 +745,14 @@ libgnunet_plugin_dhtlog_mysql_dump_load_init (void * cls) fn = GNUNET_STRINGS_filename_expand (outfile_name); + if (fn == NULL) + { + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, _("Failed to get full path for `%s'\n"), outfile_name); + GNUNET_free(outfile_path); + GNUNET_free(outfile_name); + return NULL; + } + dirwarn = (GNUNET_OK != GNUNET_DISK_directory_create_for_file (fn)); generic_stat_outfile = FOPEN (fn, "w"); @@ -707,6 +777,14 @@ libgnunet_plugin_dhtlog_mysql_dump_load_init (void * cls) fn = GNUNET_STRINGS_filename_expand (outfile_name); + if (fn == NULL) + { + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, _("Failed to get full path for `%s'\n"), outfile_name); + GNUNET_free(outfile_path); + GNUNET_free(outfile_name); + return NULL; + } + dirwarn = (GNUNET_OK != GNUNET_DISK_directory_create_for_file (fn)); dhtkey_outfile = FOPEN (fn, "w"); @@ -731,6 +809,14 @@ libgnunet_plugin_dhtlog_mysql_dump_load_init (void * cls) fn = GNUNET_STRINGS_filename_expand (outfile_name); + if (fn == NULL) + { + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, _("Failed to get full path for `%s'\n"), outfile_name); + GNUNET_free(outfile_path); + GNUNET_free(outfile_name); + return NULL; + } + dirwarn = (GNUNET_OK != GNUNET_DISK_directory_create_for_file (fn)); extended_topology_outfile = FOPEN (fn, "w"); diff --git a/src/dht/test_dhtlog.c b/src/dht/test_dhtlog.c index 1fef8857e..c2c5ccf72 100644 --- a/src/dht/test_dhtlog.c +++ b/src/dht/test_dhtlog.c @@ -72,37 +72,52 @@ test (struct GNUNET_DHTLOG_Handle * api) ret = api->insert_topology(500); CHECK(ret); ret = api->insert_node (&nodeuid, &p1); + CHECK(ret); ret = api->insert_node (&nodeuid, &p2); + CHECK(ret); ret = api->insert_node (&nodeuid, &p3); + CHECK(ret); ret = api->insert_node (&nodeuid, &p4); + CHECK(ret); ret = api->set_malicious(&p1); CHECK(ret); ret = api->insert_topology(0); + CHECK(ret); ret = api->insert_extended_topology(&p1, &p2); + CHECK(ret); ret = api->insert_extended_topology(&p3, &p4); + CHECK(ret); ret = api->update_topology(101); CHECK(ret); ret = api->insert_dhtkey (&dhtkeyuid, &k1); + CHECK(ret); ret = api->insert_dhtkey (&dhtkeyuid, &k2); CHECK(ret); ret = api->insert_query (&sqlqueryuid, internaluid, 2, 4, 0, &p2, &k1); + CHECK(ret); ret = api->insert_route (&sqlrouteuid, sqlqueryuid, 1, 1, DHTLOG_GET, &p1, &k2, &p4, &p3); + CHECK(ret); ret = api->insert_route (&sqlrouteuid, sqlqueryuid, 2, 0, DHTLOG_PUT, &p3, &k1, &p4, &p2); + CHECK(ret); ret = api->insert_route (&sqlrouteuid, sqlqueryuid, 3, 1, DHTLOG_ROUTE, &p3, &k2, &p2, NULL); + CHECK(ret); ret = api->insert_route (&sqlrouteuid, sqlqueryuid, 4, 7, DHTLOG_ROUTE, &p3, &k2, NULL, NULL); + CHECK(ret); sleep (1); ret = api->insert_stat(&p1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17); + CHECK(ret); ret = api->insert_stat(&p2, 12, 23, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27); CHECK(ret); ret = api->update_trial (trialuid, 787); + CHECK(ret); ret = api->add_generic_stat (&p2, "nonsense", "section", 77765); CHECK(ret); return 0; -- 2.25.1