diff options
-rw-r--r-- | contrib/timeout_watchdog.c | 7 | ||||
-rw-r--r-- | src/credential/gnunet-service-credential.c | 4 | ||||
-rw-r--r-- | src/gns/gns.conf.in | 3 | ||||
-rw-r--r-- | src/gns/gnunet-service-gns.c | 10 | ||||
-rw-r--r-- | src/gns/gnunet-service-gns_resolver.c | 19 | ||||
-rw-r--r-- | src/identity-provider/gnunet-service-identity-provider.c | 21 | ||||
-rw-r--r-- | src/identity-provider/plugin_rest_openid_connect.c | 7 | ||||
-rw-r--r-- | src/namecache/namecache.conf.in | 5 | ||||
-rw-r--r-- | src/namestore/gnunet-service-namestore.c | 36 | ||||
-rw-r--r-- | src/namestore/gnunet-zoneimport.c | 16 | ||||
-rw-r--r-- | src/namestore/plugin_namestore_flat.c | 2 | ||||
-rw-r--r-- | src/zonemaster/gnunet-service-zonemaster.c | 95 |
12 files changed, 178 insertions, 47 deletions
diff --git a/contrib/timeout_watchdog.c b/contrib/timeout_watchdog.c index 7a0376b9f..fc61a7cc7 100644 --- a/contrib/timeout_watchdog.c +++ b/contrib/timeout_watchdog.c | |||
@@ -33,12 +33,14 @@ | |||
33 | 33 | ||
34 | static pid_t child; | 34 | static pid_t child; |
35 | 35 | ||
36 | |||
36 | static void | 37 | static void |
37 | sigchld_handler (int val) | 38 | sigchld_handler (int val) |
38 | { | 39 | { |
39 | int status = 0; | 40 | int status = 0; |
40 | int ret = 0; | 41 | int ret = 0; |
41 | 42 | ||
43 | (void) val; | ||
42 | waitpid (child, &status, 0); | 44 | waitpid (child, &status, 0); |
43 | if (WIFEXITED (status) != 0) | 45 | if (WIFEXITED (status) != 0) |
44 | { | 46 | { |
@@ -53,6 +55,7 @@ sigchld_handler (int val) | |||
53 | exit (ret); | 55 | exit (ret); |
54 | } | 56 | } |
55 | 57 | ||
58 | |||
56 | static void | 59 | static void |
57 | sigint_handler (int val) | 60 | sigint_handler (int val) |
58 | { | 61 | { |
@@ -60,8 +63,10 @@ sigint_handler (int val) | |||
60 | exit (val); | 63 | exit (val); |
61 | } | 64 | } |
62 | 65 | ||
66 | |||
63 | int | 67 | int |
64 | main (int argc, char *argv[]) | 68 | main (int argc, |
69 | char *argv[]) | ||
65 | { | 70 | { |
66 | int timeout = 0; | 71 | int timeout = 0; |
67 | pid_t gpid = 0; | 72 | pid_t gpid = 0; |
diff --git a/src/credential/gnunet-service-credential.c b/src/credential/gnunet-service-credential.c index a2c339363..399371a2e 100644 --- a/src/credential/gnunet-service-credential.c +++ b/src/credential/gnunet-service-credential.c | |||
@@ -961,9 +961,11 @@ collect_next (void *cls) | |||
961 | struct VerifyRequestHandle *vrh = cls; | 961 | struct VerifyRequestHandle *vrh = cls; |
962 | vrh->collect_next_task = NULL; | 962 | vrh->collect_next_task = NULL; |
963 | GNUNET_assert (NULL != vrh->cred_collection_iter); | 963 | GNUNET_assert (NULL != vrh->cred_collection_iter); |
964 | GNUNET_NAMESTORE_zone_iterator_next (vrh->cred_collection_iter); | 964 | GNUNET_NAMESTORE_zone_iterator_next (vrh->cred_collection_iter, |
965 | 1); | ||
965 | } | 966 | } |
966 | 967 | ||
968 | |||
967 | static void | 969 | static void |
968 | handle_cred_collection_cb (void *cls, | 970 | handle_cred_collection_cb (void *cls, |
969 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *key, | 971 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *key, |
diff --git a/src/gns/gns.conf.in b/src/gns/gns.conf.in index d48a213e9..2e49a4c60 100644 --- a/src/gns/gns.conf.in +++ b/src/gns/gns.conf.in | |||
@@ -22,9 +22,6 @@ MAX_PARALLEL_BACKGROUND_QUERIES = 1000 | |||
22 | # called via NSS or other mechanisms). | 22 | # called via NSS or other mechanisms). |
23 | INTERCEPT_DNS = YES | 23 | INTERCEPT_DNS = YES |
24 | 24 | ||
25 | # Using caching (start with namestore), or always ask DHT? | ||
26 | USE_CACHE = YES | ||
27 | |||
28 | # PREFIX = valgrind --leak-check=full --track-origins=yes | 25 | # PREFIX = valgrind --leak-check=full --track-origins=yes |
29 | 26 | ||
30 | # Zones | 27 | # Zones |
diff --git a/src/gns/gnunet-service-gns.c b/src/gns/gnunet-service-gns.c index 90cd47e1d..c376ddfcc 100644 --- a/src/gns/gnunet-service-gns.c +++ b/src/gns/gnunet-service-gns.c | |||
@@ -229,14 +229,14 @@ GNS_get_tld (const char *name) | |||
229 | /** | 229 | /** |
230 | * Task run during shutdown. | 230 | * Task run during shutdown. |
231 | * | 231 | * |
232 | * @param cls unused | 232 | * @param cls unused, NULL |
233 | * @param tc unused | ||
234 | */ | 233 | */ |
235 | static void | 234 | static void |
236 | shutdown_task (void *cls) | 235 | shutdown_task (void *cls) |
237 | { | 236 | { |
238 | struct GNS_TopLevelDomain *tld; | 237 | struct GNS_TopLevelDomain *tld; |
239 | 238 | ||
239 | (void) cls; | ||
240 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 240 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
241 | "Shutting down!\n"); | 241 | "Shutting down!\n"); |
242 | GNS_interceptor_done (); | 242 | GNS_interceptor_done (); |
@@ -283,6 +283,7 @@ client_disconnect_cb (void *cls, | |||
283 | struct ClientLookupHandle *clh; | 283 | struct ClientLookupHandle *clh; |
284 | struct GnsClient *gc = app_ctx; | 284 | struct GnsClient *gc = app_ctx; |
285 | 285 | ||
286 | (void) cls; | ||
286 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 287 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
287 | "Client %p disconnected\n", | 288 | "Client %p disconnected\n", |
288 | client); | 289 | client); |
@@ -314,6 +315,8 @@ client_connect_cb (void *cls, | |||
314 | struct GNUNET_MQ_Handle *mq) | 315 | struct GNUNET_MQ_Handle *mq) |
315 | { | 316 | { |
316 | struct GnsClient *gc; | 317 | struct GnsClient *gc; |
318 | |||
319 | (void) cls; | ||
317 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 320 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
318 | "Client %p connected\n", | 321 | "Client %p connected\n", |
319 | client); | 322 | client); |
@@ -383,6 +386,7 @@ check_lookup (void *cls, | |||
383 | size_t msg_size; | 386 | size_t msg_size; |
384 | const char* name; | 387 | const char* name; |
385 | 388 | ||
389 | (void) cls; | ||
386 | msg_size = ntohs (l_msg->header.size); | 390 | msg_size = ntohs (l_msg->header.size); |
387 | if (msg_size < sizeof (struct LookupMessage)) | 391 | if (msg_size < sizeof (struct LookupMessage)) |
388 | { | 392 | { |
@@ -479,6 +483,8 @@ read_service_conf (void *cls, | |||
479 | struct GNUNET_CRYPTO_EcdsaPublicKey pk; | 483 | struct GNUNET_CRYPTO_EcdsaPublicKey pk; |
480 | struct GNS_TopLevelDomain *tld; | 484 | struct GNS_TopLevelDomain *tld; |
481 | 485 | ||
486 | (void) cls; | ||
487 | (void) section; | ||
482 | if (option[0] != '.') | 488 | if (option[0] != '.') |
483 | return; | 489 | return; |
484 | if (GNUNET_OK != | 490 | if (GNUNET_OK != |
diff --git a/src/gns/gnunet-service-gns_resolver.c b/src/gns/gnunet-service-gns_resolver.c index 745a2f3bd..92e03bc69 100644 --- a/src/gns/gnunet-service-gns_resolver.c +++ b/src/gns/gnunet-service-gns_resolver.c | |||
@@ -501,7 +501,7 @@ static struct CacheOps *co_tail; | |||
501 | /** | 501 | /** |
502 | * Use namecache | 502 | * Use namecache |
503 | */ | 503 | */ |
504 | static int use_cache; | 504 | static int disable_cache; |
505 | 505 | ||
506 | /** | 506 | /** |
507 | * Global configuration. | 507 | * Global configuration. |
@@ -2478,7 +2478,7 @@ recursive_gns_resolution_namecache (struct GNS_ResolverHandle *rh) | |||
2478 | GNUNET_GNSRECORD_query_from_public_key (&ac->authority_info.gns_authority, | 2478 | GNUNET_GNSRECORD_query_from_public_key (&ac->authority_info.gns_authority, |
2479 | ac->label, | 2479 | ac->label, |
2480 | &query); | 2480 | &query); |
2481 | if (GNUNET_YES == use_cache) | 2481 | if (GNUNET_YES != disable_cache) |
2482 | { | 2482 | { |
2483 | rh->namecache_qe | 2483 | rh->namecache_qe |
2484 | = GNUNET_NAMECACHE_lookup_block (namecache_handle, | 2484 | = GNUNET_NAMECACHE_lookup_block (namecache_handle, |
@@ -2489,7 +2489,8 @@ recursive_gns_resolution_namecache (struct GNS_ResolverHandle *rh) | |||
2489 | } | 2489 | } |
2490 | else | 2490 | else |
2491 | { | 2491 | { |
2492 | start_dht_request (rh, &query); | 2492 | start_dht_request (rh, |
2493 | &query); | ||
2493 | } | 2494 | } |
2494 | } | 2495 | } |
2495 | 2496 | ||
@@ -2816,13 +2817,11 @@ GNS_resolver_init (struct GNUNET_NAMECACHE_Handle *nc, | |||
2816 | dht_lookup_heap = | 2817 | dht_lookup_heap = |
2817 | GNUNET_CONTAINER_heap_create (GNUNET_CONTAINER_HEAP_ORDER_MIN); | 2818 | GNUNET_CONTAINER_heap_create (GNUNET_CONTAINER_HEAP_ORDER_MIN); |
2818 | max_allowed_background_queries = max_bg_queries; | 2819 | max_allowed_background_queries = max_bg_queries; |
2819 | if (GNUNET_SYSERR == (use_cache = | 2820 | disable_cache = GNUNET_CONFIGURATION_get_value_yesno (cfg, |
2820 | GNUNET_CONFIGURATION_get_value_yesno (c, | 2821 | "namecache", |
2821 | "gns", | 2822 | "DISABLE"); |
2822 | "USE_CACHE"))) | 2823 | if (GNUNET_YES == disable_cache) |
2823 | use_cache = GNUNET_YES; | 2824 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
2824 | if (GNUNET_NO == use_cache) | ||
2825 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
2826 | "Namecache disabled\n"); | 2825 | "Namecache disabled\n"); |
2827 | vpn_handle = GNUNET_VPN_connect (cfg); | 2826 | vpn_handle = GNUNET_VPN_connect (cfg); |
2828 | } | 2827 | } |
diff --git a/src/identity-provider/gnunet-service-identity-provider.c b/src/identity-provider/gnunet-service-identity-provider.c index 572202c3f..6afb7bb05 100644 --- a/src/identity-provider/gnunet-service-identity-provider.c +++ b/src/identity-provider/gnunet-service-identity-provider.c | |||
@@ -2190,12 +2190,15 @@ attr_iter_cb (void *cls, | |||
2190 | 2190 | ||
2191 | if (rd_count != 1) | 2191 | if (rd_count != 1) |
2192 | { | 2192 | { |
2193 | GNUNET_NAMESTORE_zone_iterator_next (ai->ns_it); | 2193 | GNUNET_NAMESTORE_zone_iterator_next (ai->ns_it, |
2194 | 1); | ||
2194 | return; | 2195 | return; |
2195 | } | 2196 | } |
2196 | 2197 | ||
2197 | if (GNUNET_GNSRECORD_TYPE_ID_ATTR != rd->record_type) { | 2198 | if (GNUNET_GNSRECORD_TYPE_ID_ATTR != rd->record_type) |
2198 | GNUNET_NAMESTORE_zone_iterator_next (ai->ns_it); | 2199 | { |
2200 | GNUNET_NAMESTORE_zone_iterator_next (ai->ns_it, | ||
2201 | 1); | ||
2199 | return; | 2202 | return; |
2200 | } | 2203 | } |
2201 | attr_ver = ntohl(*((uint32_t*)rd->data)); | 2204 | attr_ver = ntohl(*((uint32_t*)rd->data)); |
@@ -2209,8 +2212,10 @@ attr_iter_cb (void *cls, | |||
2209 | rd->data_size-sizeof (uint32_t), | 2212 | rd->data_size-sizeof (uint32_t), |
2210 | key, | 2213 | key, |
2211 | (void**)&attr_ser); | 2214 | (void**)&attr_ser); |
2212 | if (GNUNET_SYSERR == msg_extra_len) { | 2215 | if (GNUNET_SYSERR == msg_extra_len) |
2213 | GNUNET_NAMESTORE_zone_iterator_next (ai->ns_it); | 2216 | { |
2217 | GNUNET_NAMESTORE_zone_iterator_next (ai->ns_it, | ||
2218 | 1); | ||
2214 | return; | 2219 | return; |
2215 | } | 2220 | } |
2216 | 2221 | ||
@@ -2253,13 +2258,15 @@ iterate_after_abe_bootstrap (void *cls, | |||
2253 | ai); | 2258 | ai); |
2254 | } | 2259 | } |
2255 | 2260 | ||
2256 | void | 2261 | |
2262 | static void | ||
2257 | iterate_next_after_abe_bootstrap (void *cls, | 2263 | iterate_next_after_abe_bootstrap (void *cls, |
2258 | struct GNUNET_ABE_AbeMasterKey *abe_key) | 2264 | struct GNUNET_ABE_AbeMasterKey *abe_key) |
2259 | { | 2265 | { |
2260 | struct AttributeIterator *ai = cls; | 2266 | struct AttributeIterator *ai = cls; |
2261 | ai->abe_key = abe_key; | 2267 | ai->abe_key = abe_key; |
2262 | GNUNET_NAMESTORE_zone_iterator_next (ai->ns_it); | 2268 | GNUNET_NAMESTORE_zone_iterator_next (ai->ns_it, |
2269 | 1); | ||
2263 | } | 2270 | } |
2264 | 2271 | ||
2265 | 2272 | ||
diff --git a/src/identity-provider/plugin_rest_openid_connect.c b/src/identity-provider/plugin_rest_openid_connect.c index 7e8054e60..125bb98f6 100644 --- a/src/identity-provider/plugin_rest_openid_connect.c +++ b/src/identity-provider/plugin_rest_openid_connect.c | |||
@@ -1076,16 +1076,19 @@ namestore_iteration_callback ( | |||
1076 | } | 1076 | } |
1077 | } | 1077 | } |
1078 | 1078 | ||
1079 | GNUNET_NAMESTORE_zone_iterator_next (handle->namestore_handle_it); | 1079 | GNUNET_NAMESTORE_zone_iterator_next (handle->namestore_handle_it, |
1080 | 1); | ||
1080 | } | 1081 | } |
1081 | 1082 | ||
1083 | |||
1082 | /** | 1084 | /** |
1083 | * Iteration over all results finished, build final | 1085 | * Iteration over all results finished, build final |
1084 | * response. | 1086 | * response. |
1085 | * | 1087 | * |
1086 | * @param cls the `struct RequestHandle` | 1088 | * @param cls the `struct RequestHandle` |
1087 | */ | 1089 | */ |
1088 | static void namestore_iteration_finished (void *cls) | 1090 | static void |
1091 | namestore_iteration_finished (void *cls) | ||
1089 | { | 1092 | { |
1090 | struct RequestHandle *handle = cls; | 1093 | struct RequestHandle *handle = cls; |
1091 | struct GNUNET_HashCode cache_key; | 1094 | struct GNUNET_HashCode cache_key; |
diff --git a/src/namecache/namecache.conf.in b/src/namecache/namecache.conf.in index 236cafecd..becd34187 100644 --- a/src/namecache/namecache.conf.in +++ b/src/namecache/namecache.conf.in | |||
@@ -11,6 +11,11 @@ ACCEPT_FROM = 127.0.0.1; | |||
11 | ACCEPT_FROM6 = ::1; | 11 | ACCEPT_FROM6 = ::1; |
12 | DATABASE = sqlite | 12 | DATABASE = sqlite |
13 | 13 | ||
14 | # Disables use of caching by GNS. Useful for systems that | ||
15 | # publish very large zones and are CPU bound, if they do not | ||
16 | # also do a large number of lookups. | ||
17 | DISABLE = NO | ||
18 | |||
14 | [namecache-sqlite] | 19 | [namecache-sqlite] |
15 | FILENAME = $GNUNET_DATA_HOME/namecache/sqlite.db | 20 | FILENAME = $GNUNET_DATA_HOME/namecache/sqlite.db |
16 | 21 | ||
diff --git a/src/namestore/gnunet-service-namestore.c b/src/namestore/gnunet-service-namestore.c index 06a50132b..b9061ed9f 100644 --- a/src/namestore/gnunet-service-namestore.c +++ b/src/namestore/gnunet-service-namestore.c | |||
@@ -257,6 +257,12 @@ static struct GNUNET_NotificationContext *monitor_nc; | |||
257 | */ | 257 | */ |
258 | static int cache_keys; | 258 | static int cache_keys; |
259 | 259 | ||
260 | /** | ||
261 | * Use the namecache? Doing so creates additional cryptographic | ||
262 | * operations whenever we touch a record. | ||
263 | */ | ||
264 | static int disable_namecache; | ||
265 | |||
260 | 266 | ||
261 | /** | 267 | /** |
262 | * Task run during shutdown. | 268 | * Task run during shutdown. |
@@ -281,8 +287,11 @@ cleanup_task (void *cls) | |||
281 | cop); | 287 | cop); |
282 | GNUNET_free (cop); | 288 | GNUNET_free (cop); |
283 | } | 289 | } |
284 | GNUNET_NAMECACHE_disconnect (namecache); | 290 | if (NULL != namecache) |
285 | namecache = NULL; | 291 | { |
292 | GNUNET_NAMECACHE_disconnect (namecache); | ||
293 | namecache = NULL; | ||
294 | } | ||
286 | GNUNET_break (NULL == GNUNET_PLUGIN_unload (db_lib_name, | 295 | GNUNET_break (NULL == GNUNET_PLUGIN_unload (db_lib_name, |
287 | GSN_database)); | 296 | GSN_database)); |
288 | GNUNET_free (db_lib_name); | 297 | GNUNET_free (db_lib_name); |
@@ -715,6 +724,14 @@ refresh_block (struct NamestoreClient *nc, | |||
715 | rid); | 724 | rid); |
716 | return; /* no data, no need to update cache */ | 725 | return; /* no data, no need to update cache */ |
717 | } | 726 | } |
727 | if (GNUNET_YES == disable_namecache) | ||
728 | { | ||
729 | GNUNET_STATISTICS_update (statistics, | ||
730 | "Namecache updates skipped (NC disabled)", | ||
731 | 1, | ||
732 | GNUNET_NO); | ||
733 | return; | ||
734 | } | ||
718 | exp_time = GNUNET_GNSRECORD_record_get_expiration_time (res_count, | 735 | exp_time = GNUNET_GNSRECORD_record_get_expiration_time (res_count, |
719 | res); | 736 | res); |
720 | if (cache_keys) | 737 | if (cache_keys) |
@@ -1692,13 +1709,20 @@ run (void *cls, | |||
1692 | (void) service; | 1709 | (void) service; |
1693 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1710 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1694 | "Starting namestore service\n"); | 1711 | "Starting namestore service\n"); |
1695 | GSN_cfg = cfg; | ||
1696 | monitor_nc = GNUNET_notification_context_create (1); | ||
1697 | namecache = GNUNET_NAMECACHE_connect (cfg); | ||
1698 | /* Loading database plugin */ | ||
1699 | cache_keys = GNUNET_CONFIGURATION_get_value_yesno (cfg, | 1712 | cache_keys = GNUNET_CONFIGURATION_get_value_yesno (cfg, |
1700 | "namestore", | 1713 | "namestore", |
1701 | "CACHE_KEYS"); | 1714 | "CACHE_KEYS"); |
1715 | disable_namecache = GNUNET_CONFIGURATION_get_value_yesno (cfg, | ||
1716 | "namecache", | ||
1717 | "DISABLE"); | ||
1718 | GSN_cfg = cfg; | ||
1719 | monitor_nc = GNUNET_notification_context_create (1); | ||
1720 | if (GNUNET_NO == disable_namecache) | ||
1721 | { | ||
1722 | namecache = GNUNET_NAMECACHE_connect (cfg); | ||
1723 | GNUNET_assert (NULL != namecache); | ||
1724 | } | ||
1725 | /* Loading database plugin */ | ||
1702 | if (GNUNET_OK != | 1726 | if (GNUNET_OK != |
1703 | GNUNET_CONFIGURATION_get_value_string (cfg, | 1727 | GNUNET_CONFIGURATION_get_value_string (cfg, |
1704 | "namestore", | 1728 | "namestore", |
diff --git a/src/namestore/gnunet-zoneimport.c b/src/namestore/gnunet-zoneimport.c index 503262487..55779e06a 100644 --- a/src/namestore/gnunet-zoneimport.c +++ b/src/namestore/gnunet-zoneimport.c | |||
@@ -951,10 +951,10 @@ store_completed_cb (void *cls, | |||
951 | 951 | ||
952 | delta = GNUNET_TIME_absolute_get_duration (last); | 952 | delta = GNUNET_TIME_absolute_get_duration (last); |
953 | last = GNUNET_TIME_absolute_get (); | 953 | last = GNUNET_TIME_absolute_get (); |
954 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 954 | fprintf (stderr, |
955 | "Processed 1000 records in %s\n", | 955 | "Processed 1000 records in %s\n", |
956 | GNUNET_STRINGS_relative_time_to_string (delta, | 956 | GNUNET_STRINGS_relative_time_to_string (delta, |
957 | GNUNET_YES)); | 957 | GNUNET_YES)); |
958 | } | 958 | } |
959 | } | 959 | } |
960 | free_records (req); | 960 | free_records (req); |
@@ -1590,10 +1590,10 @@ process_stdin (void *cls) | |||
1590 | 1590 | ||
1591 | delta = GNUNET_TIME_absolute_get_duration (last); | 1591 | delta = GNUNET_TIME_absolute_get_duration (last); |
1592 | last = GNUNET_TIME_absolute_get (); | 1592 | last = GNUNET_TIME_absolute_get (); |
1593 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 1593 | fprintf (stderr, |
1594 | "Imported 1000 records in %s\n", | 1594 | "Imported 1000 records in %s\n", |
1595 | GNUNET_STRINGS_relative_time_to_string (delta, | 1595 | GNUNET_STRINGS_relative_time_to_string (delta, |
1596 | GNUNET_YES)); | 1596 | GNUNET_YES)); |
1597 | } | 1597 | } |
1598 | queue (hn); | 1598 | queue (hn); |
1599 | } | 1599 | } |
diff --git a/src/namestore/plugin_namestore_flat.c b/src/namestore/plugin_namestore_flat.c index e9ed1cc4f..f061ab7d1 100644 --- a/src/namestore/plugin_namestore_flat.c +++ b/src/namestore/plugin_namestore_flat.c | |||
@@ -583,7 +583,7 @@ iterate_zones (void *cls, | |||
583 | (void) key; | 583 | (void) key; |
584 | if (0 == ic->limit) | 584 | if (0 == ic->limit) |
585 | return GNUNET_NO; | 585 | return GNUNET_NO; |
586 | if ( (NULL != it->zone) && | 586 | if ( (NULL != ic->zone) && |
587 | (0 != memcmp (entry->private_key, | 587 | (0 != memcmp (entry->private_key, |
588 | ic->zone, | 588 | ic->zone, |
589 | sizeof (struct GNUNET_CRYPTO_EcdsaPrivateKey))) ) | 589 | sizeof (struct GNUNET_CRYPTO_EcdsaPrivateKey))) ) |
diff --git a/src/zonemaster/gnunet-service-zonemaster.c b/src/zonemaster/gnunet-service-zonemaster.c index 518d5f572..25baf4396 100644 --- a/src/zonemaster/gnunet-service-zonemaster.c +++ b/src/zonemaster/gnunet-service-zonemaster.c | |||
@@ -272,6 +272,14 @@ publish_zone_dht_start (void *cls); | |||
272 | 272 | ||
273 | 273 | ||
274 | /** | 274 | /** |
275 | * How often do we measure the delta between desired zone | ||
276 | * iteration speed and actual speed, and tell statistics | ||
277 | * service about it? | ||
278 | */ | ||
279 | #define DELTA_INTERVAL 100 | ||
280 | |||
281 | |||
282 | /** | ||
275 | * Continuation called from DHT once the PUT operation is done. | 283 | * Continuation called from DHT once the PUT operation is done. |
276 | * | 284 | * |
277 | * @param cls closure, NULL if called from regular iteration, | 285 | * @param cls closure, NULL if called from regular iteration, |
@@ -283,7 +291,11 @@ dht_put_continuation (void *cls, | |||
283 | int success) | 291 | int success) |
284 | { | 292 | { |
285 | struct MonitorActivity *ma = cls; | 293 | struct MonitorActivity *ma = cls; |
294 | static unsigned long long put_cnt; | ||
295 | static struct GNUNET_TIME_Absolute last_put_100; | ||
296 | static struct GNUNET_TIME_Relative sub_delta; | ||
286 | struct GNUNET_TIME_Relative next_put_interval; | 297 | struct GNUNET_TIME_Relative next_put_interval; |
298 | struct GNUNET_TIME_Relative delay; | ||
287 | 299 | ||
288 | num_public_records++; | 300 | num_public_records++; |
289 | if (NULL == ma) | 301 | if (NULL == ma) |
@@ -300,20 +312,91 @@ dht_put_continuation (void *cls, | |||
300 | LATE_ITERATION_SPEEDUP_FACTOR); | 312 | LATE_ITERATION_SPEEDUP_FACTOR); |
301 | } | 313 | } |
302 | else | 314 | else |
315 | { | ||
303 | next_put_interval = put_interval; | 316 | next_put_interval = put_interval; |
317 | } | ||
304 | next_put_interval = GNUNET_TIME_relative_min (next_put_interval, | 318 | next_put_interval = GNUNET_TIME_relative_min (next_put_interval, |
305 | MAXIMUM_ZONE_ITERATION_INTERVAL); | 319 | MAXIMUM_ZONE_ITERATION_INTERVAL); |
306 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 320 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
307 | "PUT complete, next PUT in %s!\n", | 321 | "PUT complete, next PUT in %s!\n", |
308 | GNUNET_STRINGS_relative_time_to_string (next_put_interval, | 322 | GNUNET_STRINGS_relative_time_to_string (next_put_interval, |
309 | GNUNET_YES)); | 323 | GNUNET_YES)); |
310 | 324 | /* compute velocities and delay corrections to apply */ | |
311 | GNUNET_STATISTICS_set (statistics, | 325 | if (0 == put_cnt) |
312 | "Current zone iteration interval (ms)", | 326 | last_put_100 = GNUNET_TIME_absolute_get (); /* first time! */ |
313 | next_put_interval.rel_value_us / 1000LL, | 327 | put_cnt++; |
314 | GNUNET_NO); | 328 | if (0 == put_cnt % DELTA_INTERVAL) |
329 | { | ||
330 | struct GNUNET_TIME_Relative delta; | ||
331 | unsigned long long pct = 0; | ||
332 | |||
333 | /* How fast were we really? */ | ||
334 | delta = GNUNET_TIME_absolute_get_duration (last_put_100); | ||
335 | delta.rel_value_us /= DELTA_INTERVAL; | ||
336 | last_put_100 = GNUNET_TIME_absolute_get (); | ||
337 | /* Tell statistics actual vs. desired speed */ | ||
338 | GNUNET_STATISTICS_set (statistics, | ||
339 | "Target zone iteration velocity (μs)", | ||
340 | next_put_interval.rel_value_us, | ||
341 | GNUNET_NO); | ||
342 | GNUNET_STATISTICS_set (statistics, | ||
343 | "Current zone iteration velocity (μs)", | ||
344 | delta.rel_value_us, | ||
345 | GNUNET_NO); | ||
346 | /* update "sub_delta" based on difference, taking | ||
347 | previous sub_delta into account! */ | ||
348 | if (next_put_interval.rel_value_us > delta.rel_value_us) | ||
349 | { | ||
350 | /* We were too fast, reduce sub_delta! */ | ||
351 | struct GNUNET_TIME_Relative corr; | ||
352 | |||
353 | corr = GNUNET_TIME_relative_subtract (next_put_interval, | ||
354 | delta); | ||
355 | if (sub_delta.rel_value_us > delta.rel_value_us) | ||
356 | { | ||
357 | /* Reduce sub_delta by corr */ | ||
358 | sub_delta = GNUNET_TIME_relative_subtract (sub_delta, | ||
359 | corr); | ||
360 | } | ||
361 | else | ||
362 | { | ||
363 | /* We're doing fine with waiting the full time, this | ||
364 | should theoretically only happen if we run at | ||
365 | infinite speed. */ | ||
366 | sub_delta = GNUNET_TIME_UNIT_ZERO; | ||
367 | } | ||
368 | } | ||
369 | else if (next_put_interval.rel_value_us < delta.rel_value_us) | ||
370 | { | ||
371 | /* We were too slow, increase sub_delta! */ | ||
372 | struct GNUNET_TIME_Relative corr; | ||
373 | |||
374 | corr = GNUNET_TIME_relative_subtract (delta, | ||
375 | next_put_interval); | ||
376 | sub_delta = GNUNET_TIME_relative_add (sub_delta, | ||
377 | corr); | ||
378 | if (sub_delta.rel_value_us > next_put_interval.rel_value_us) | ||
379 | { | ||
380 | /* CPU overload detected, we cannot go at desired speed, | ||
381 | as this would mean using a negative delay. */ | ||
382 | sub_delta = next_put_interval; | ||
383 | /* compute how much faster we would want to be for | ||
384 | the desired velocity */ | ||
385 | if (0 == next_put_interval.rel_value_us) | ||
386 | pct = UINT64_MAX; /* desired speed is infinity ... */ | ||
387 | else | ||
388 | pct = sub_delta.rel_value_us * 100 / next_put_interval.rel_value_us; | ||
389 | } | ||
390 | } | ||
391 | GNUNET_STATISTICS_set (statistics, | ||
392 | "% speed increase needed for target velocity", | ||
393 | pct, | ||
394 | GNUNET_NO); | ||
395 | } /* end of periodic velocity calculations */ | ||
396 | delay = GNUNET_TIME_relative_subtract (next_put_interval, | ||
397 | sub_delta); | ||
315 | GNUNET_assert (NULL == zone_publish_task); | 398 | GNUNET_assert (NULL == zone_publish_task); |
316 | zone_publish_task = GNUNET_SCHEDULER_add_delayed (next_put_interval, | 399 | zone_publish_task = GNUNET_SCHEDULER_add_delayed (delay, |
317 | &publish_zone_dht_next, | 400 | &publish_zone_dht_next, |
318 | NULL); | 401 | NULL); |
319 | } | 402 | } |