static pid_t child;
+
static void
sigchld_handler (int val)
{
int status = 0;
int ret = 0;
+ (void) val;
waitpid (child, &status, 0);
if (WIFEXITED (status) != 0)
{
exit (ret);
}
+
static void
sigint_handler (int val)
{
exit (val);
}
+
int
-main (int argc, char *argv[])
+main (int argc,
+ char *argv[])
{
int timeout = 0;
pid_t gpid = 0;
struct VerifyRequestHandle *vrh = cls;
vrh->collect_next_task = NULL;
GNUNET_assert (NULL != vrh->cred_collection_iter);
- GNUNET_NAMESTORE_zone_iterator_next (vrh->cred_collection_iter);
+ GNUNET_NAMESTORE_zone_iterator_next (vrh->cred_collection_iter,
+ 1);
}
+
static void
handle_cred_collection_cb (void *cls,
const struct GNUNET_CRYPTO_EcdsaPrivateKey *key,
# called via NSS or other mechanisms).
INTERCEPT_DNS = YES
-# Using caching (start with namestore), or always ask DHT?
-USE_CACHE = YES
-
# PREFIX = valgrind --leak-check=full --track-origins=yes
# Zones
/**
* Task run during shutdown.
*
- * @param cls unused
- * @param tc unused
+ * @param cls unused, NULL
*/
static void
shutdown_task (void *cls)
{
struct GNS_TopLevelDomain *tld;
+ (void) cls;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Shutting down!\n");
GNS_interceptor_done ();
struct ClientLookupHandle *clh;
struct GnsClient *gc = app_ctx;
+ (void) cls;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Client %p disconnected\n",
client);
struct GNUNET_MQ_Handle *mq)
{
struct GnsClient *gc;
+
+ (void) cls;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Client %p connected\n",
client);
size_t msg_size;
const char* name;
+ (void) cls;
msg_size = ntohs (l_msg->header.size);
if (msg_size < sizeof (struct LookupMessage))
{
struct GNUNET_CRYPTO_EcdsaPublicKey pk;
struct GNS_TopLevelDomain *tld;
+ (void) cls;
+ (void) section;
if (option[0] != '.')
return;
if (GNUNET_OK !=
/**
* Use namecache
*/
-static int use_cache;
+static int disable_cache;
/**
* Global configuration.
GNUNET_GNSRECORD_query_from_public_key (&ac->authority_info.gns_authority,
ac->label,
&query);
- if (GNUNET_YES == use_cache)
+ if (GNUNET_YES != disable_cache)
{
rh->namecache_qe
= GNUNET_NAMECACHE_lookup_block (namecache_handle,
}
else
{
- start_dht_request (rh, &query);
+ start_dht_request (rh,
+ &query);
}
}
dht_lookup_heap =
GNUNET_CONTAINER_heap_create (GNUNET_CONTAINER_HEAP_ORDER_MIN);
max_allowed_background_queries = max_bg_queries;
- if (GNUNET_SYSERR == (use_cache =
- GNUNET_CONFIGURATION_get_value_yesno (c,
- "gns",
- "USE_CACHE")))
- use_cache = GNUNET_YES;
- if (GNUNET_NO == use_cache)
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ disable_cache = GNUNET_CONFIGURATION_get_value_yesno (cfg,
+ "namecache",
+ "DISABLE");
+ if (GNUNET_YES == disable_cache)
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
"Namecache disabled\n");
vpn_handle = GNUNET_VPN_connect (cfg);
}
if (rd_count != 1)
{
- GNUNET_NAMESTORE_zone_iterator_next (ai->ns_it);
+ GNUNET_NAMESTORE_zone_iterator_next (ai->ns_it,
+ 1);
return;
}
- if (GNUNET_GNSRECORD_TYPE_ID_ATTR != rd->record_type) {
- GNUNET_NAMESTORE_zone_iterator_next (ai->ns_it);
+ if (GNUNET_GNSRECORD_TYPE_ID_ATTR != rd->record_type)
+ {
+ GNUNET_NAMESTORE_zone_iterator_next (ai->ns_it,
+ 1);
return;
}
attr_ver = ntohl(*((uint32_t*)rd->data));
rd->data_size-sizeof (uint32_t),
key,
(void**)&attr_ser);
- if (GNUNET_SYSERR == msg_extra_len) {
- GNUNET_NAMESTORE_zone_iterator_next (ai->ns_it);
+ if (GNUNET_SYSERR == msg_extra_len)
+ {
+ GNUNET_NAMESTORE_zone_iterator_next (ai->ns_it,
+ 1);
return;
}
ai);
}
-void
+
+static void
iterate_next_after_abe_bootstrap (void *cls,
struct GNUNET_ABE_AbeMasterKey *abe_key)
{
struct AttributeIterator *ai = cls;
ai->abe_key = abe_key;
- GNUNET_NAMESTORE_zone_iterator_next (ai->ns_it);
+ GNUNET_NAMESTORE_zone_iterator_next (ai->ns_it,
+ 1);
}
}
}
- GNUNET_NAMESTORE_zone_iterator_next (handle->namestore_handle_it);
+ GNUNET_NAMESTORE_zone_iterator_next (handle->namestore_handle_it,
+ 1);
}
+
/**
* Iteration over all results finished, build final
* response.
*
* @param cls the `struct RequestHandle`
*/
-static void namestore_iteration_finished (void *cls)
+static void
+namestore_iteration_finished (void *cls)
{
struct RequestHandle *handle = cls;
struct GNUNET_HashCode cache_key;
ACCEPT_FROM6 = ::1;
DATABASE = sqlite
+# Disables use of caching by GNS. Useful for systems that
+# publish very large zones and are CPU bound, if they do not
+# also do a large number of lookups.
+DISABLE = NO
+
[namecache-sqlite]
FILENAME = $GNUNET_DATA_HOME/namecache/sqlite.db
*/
static int cache_keys;
+/**
+ * Use the namecache? Doing so creates additional cryptographic
+ * operations whenever we touch a record.
+ */
+static int disable_namecache;
+
/**
* Task run during shutdown.
cop);
GNUNET_free (cop);
}
- GNUNET_NAMECACHE_disconnect (namecache);
- namecache = NULL;
+ if (NULL != namecache)
+ {
+ GNUNET_NAMECACHE_disconnect (namecache);
+ namecache = NULL;
+ }
GNUNET_break (NULL == GNUNET_PLUGIN_unload (db_lib_name,
GSN_database));
GNUNET_free (db_lib_name);
rid);
return; /* no data, no need to update cache */
}
+ if (GNUNET_YES == disable_namecache)
+ {
+ GNUNET_STATISTICS_update (statistics,
+ "Namecache updates skipped (NC disabled)",
+ 1,
+ GNUNET_NO);
+ return;
+ }
exp_time = GNUNET_GNSRECORD_record_get_expiration_time (res_count,
res);
if (cache_keys)
(void) service;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Starting namestore service\n");
- GSN_cfg = cfg;
- monitor_nc = GNUNET_notification_context_create (1);
- namecache = GNUNET_NAMECACHE_connect (cfg);
- /* Loading database plugin */
cache_keys = GNUNET_CONFIGURATION_get_value_yesno (cfg,
"namestore",
"CACHE_KEYS");
+ disable_namecache = GNUNET_CONFIGURATION_get_value_yesno (cfg,
+ "namecache",
+ "DISABLE");
+ GSN_cfg = cfg;
+ monitor_nc = GNUNET_notification_context_create (1);
+ if (GNUNET_NO == disable_namecache)
+ {
+ namecache = GNUNET_NAMECACHE_connect (cfg);
+ GNUNET_assert (NULL != namecache);
+ }
+ /* Loading database plugin */
if (GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_string (cfg,
"namestore",
delta = GNUNET_TIME_absolute_get_duration (last);
last = GNUNET_TIME_absolute_get ();
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Processed 1000 records in %s\n",
- GNUNET_STRINGS_relative_time_to_string (delta,
- GNUNET_YES));
+ fprintf (stderr,
+ "Processed 1000 records in %s\n",
+ GNUNET_STRINGS_relative_time_to_string (delta,
+ GNUNET_YES));
}
}
free_records (req);
delta = GNUNET_TIME_absolute_get_duration (last);
last = GNUNET_TIME_absolute_get ();
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Imported 1000 records in %s\n",
- GNUNET_STRINGS_relative_time_to_string (delta,
- GNUNET_YES));
+ fprintf (stderr,
+ "Imported 1000 records in %s\n",
+ GNUNET_STRINGS_relative_time_to_string (delta,
+ GNUNET_YES));
}
queue (hn);
}
(void) key;
if (0 == ic->limit)
return GNUNET_NO;
- if ( (NULL != it->zone) &&
+ if ( (NULL != ic->zone) &&
(0 != memcmp (entry->private_key,
ic->zone,
sizeof (struct GNUNET_CRYPTO_EcdsaPrivateKey))) )
publish_zone_dht_start (void *cls);
+/**
+ * How often do we measure the delta between desired zone
+ * iteration speed and actual speed, and tell statistics
+ * service about it?
+ */
+#define DELTA_INTERVAL 100
+
+
/**
* Continuation called from DHT once the PUT operation is done.
*
int success)
{
struct MonitorActivity *ma = cls;
+ static unsigned long long put_cnt;
+ static struct GNUNET_TIME_Absolute last_put_100;
+ static struct GNUNET_TIME_Relative sub_delta;
struct GNUNET_TIME_Relative next_put_interval;
+ struct GNUNET_TIME_Relative delay;
num_public_records++;
if (NULL == ma)
LATE_ITERATION_SPEEDUP_FACTOR);
}
else
+ {
next_put_interval = put_interval;
+ }
next_put_interval = GNUNET_TIME_relative_min (next_put_interval,
MAXIMUM_ZONE_ITERATION_INTERVAL);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"PUT complete, next PUT in %s!\n",
GNUNET_STRINGS_relative_time_to_string (next_put_interval,
GNUNET_YES));
-
- GNUNET_STATISTICS_set (statistics,
- "Current zone iteration interval (ms)",
- next_put_interval.rel_value_us / 1000LL,
- GNUNET_NO);
+ /* compute velocities and delay corrections to apply */
+ if (0 == put_cnt)
+ last_put_100 = GNUNET_TIME_absolute_get (); /* first time! */
+ put_cnt++;
+ if (0 == put_cnt % DELTA_INTERVAL)
+ {
+ struct GNUNET_TIME_Relative delta;
+ unsigned long long pct = 0;
+
+ /* How fast were we really? */
+ delta = GNUNET_TIME_absolute_get_duration (last_put_100);
+ delta.rel_value_us /= DELTA_INTERVAL;
+ last_put_100 = GNUNET_TIME_absolute_get ();
+ /* Tell statistics actual vs. desired speed */
+ GNUNET_STATISTICS_set (statistics,
+ "Target zone iteration velocity (μs)",
+ next_put_interval.rel_value_us,
+ GNUNET_NO);
+ GNUNET_STATISTICS_set (statistics,
+ "Current zone iteration velocity (μs)",
+ delta.rel_value_us,
+ GNUNET_NO);
+ /* update "sub_delta" based on difference, taking
+ previous sub_delta into account! */
+ if (next_put_interval.rel_value_us > delta.rel_value_us)
+ {
+ /* We were too fast, reduce sub_delta! */
+ struct GNUNET_TIME_Relative corr;
+
+ corr = GNUNET_TIME_relative_subtract (next_put_interval,
+ delta);
+ if (sub_delta.rel_value_us > delta.rel_value_us)
+ {
+ /* Reduce sub_delta by corr */
+ sub_delta = GNUNET_TIME_relative_subtract (sub_delta,
+ corr);
+ }
+ else
+ {
+ /* We're doing fine with waiting the full time, this
+ should theoretically only happen if we run at
+ infinite speed. */
+ sub_delta = GNUNET_TIME_UNIT_ZERO;
+ }
+ }
+ else if (next_put_interval.rel_value_us < delta.rel_value_us)
+ {
+ /* We were too slow, increase sub_delta! */
+ struct GNUNET_TIME_Relative corr;
+
+ corr = GNUNET_TIME_relative_subtract (delta,
+ next_put_interval);
+ sub_delta = GNUNET_TIME_relative_add (sub_delta,
+ corr);
+ if (sub_delta.rel_value_us > next_put_interval.rel_value_us)
+ {
+ /* CPU overload detected, we cannot go at desired speed,
+ as this would mean using a negative delay. */
+ sub_delta = next_put_interval;
+ /* compute how much faster we would want to be for
+ the desired velocity */
+ if (0 == next_put_interval.rel_value_us)
+ pct = UINT64_MAX; /* desired speed is infinity ... */
+ else
+ pct = sub_delta.rel_value_us * 100 / next_put_interval.rel_value_us;
+ }
+ }
+ GNUNET_STATISTICS_set (statistics,
+ "% speed increase needed for target velocity",
+ pct,
+ GNUNET_NO);
+ } /* end of periodic velocity calculations */
+ delay = GNUNET_TIME_relative_subtract (next_put_interval,
+ sub_delta);
GNUNET_assert (NULL == zone_publish_task);
- zone_publish_task = GNUNET_SCHEDULER_add_delayed (next_put_interval,
+ zone_publish_task = GNUNET_SCHEDULER_add_delayed (delay,
&publish_zone_dht_next,
NULL);
}