[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r37513 - gnunet/src/gns gnunet/src/identity-provider gnunet
From: |
gnunet |
Subject: |
[GNUnet-SVN] r37513 - gnunet/src/gns gnunet/src/identity-provider gnunet/src/include gnunet/src/namestore gnunet-gtk/src/conversation gnunet-gtk/src/fs gnunet-gtk/src/namestore |
Date: |
Sat, 9 Jul 2016 16:29:34 +0200 |
Author: grothoff
Date: 2016-07-09 16:29:34 +0200 (Sat, 09 Jul 2016)
New Revision: 37513
Modified:
gnunet-gtk/src/conversation/gnunet-conversation-gtk_contacts.c
gnunet-gtk/src/conversation/gnunet-conversation-gtk_get_label.c
gnunet-gtk/src/conversation/gnunet-conversation-gtk_import.c
gnunet-gtk/src/conversation/gnunet-conversation-gtk_phone.c
gnunet-gtk/src/fs/gnunet-fs-gtk.c
gnunet-gtk/src/namestore/gnunet-namestore-gtk.c
gnunet/src/gns/gnunet-service-gns.c
gnunet/src/gns/gnunet-service-gns_shorten.c
gnunet/src/identity-provider/gnunet-service-identity-provider.c
gnunet/src/identity-provider/plugin_rest_identity_provider.c
gnunet/src/include/gnunet_namestore_service.h
gnunet/src/namestore/gnunet-namestore-fcfsd.c
gnunet/src/namestore/gnunet-namestore.c
gnunet/src/namestore/namestore_api.c
gnunet/src/namestore/namestore_api_monitor.c
gnunet/src/namestore/plugin_rest_namestore.c
gnunet/src/namestore/test_namestore_api.conf
gnunet/src/namestore/test_namestore_api_lookup_nick.c
gnunet/src/namestore/test_namestore_api_lookup_private.c
gnunet/src/namestore/test_namestore_api_monitoring.c
gnunet/src/namestore/test_namestore_api_monitoring_existing.c
gnunet/src/namestore/test_namestore_api_zone_iteration.c
gnunet/src/namestore/test_namestore_api_zone_iteration_nick.c
gnunet/src/namestore/test_namestore_api_zone_iteration_specific_zone.c
gnunet/src/namestore/test_namestore_api_zone_iteration_stop.c
Log:
make namestore API less brittle/sublte to use
Modified: gnunet/src/gns/gnunet-service-gns.c
===================================================================
--- gnunet/src/gns/gnunet-service-gns.c 2016-07-08 19:35:27 UTC (rev 37512)
+++ gnunet/src/gns/gnunet-service-gns.c 2016-07-09 14:29:34 UTC (rev 37513)
@@ -46,11 +46,16 @@
#define INITIAL_PUT_INTERVAL GNUNET_TIME_UNIT_MILLISECONDS
/**
- * The upper bound for the zone iteration interval in milliseconds
+ * The lower bound for the zone iteration interval
*/
#define MINIMUM_ZONE_ITERATION_INTERVAL GNUNET_TIME_UNIT_SECONDS
/**
+ * The upper bound for the zone iteration interval
+ */
+#define MAXIMUM_ZONE_ITERATION_INTERVAL GNUNET_TIME_relative_multiply
(GNUNET_TIME_UNIT_MINUTES, 15)
+
+/**
* The default put interval for the zone iteration. In case
* no option is found
*/
@@ -401,6 +406,12 @@
}
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)",
@@ -509,7 +520,8 @@
label,
GNUNET_STRINGS_absolute_time_to_string (expire),
GNUNET_h2s (&query));
- ret = GNUNET_DHT_put (dht_handle, &query,
+ ret = GNUNET_DHT_put (dht_handle,
+ &query,
DHT_GNS_REPLICATION_LEVEL,
GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE,
GNUNET_BLOCK_TYPE_GNS_NAMERECORD,
@@ -524,6 +536,98 @@
/**
+ * We encountered an error in our zone iteration.
+ */
+static void
+zone_iteration_error (void *cls)
+{
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Got disconnected from namestore database, retrying.\n");
+ namestore_iter = NULL;
+ /* We end up here on error/disconnect/shutdown, so potentially
+ while a zone publish task or a DHT put is still running; hence
+ we need to cancel those. */
+ if (NULL != zone_publish_task)
+ {
+ GNUNET_SCHEDULER_cancel (zone_publish_task);
+ zone_publish_task = NULL;
+ }
+ if (NULL != active_put)
+ {
+ GNUNET_DHT_put_cancel (active_put);
+ active_put = NULL;
+ }
+ zone_publish_task = GNUNET_SCHEDULER_add_now (&publish_zone_dht_start,
+ NULL);
+}
+
+
+/**
+ * Zone iteration is completed.
+ */
+static void
+zone_iteration_finished (void *cls)
+{
+ /* we're done with one iteration, calculate when to do the next one */
+ namestore_iter = NULL;
+ last_num_public_records = num_public_records;
+ first_zone_iteration = GNUNET_NO;
+ if (0 == num_public_records)
+ {
+ /**
+ * If no records are known (startup) or none present
+ * we can safely set the interval to the value for a single
+ * record
+ */
+ put_interval = zone_publish_time_window;
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK,
+ "No records in namestore database.\n");
+ }
+ else
+ {
+ /* If records are present, next publication is based on the minimum
+ * relative expiration time of the records published divided by 4
+ */
+ zone_publish_time_window
+ = GNUNET_TIME_relative_min (GNUNET_TIME_relative_divide
(min_relative_record_time, 4),
+ zone_publish_time_window_default);
+ put_interval = GNUNET_TIME_relative_divide (zone_publish_time_window,
+ num_public_records);
+ }
+ /* reset for next iteration */
+ min_relative_record_time = GNUNET_TIME_UNIT_FOREVER_REL;
+ put_interval = GNUNET_TIME_relative_max (MINIMUM_ZONE_ITERATION_INTERVAL,
+ put_interval);
+ put_interval = GNUNET_TIME_relative_min (put_interval,
+ MAXIMUM_ZONE_ITERATION_INTERVAL);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Zone iteration finished. Adjusted zone iteration interval to
%s\n",
+ GNUNET_STRINGS_relative_time_to_string (put_interval,
+ GNUNET_YES));
+ GNUNET_STATISTICS_set (statistics,
+ "Current zone iteration interval (in ms)",
+ put_interval.rel_value_us / 1000LL,
+ GNUNET_NO);
+ GNUNET_STATISTICS_update (statistics,
+ "Number of zone iterations",
+ 1,
+ GNUNET_NO);
+ GNUNET_STATISTICS_set (statistics,
+ "Number of public records in DHT",
+ last_num_public_records,
+ GNUNET_NO);
+ GNUNET_assert (NULL == zone_publish_task);
+ if (0 == num_public_records)
+ zone_publish_task = GNUNET_SCHEDULER_add_delayed (put_interval,
+ &publish_zone_dht_start,
+ NULL);
+ else
+ zone_publish_task = GNUNET_SCHEDULER_add_now (&publish_zone_dht_start,
+ NULL);
+}
+
+
+/**
* Function used to put all records successively into the DHT.
*
* @param cls the closure (NULL)
@@ -542,95 +646,22 @@
struct GNUNET_GNSRECORD_Data rd_public[rd_count];
unsigned int rd_public_count;
- if ( (NULL == key) &&
- (NULL == label) &&
- (0 == rd_count) )
- {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Got disconnected from namestore database, retrying.\n");
- namestore_iter = NULL;
- if (NULL != zone_publish_task)
- {
- GNUNET_SCHEDULER_cancel (zone_publish_task);
- zone_publish_task = NULL;
- }
- zone_publish_task = GNUNET_SCHEDULER_add_now (&publish_zone_dht_start,
- NULL);
- return;
- }
- if (NULL == label)
- {
- /* we're done with one iteration, calculate when to do the next one */
- namestore_iter = NULL;
- last_num_public_records = num_public_records;
- first_zone_iteration = GNUNET_NO;
- if (0 == num_public_records)
- {
- /**
- * If no records are known (startup) or none present
- * we can safely set the interval to the value for a single
- * record
- */
- put_interval = zone_publish_time_window;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK,
- "No records in namestore database.\n");
- }
- else
- {
- /* If records are present, next publication is based on the minimum
- * relative expiration time of the records published divided by 4
- */
- zone_publish_time_window = GNUNET_TIME_relative_min (
- GNUNET_TIME_relative_divide (min_relative_record_time, 4),
- zone_publish_time_window_default);
- put_interval = GNUNET_TIME_relative_divide (zone_publish_time_window,
- num_public_records);
- }
- /* reset for next iteration */
- min_relative_record_time = GNUNET_TIME_UNIT_FOREVER_REL;
- put_interval = GNUNET_TIME_relative_max (MINIMUM_ZONE_ITERATION_INTERVAL,
- put_interval);
-
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Zone iteration finished. Adjusted zone iteration interval to
%s\n",
- GNUNET_STRINGS_relative_time_to_string (put_interval,
- GNUNET_YES));
- GNUNET_STATISTICS_set (statistics,
- "Current zone iteration interval (in ms)",
- put_interval.rel_value_us / 1000LL,
- GNUNET_NO);
- GNUNET_STATISTICS_update (statistics,
- "Number of zone iterations",
- 1,
- GNUNET_NO);
- GNUNET_STATISTICS_set (statistics,
- "Number of public records in DHT",
- last_num_public_records,
- GNUNET_NO);
- GNUNET_assert (NULL == zone_publish_task);
- if (0 == num_public_records)
- zone_publish_task = GNUNET_SCHEDULER_add_delayed (put_interval,
- &publish_zone_dht_start,
- NULL);
- else
- zone_publish_task = GNUNET_SCHEDULER_add_now (&publish_zone_dht_start,
- NULL);
- return;
- }
-
rd_public_count = convert_records_for_export (rd,
rd_count,
rd_public);
- /* We got a set of records to publish */
if (0 == rd_public_count)
{
GNUNET_assert (NULL == zone_publish_task);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Record set empty, moving to next record set\n");
zone_publish_task = GNUNET_SCHEDULER_add_now (&publish_zone_dht_next,
- NULL);
+ NULL);
return;
}
-
+ /* We got a set of records to publish */
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Starting DHT PUT\n");
active_put = perform_dht_put (key,
label,
rd_public,
@@ -662,7 +693,11 @@
namestore_iter
= GNUNET_NAMESTORE_zone_iteration_start (namestore_handle,
NULL, /* All zones */
+ &zone_iteration_error,
+ NULL,
&put_gns_record,
+ NULL,
+ &zone_iteration_finished,
NULL);
}
@@ -694,13 +729,16 @@
label);
/* filter out records that are not public, and convert to
absolute expiration time. */
- rd_public_count = convert_records_for_export (rd, rd_count,
+ rd_public_count = convert_records_for_export (rd,
+ rd_count,
rd_public);
if (0 == rd_public_count)
return; /* nothing to do */
ma = GNUNET_new (struct MonitorActivity);
- ma->ph = perform_dht_put (zone, label,
- rd, rd_count,
+ ma->ph = perform_dht_put (zone,
+ label,
+ rd,
+ rd_count,
ma);
if (NULL == ma->ph)
{
@@ -881,6 +919,35 @@
/**
+ * The zone monitor is now in SYNC with the current state of the
+ * name store. Start to perform periodic iterations.
+ *
+ * @param cls NULL
+ */
+static void
+handle_monitor_error (void *cls)
+{
+ if (NULL != zone_publish_task)
+ {
+ GNUNET_SCHEDULER_cancel (zone_publish_task);
+ zone_publish_task = NULL;
+ }
+ if (NULL != namestore_iter)
+ {
+ GNUNET_NAMESTORE_zone_iteration_stop (namestore_iter);
+ namestore_iter = NULL;
+ }
+ if (NULL != active_put)
+ {
+ GNUNET_DHT_put_cancel (active_put);
+ active_put = NULL;
+ }
+ zone_publish_task = GNUNET_SCHEDULER_add_now (&publish_zone_dht_start,
+ NULL);
+}
+
+
+/**
* Method called to inform about the ego to be used for the master zone
* for DNS interceptions.
*
@@ -1032,7 +1099,10 @@
zmon = GNUNET_NAMESTORE_zone_monitor_start (c,
NULL,
GNUNET_NO,
+ &handle_monitor_error,
+ NULL,
&handle_monitor_event,
+ NULL,
&monitor_sync_event,
NULL);
GNUNET_break (NULL != zmon);
Modified: gnunet/src/gns/gnunet-service-gns_shorten.c
===================================================================
--- gnunet/src/gns/gnunet-service-gns_shorten.c 2016-07-08 19:35:27 UTC (rev
37512)
+++ gnunet/src/gns/gnunet-service-gns_shorten.c 2016-07-09 14:29:34 UTC (rev
37513)
@@ -326,6 +326,21 @@
/**
+ * Encountered an error in zone-to-name lookup, give up on shortening.
+ */
+static void
+zone_to_name_error_cb (void *cls)
+{
+ struct GetPseuAuthorityHandle* gph = cls;
+
+ gph->namestore_task = NULL;
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ "Shortening aborted, internal error talking to namestore\n");
+ free_get_pseu_authority_handle (gph);
+}
+
+
+/**
* Callback called by namestore for a zone to name result. We're
* trying to see if a short name for a given zone already exists.
*
@@ -343,9 +358,6 @@
const struct GNUNET_GNSRECORD_Data *rd)
{
struct GetPseuAuthorityHandle* gph = cls;
-#if 0
- struct GNUNET_HashCode lookup_key;
-#endif
gph->namestore_task = NULL;
if (0 != rd_len)
@@ -412,6 +424,8 @@
gph->namestore_task = GNUNET_NAMESTORE_zone_to_name (namestore_handle,
shorten_zone,
pub,
+ &zone_to_name_error_cb,
+ gph,
&process_zone_to_name_discover,
gph);
}
Modified: gnunet/src/identity-provider/gnunet-service-identity-provider.c
===================================================================
--- gnunet/src/identity-provider/gnunet-service-identity-provider.c
2016-07-08 19:35:27 UTC (rev 37512)
+++ gnunet/src/identity-provider/gnunet-service-identity-provider.c
2016-07-09 14:29:34 UTC (rev 37513)
@@ -531,6 +531,32 @@
}
+static void
+token_collect_error_cb (void *cls)
+{
+ // struct EgoEntry *ego_entry = cls;
+
+ GNUNET_assert (0); // FIXME: handle properly!
+}
+
+
+static void
+token_collect_finished_cb (void *cls)
+{
+ struct EgoEntry *ego_entry = cls;
+
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ ">>> Updating Ego finished\n");
+ //Clear attribute map for ego
+ GNUNET_CONTAINER_multihashmap_iterate (ego_entry->attr_map,
+ &clear_ego_attrs,
+ ego_entry);
+ GNUNET_CONTAINER_multihashmap_clear (ego_entry->attr_map);
+ update_task = GNUNET_SCHEDULER_add_now (&update_identities,
+ ego_entry->next);
+}
+
+
/**
*
* Update all ID_TOKEN records for an identity and store them
@@ -553,21 +579,6 @@
const struct GNUNET_GNSRECORD_Data *token_metadata_record;
struct GNUNET_CRYPTO_EcdsaPublicKey *aud_key;
- if (NULL == lbl)
- {
- //Done
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- ">>> Updating Ego finished\n");
- //Clear attribute map for ego
- GNUNET_CONTAINER_multihashmap_iterate (ego_entry->attr_map,
- &clear_ego_attrs,
- ego_entry);
- GNUNET_CONTAINER_multihashmap_clear (ego_entry->attr_map);
- update_task = GNUNET_SCHEDULER_add_now (&update_identities,
- ego_entry->next);
- return;
- }
-
//There should be only a single record for a token under a label
if (2 != rd_count)
{
@@ -614,6 +625,28 @@
}
+static void
+attribute_collect_error_cb (void *cls)
+{
+ // struct EgoEntry *ego_entry = cls;
+
+ GNUNET_assert (0); // FIXME: handle properly!
+}
+
+
+static void
+attribute_collect_finished_cb (void *cls)
+{
+ struct EgoEntry *ego_entry = cls;
+
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ ">>> Updating Attributes finished\n");
+ ego_entry->attributes_dirty = GNUNET_NO;
+ update_task = GNUNET_SCHEDULER_add_now (&update_identities,
+ ego_entry);
+}
+
+
/**
*
* Collect all ID_ATTR records for an identity and store them
@@ -639,17 +672,6 @@
char *val_str;
int i;
- if (NULL == lbl)
- {
- //Done
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- ">>> Updating Attributes finished\n");
- ego_entry->attributes_dirty = GNUNET_NO;
- update_task = GNUNET_SCHEDULER_add_now (&update_identities,
- ego_entry);
- return;
- }
-
if (0 == rd_count)
{
GNUNET_NAMESTORE_zone_iterator_next (ns_it);
@@ -703,7 +725,6 @@
attr,
GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
GNUNET_NAMESTORE_zone_iterator_next (ns_it);
- return;
}
/**
@@ -718,6 +739,7 @@
{
struct EgoEntry *next_ego = cls;
const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv_key;
+
update_task = NULL;
if (NULL == next_ego)
{
@@ -740,7 +762,11 @@
//Starting over. We must update the Attributes for they might have changed.
ns_it = GNUNET_NAMESTORE_zone_iteration_start (ns_handle,
priv_key,
+ &attribute_collect_error_cb,
+ next_ego,
&attribute_collect,
+ next_ego,
+
&attribute_collect_finished_cb,
next_ego);
}
@@ -750,7 +776,11 @@
next_ego->attributes_dirty = GNUNET_YES;
ns_it = GNUNET_NAMESTORE_zone_iteration_start (ns_handle,
priv_key,
+ &token_collect_error_cb,
+ next_ego,
&token_collect,
+ next_ego,
+ &token_collect_finished_cb,
next_ego);
}
}
@@ -939,7 +969,7 @@
struct GNUNET_IDENTITY_PROVIDER_IssueResultMessage *irm;
char *ticket_str;
char *token_str;
-
+
handle->ns_qe = NULL;
if (GNUNET_SYSERR == success)
{
@@ -1077,6 +1107,27 @@
GNUNET_free (token_metadata);
}
+
+static void
+attr_collect_error (void *cls)
+{
+ // struct IssueHandle *handle = cls;
+
+ GNUNET_assert (0); // FIXME: handle error!
+}
+
+
+static void
+attr_collect_finished (void *cls)
+{
+ struct IssueHandle *handle = cls;
+
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding attribute END: \n");
+ handle->ns_it = NULL;
+ GNUNET_SCHEDULER_add_now (&sign_and_return_token, handle);
+}
+
+
/**
* Collect attributes for token
*/
@@ -1087,19 +1138,11 @@
unsigned int rd_count,
const struct GNUNET_GNSRECORD_Data *rd)
{
+ struct IssueHandle *handle = cls;
int i;
char* data;
- struct IssueHandle *handle = cls;
struct GNUNET_HashCode key;
- if (NULL == label)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding attribute END: \n");
- handle->ns_it = NULL;
- GNUNET_SCHEDULER_add_now (&sign_and_return_token, handle);
- return;
- }
-
GNUNET_CRYPTO_hash (label,
strlen (label),
&key);
@@ -1278,6 +1321,41 @@
}
+static void
+find_existing_token_error (void *cls)
+{
+ // struct IssueHandle *handle = cls;
+
+ GNUNET_assert (0); // FIXME: handle properly
+}
+
+
+static void
+find_existing_token_finished (void *cls)
+{
+ struct IssueHandle *handle = cls;
+ uint64_t rnd_key;
+
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ ">>> No existing token found\n");
+ rnd_key =
+ GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_STRONG,
+ UINT64_MAX);
+ GNUNET_STRINGS_base64_encode ((char*)&rnd_key,
+ sizeof (uint64_t),
+ &handle->label);
+ handle->ns_it = NULL;
+ handle->ns_it = GNUNET_NAMESTORE_zone_iteration_start (ns_handle,
+ &handle->iss_key,
+ &attr_collect_error,
+ handle,
+ &attr_collect,
+ handle,
+
&attr_collect_finished,
+ handle);
+}
+
+
/**
*
* Look for existing token
@@ -1301,30 +1379,9 @@
struct GNUNET_CRYPTO_EcdsaPublicKey *aud_key;
struct GNUNET_HashCode key;
int scope_count_token;
- uint64_t rnd_key;
char *scope;
char *tmp_scopes;
- if (NULL == lbl)
- {
- //Done
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- ">>> No existing token found\n");
- //Label
- rnd_key =
- GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_STRONG,
- UINT64_MAX);
- GNUNET_STRINGS_base64_encode ((char*)&rnd_key,
- sizeof (uint64_t),
- &handle->label);
- handle->ns_it = NULL;
- handle->ns_it = GNUNET_NAMESTORE_zone_iteration_start (ns_handle,
- &handle->iss_key,
- &attr_collect,
- handle);
- return;
- }
-
//There should be only a single record for a token under a label
if (2 != rd_count)
{
@@ -1335,7 +1392,9 @@
if (rd[0].record_type == GNUNET_GNSRECORD_TYPE_ID_TOKEN_METADATA)
{
token_metadata_record = &rd[0];
- } else {
+ }
+ else
+ {
token_metadata_record = &rd[1];
}
if (token_metadata_record->record_type !=
GNUNET_GNSRECORD_TYPE_ID_TOKEN_METADATA)
@@ -1399,7 +1458,11 @@
handle->ns_it = NULL;
handle->ns_it = GNUNET_NAMESTORE_zone_iteration_start (ns_handle,
&handle->iss_key,
+ &attr_collect_error,
+ handle,
&attr_collect,
+ handle,
+
&attr_collect_finished,
handle);
return;
@@ -1477,10 +1540,15 @@
issue_handle->ns_it = GNUNET_NAMESTORE_zone_iteration_start (ns_handle,
&im->iss_key,
+
&find_existing_token_error,
+ issue_handle,
&find_existing_token,
+ issue_handle,
+
&find_existing_token_finished,
issue_handle);
}
+
/**
* Main function that will be run
*
Modified: gnunet/src/identity-provider/plugin_rest_identity_provider.c
===================================================================
--- gnunet/src/identity-provider/plugin_rest_identity_provider.c
2016-07-08 19:35:27 UTC (rev 37512)
+++ gnunet/src/identity-provider/plugin_rest_identity_provider.c
2016-07-09 14:29:34 UTC (rev 37513)
@@ -647,6 +647,16 @@
cleanup_handle (handle);
}
+
+static void
+token_collect_error_cb (void *cls)
+{
+ struct RequestHandle *handle = cls;
+
+ do_error (handle);
+}
+
+
/**
* Collect all tokens for an ego
*
@@ -658,45 +668,68 @@
const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone,
const char *label,
unsigned int rd_count,
- const struct GNUNET_GNSRECORD_Data *rd)
+ const struct GNUNET_GNSRECORD_Data *rd);
+
+
+static void
+token_collect_finished_cb (void *cls)
{
- int i;
- char* data;
struct RequestHandle *handle = cls;
struct EgoEntry *ego_tmp;
- struct GNUNET_JSONAPI_Resource *json_resource;
const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv_key;
- json_t *issuer;
- json_t *token;
- if (NULL == label)
+ ego_tmp = handle->ego_head;
+ GNUNET_CONTAINER_DLL_remove (handle->ego_head,
+ handle->ego_tail,
+ ego_tmp);
+ GNUNET_free (ego_tmp->identifier);
+ GNUNET_free (ego_tmp->keystring);
+ GNUNET_free (ego_tmp);
+
+ if (NULL == handle->ego_head)
{
- ego_tmp = handle->ego_head;
- GNUNET_CONTAINER_DLL_remove (handle->ego_head,
- handle->ego_tail,
- ego_tmp);
- GNUNET_free (ego_tmp->identifier);
- GNUNET_free (ego_tmp->keystring);
- GNUNET_free (ego_tmp);
-
- if (NULL == handle->ego_head)
- {
- //Done
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding token END\n");
- handle->ns_it = NULL;
- GNUNET_SCHEDULER_add_now (&return_token_list, handle);
- return;
- }
-
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Next ego: %s\n",
handle->ego_head->identifier);
- priv_key = GNUNET_IDENTITY_ego_get_private_key (handle->ego_head->ego);
- handle->ns_it = GNUNET_NAMESTORE_zone_iteration_start (handle->ns_handle,
- priv_key,
- &token_collect,
- handle);
+ //Done
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding token END\n");
+ handle->ns_it = NULL;
+ GNUNET_SCHEDULER_add_now (&return_token_list, handle);
return;
}
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Next ego: %s\n",
+ handle->ego_head->identifier);
+ priv_key = GNUNET_IDENTITY_ego_get_private_key (handle->ego_head->ego);
+ handle->ns_it = GNUNET_NAMESTORE_zone_iteration_start (handle->ns_handle,
+ priv_key,
+
&token_collect_error_cb,
+ handle,
+ &token_collect,
+ handle,
+
&token_collect_finished_cb,
+ handle);
+}
+
+
+/**
+ * Collect all tokens for an ego
+ *
+ * TODO move this into the identity-provider service
+ *
+ */
+static void
+token_collect (void *cls,
+ const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone,
+ const char *label,
+ unsigned int rd_count,
+ const struct GNUNET_GNSRECORD_Data *rd)
+{
+ struct RequestHandle *handle = cls;
+ int i;
+ char* data;
+ struct GNUNET_JSONAPI_Resource *json_resource;
+ json_t *issuer;
+ json_t *token;
+
for (i = 0; i < rd_count; i++)
{
if (rd[i].record_type == GNUNET_GNSRECORD_TYPE_ID_TOKEN)
@@ -789,7 +822,11 @@
handle->ns_handle = GNUNET_NAMESTORE_connect (cfg);
handle->ns_it = GNUNET_NAMESTORE_zone_iteration_start (handle->ns_handle,
priv_key,
+
&token_collect_error_cb,
+ handle,
&token_collect,
+ handle,
+
&token_collect_finished_cb,
handle);
}
Modified: gnunet/src/include/gnunet_namestore_service.h
===================================================================
--- gnunet/src/include/gnunet_namestore_service.h 2016-07-08 19:35:27 UTC
(rev 37512)
+++ gnunet/src/include/gnunet_namestore_service.h 2016-07-09 14:29:34 UTC
(rev 37513)
@@ -133,8 +133,8 @@
* Process a record that was stored in the namestore.
*
* @param cls closure
- * @param zone private key of the zone; NULL on disconnect
- * @param label label of the records; NULL on disconnect
+ * @param zone private key of the zone
+ * @param label label of the records
* @param rd_count number of entries in @a rd array, 0 if label was deleted
* @param rd array of records with data to store
*/
@@ -170,7 +170,11 @@
* @param h handle to the namestore
* @param pkey private key of the zone
* @param label name that is being mapped
- * @param rm function to call with the result (with 0 records if we don't have
that label)
+ * @param error_cb function to call on error (i.e. disconnect)
+ * the handle is afterwards invalid
+ * @param error_cb_cls closure for @a error_cb
+ * @param rm function to call with the result (with 0 records if we don't have
that label);
+ * the handle is afterwards invalid
* @param rm_cls closure for @a rm
* @return handle to abort the request
*/
@@ -178,6 +182,8 @@
GNUNET_NAMESTORE_records_lookup (struct GNUNET_NAMESTORE_Handle *h,
const struct GNUNET_CRYPTO_EcdsaPrivateKey
*pkey,
const char *label,
+ GNUNET_SCHEDULER_TaskCallback error_cb,
+ void *error_cb_cls,
GNUNET_NAMESTORE_RecordMonitor rm,
void *rm_cls);
@@ -189,8 +195,12 @@
* @param h handle to the namestore
* @param zone public key of the zone to look up in, never NULL
* @param value_zone public key of the target zone (value), never NULL
+ * @param error_cb function to call on error (i.e. disconnect)
+ * the handle is afterwards invalid
+ * @param error_cb_cls closure for @a error_cb
* @param proc function to call on the matching records, or with
- * NULL (rd_count == 0) if there are no matching records
+ * NULL (rd_count == 0) if there are no matching records;
+ * the handle is afterwards invalid
* @param proc_cls closure for @a proc
* @return a handle that can be used to
* cancel
@@ -199,7 +209,10 @@
GNUNET_NAMESTORE_zone_to_name (struct GNUNET_NAMESTORE_Handle *h,
const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone,
const struct GNUNET_CRYPTO_EcdsaPublicKey
*value_zone,
- GNUNET_NAMESTORE_RecordMonitor proc, void
*proc_cls);
+ GNUNET_SCHEDULER_TaskCallback error_cb,
+ void *error_cb_cls,
+ GNUNET_NAMESTORE_RecordMonitor proc,
+ void *proc_cls);
/**
@@ -216,25 +229,38 @@
/**
* Starts a new zone iteration (used to periodically PUT all of our
- * records into our DHT). This MUST lock the struct GNUNET_NAMESTORE_Handle
- * for any other calls than #GNUNET_NAMESTORE_zone_iterator_next and
+ * records into our DHT). This MUST lock the `struct GNUNET_NAMESTORE_Handle`
+ * for any other calls than #GNUNET_NAMESTORE_zone_iterator_next() and
* #GNUNET_NAMESTORE_zone_iteration_stop. @a proc will be called once
* immediately, and then again after
- * #GNUNET_NAMESTORE_zone_iterator_next is invoked.
+ * #GNUNET_NAMESTORE_zone_iterator_next() is invoked.
*
+ * On error (disconnect), @a error_cb will be invoked.
+ * On normal completion, @a finish_cb proc will be
+ * invoked.
+ *
* @param h handle to the namestore
* @param zone zone to access, NULL for all zones
+ * @param error_cb function to call on error (i.e. disconnect),
+ * the handle is afterwards invalid
+ * @param error_cb_cls closure for @a error_cb
* @param proc function to call on each name from the zone; it
* will be called repeatedly with a value (if available)
- * and always once at the end with a label of NULL.
* @param proc_cls closure for @a proc
+ * @param finish_cb function to call on completion
+ * the handle is afterwards invalid
+ * @param finish_cb_cls closure for @a finish_cb
* @return an iterator handle to use for iteration
*/
struct GNUNET_NAMESTORE_ZoneIterator *
GNUNET_NAMESTORE_zone_iteration_start (struct GNUNET_NAMESTORE_Handle *h,
const struct
GNUNET_CRYPTO_EcdsaPrivateKey *zone,
+ GNUNET_SCHEDULER_TaskCallback error_cb,
+ void *error_cb_cls,
GNUNET_NAMESTORE_RecordMonitor proc,
- void *proc_cls);
+ void *proc_cls,
+ GNUNET_SCHEDULER_TaskCallback finish_cb,
+ void *finish_cb_cls);
/**
@@ -265,35 +291,30 @@
/**
- * Function called once the monitor has caught up with the current
- * state of the database. Will be called AGAIN after each disconnect
- * (record monitor called with 'NULL' for zone_key) once we're again
- * in sync.
- *
- * @param cls closure
- */
-typedef void
-(*GNUNET_NAMESTORE_RecordsSynchronizedCallback)(void *cls);
-
-
-/**
* Begin monitoring a zone for changes. Will first call the @a
* monitor function on all existing records in the selected zone(s) if
* @a iterate_first is #GNUNET_YES. In any case, we will then call @a
* sync_cb, and then afterwards call the @a monitor whenever a record
- * changes. If the namestore disconnects, the @a monitor function is
- * called with a disconnect event; if the connection is
+ * changes. If the namestore disconnects, the @a error_cb function is
+ * called with a disconnect event. Once the connection is
* re-established, the process begins from the start (depending on @a
- * iterate_first, we first do all existing records, then @a sync, then
- * updates).
+ * iterate_first, we will again first do all existing records, then @a
+ * sync, then updates).
*
* @param cfg configuration to use to connect to namestore
* @param zone zone to monitor, NULL for all zones
* @param iterate_first #GNUNET_YES to first iterate over all existing records,
* #GNUNET_NO to only return changes that happen from now
on
+ * @param error_cb function to call on error (i.e. disconnect); note that
+ * unlike the other error callbacks in this API, a call to this
+ * function does NOT destroy the monitor handle, it merely signals
+ * that monitoring is down. You need to still explicitly call
+ * #GNUNET_NAMESTORE_zone_monitor_stop().
+ * @param error_cb_cls closure for @a error_cb
* @param monitor function to call on zone changes
+ * @param monitor_cls closure for @a monitor
* @param sync_cb function called when we're in sync with the namestore
- * @param cls closure for @a monitor and @a sync_cb
+ * @param sync_cb_cls closure for @a sync_cb
* @return handle to stop monitoring
*/
struct GNUNET_NAMESTORE_ZoneMonitor *
@@ -300,9 +321,12 @@
GNUNET_NAMESTORE_zone_monitor_start (const struct GNUNET_CONFIGURATION_Handle
*cfg,
const struct GNUNET_CRYPTO_EcdsaPrivateKey
*zone,
int iterate_first,
+ GNUNET_SCHEDULER_TaskCallback error_cb,
+ void *error_cb_cls,
GNUNET_NAMESTORE_RecordMonitor monitor,
-
GNUNET_NAMESTORE_RecordsSynchronizedCallback sync_cb,
- void *cls);
+ void *monitor_cls,
+ GNUNET_SCHEDULER_TaskCallback sync_cb,
+ void *sync_cb_cls);
/**
Modified: gnunet/src/namestore/gnunet-namestore-fcfsd.c
===================================================================
--- gnunet/src/namestore/gnunet-namestore-fcfsd.c 2016-07-08 19:35:27 UTC
(rev 37512)
+++ gnunet/src/namestore/gnunet-namestore-fcfsd.c 2016-07-09 14:29:34 UTC
(rev 37513)
@@ -247,6 +247,62 @@
/**
+ * Function called on error in zone iteration.
+ */
+static void
+zone_iteration_error (void *cls)
+{
+ struct ZoneinfoRequest *zr = cls;
+ struct MHD_Response *response;
+
+ zr->list_it = NULL;
+ response = MHD_create_response_from_buffer (strlen ("internal error"),
+ (void *) "internal error",
+ MHD_RESPMEM_PERSISTENT);
+ MHD_queue_response (zr->connection,
+ MHD_HTTP_INTERNAL_SERVER_ERROR,
+ response);
+ MHD_destroy_response (response);
+ GNUNET_free (zr->zoneinfo);
+ GNUNET_free (zr);
+ run_httpd_now ();
+}
+
+
+/**
+ * Function called once the zone iteration is done.
+ */
+static void
+zone_iteration_end (void *cls)
+{
+ struct ZoneinfoRequest *zr = cls;
+ struct MHD_Response *response;
+ char* full_page;
+
+ zr->list_it = NULL;
+
+ /* return static form */
+ GNUNET_asprintf (&full_page,
+ ZONEINFO_PAGE,
+ zr->zoneinfo,
+ zr->zoneinfo);
+ response = MHD_create_response_from_buffer (strlen (full_page),
+ (void *) full_page,
+ MHD_RESPMEM_MUST_FREE);
+ MHD_add_response_header (response,
+ MHD_HTTP_HEADER_CONTENT_TYPE,
+ MIME_HTML);
+ MHD_queue_response (zr->connection,
+ MHD_HTTP_OK,
+ response);
+ MHD_destroy_response (response);
+ GNUNET_free (zr->zoneinfo);
+ GNUNET_free (zr);
+ run_httpd_now ();
+}
+
+
+/**
* Process a record that was stored in the namestore, adding
* the information to the HTML.
*
@@ -264,38 +320,10 @@
const struct GNUNET_GNSRECORD_Data *rd)
{
struct ZoneinfoRequest *zr = cls;
- struct MHD_Response *response;
- char* full_page;
size_t bytes_free;
char* pkey;
char* new_buf;
-
- if (NULL == name)
- {
- zr->list_it = NULL;
-
- /* return static form */
- GNUNET_asprintf (&full_page,
- ZONEINFO_PAGE,
- zr->zoneinfo,
- zr->zoneinfo);
- response = MHD_create_response_from_buffer (strlen (full_page),
- (void *) full_page,
- MHD_RESPMEM_MUST_FREE);
- MHD_add_response_header (response,
- MHD_HTTP_HEADER_CONTENT_TYPE,
- MIME_HTML);
- MHD_queue_response (zr->connection,
- MHD_HTTP_OK,
- response);
- MHD_destroy_response (response);
- GNUNET_free (zr->zoneinfo);
- GNUNET_free (zr);
- run_httpd_now ();
- return;
- }
-
if (1 != rd_len)
{
GNUNET_NAMESTORE_zone_iterator_next (zr->list_it);
@@ -354,8 +382,12 @@
zr->write_offset = 0;
zr->list_it = GNUNET_NAMESTORE_zone_iteration_start (ns,
&fcfs_zone_pkey,
+ &zone_iteration_error,
+ zr,
&iterate_cb,
- zr);
+ zr,
+ &zone_iteration_end,
+ zr);
return MHD_YES;
}
@@ -512,6 +544,21 @@
/**
+ * Function called if we had an error in zone-to-name mapping.
+ */
+static void
+zone_to_name_error (void *cls)
+{
+ struct Request *request = cls;
+
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ _("Error when mapping zone to name\n"));
+ request->phase = RP_FAIL;
+ run_httpd_now ();
+}
+
+
+/**
* Test if a name mapping was found, if so, refuse. If not, initiate storing
of the record.
*
* @param cls closure
@@ -529,6 +576,7 @@
{
struct Request *request = cls;
struct GNUNET_GNSRECORD_Data r;
+
request->qe = NULL;
if (0 != rd_count)
@@ -540,15 +588,6 @@
run_httpd_now ();
return;
}
- if (NULL == zone_key)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- _("Error when mapping zone to name\n"));
- request->phase = RP_FAIL;
- run_httpd_now ();
- return;
- }
-
r.data = &request->pub;
r.data_size = sizeof (request->pub);
r.expiration_time = UINT64_MAX;
@@ -564,6 +603,20 @@
/**
+ * We encountered an error in the name lookup.
+ */
+static void
+lookup_block_error (void *cls)
+{
+ struct Request *request = cls;
+
+ request->qe = NULL;
+ request->phase = RP_FAIL;
+ run_httpd_now ();
+}
+
+
+/**
* We got a block back from the namestore. Decrypt it
* and continue to process the result.
*
@@ -585,7 +638,6 @@
request->qe = NULL;
if (0 == rd_count)
{
-
if (GNUNET_OK !=
GNUNET_CRYPTO_ecdsa_public_key_from_string (request->public_key,
strlen
(request->public_key),
@@ -599,6 +651,8 @@
request->qe = GNUNET_NAMESTORE_zone_to_name (ns,
&fcfs_zone_pkey,
&request->pub,
+ &zone_to_name_error,
+ request,
&zone_to_name_cb,
request);
return;
@@ -728,10 +782,12 @@
}
request->phase = RP_LOOKUP;
request->qe = GNUNET_NAMESTORE_records_lookup (ns,
- &fcfs_zone_pkey,
- request->domain_name,
- &lookup_block_processor,
- request);
+ &fcfs_zone_pkey,
+ request->domain_name,
+ &lookup_block_error,
+ request,
+
&lookup_block_processor,
+ request);
break;
case RP_LOOKUP:
break;
Modified: gnunet/src/namestore/gnunet-namestore.c
===================================================================
--- gnunet/src/namestore/gnunet-namestore.c 2016-07-08 19:35:27 UTC (rev
37512)
+++ gnunet/src/namestore/gnunet-namestore.c 2016-07-09 14:29:34 UTC (rev
37513)
@@ -343,6 +343,31 @@
/**
+ * Function called when we are done with a zone iteration.
+ */
+static void
+zone_iteration_finished (void *cls)
+{
+ list_it = NULL;
+ test_finished ();
+}
+
+
+/**
+ * Function called when we encountered an error in a zone iteration.
+ */
+static void
+zone_iteration_error_cb (void *cls)
+{
+ list_it = NULL;
+ fprintf (stderr,
+ "Error iterating over zone\n");
+ ret = 1;
+ test_finished ();
+}
+
+
+/**
* Process a record that was stored in the namestore.
*
* @param cls closure
@@ -365,12 +390,6 @@
struct GNUNET_TIME_Absolute at;
struct GNUNET_TIME_Relative rt;
- if (NULL == rname)
- {
- list_it = NULL;
- test_finished ();
- return;
- }
if ( (NULL != name) &&
(0 != strcmp (name, rname)) )
{
@@ -433,6 +452,31 @@
/**
+ * Function called on errors while monitoring.
+ *
+ * @param cls NULL
+ */
+static void
+monitor_error_cb (void *cls)
+{
+ FPRINTF (stderr, "%s", "Monitor disconnected and out of sync.\n");
+}
+
+
+/**
+ * Function called if lookup fails.
+ */
+static void
+lookup_error_cb (void *cls)
+{
+ add_qe = NULL;
+ GNUNET_break (0);
+ ret = 1;
+ test_finished ();
+}
+
+
+/**
* We're storing a record; this function is given the existing record
* so that we can merge the information.
*
@@ -454,8 +498,7 @@
unsigned int i;
add_qe = NULL;
- if ( (NULL != zone_key) &&
- (0 != strcmp (rec_name, name)) )
+ if (0 != strcmp (rec_name, name))
{
GNUNET_break (0);
ret = 1;
@@ -566,6 +609,19 @@
/**
+ * Function called if we encountered an error in zone-to-name.
+ */
+static void
+reverse_error_cb (void *cls)
+{
+ reverse_qe = NULL;
+ FPRINTF (stdout,
+ "%s.zkey\n",
+ reverse_pkey);
+}
+
+
+/**
* Function called with the result of our attempt to obtain a name for a given
* public key.
*
@@ -596,6 +652,19 @@
/**
+ * Function called if lookup for deletion fails.
+ */
+static void
+del_lookup_error_cb (void *cls)
+{
+ del_qe = NULL;
+ GNUNET_break (0);
+ ret = 1;
+ test_finished ();
+}
+
+
+/**
* We were asked to delete something; this function is called with
* the existing records. Now we should determine what should be
* deleted and then issue the deletion operation.
@@ -802,8 +871,13 @@
ret = 1;
return;
}
- add_qe = GNUNET_NAMESTORE_records_lookup (ns, &zone_pkey, name,
- &get_existing_record, NULL );
+ add_qe = GNUNET_NAMESTORE_records_lookup (ns,
+ &zone_pkey,
+ name,
+ &lookup_error_cb,
+ NULL,
+ &get_existing_record,
+ NULL);
}
if (del)
{
@@ -819,6 +893,8 @@
del_qe = GNUNET_NAMESTORE_records_lookup (ns,
&zone_pkey,
name,
+ &del_lookup_error_cb,
+ NULL,
&del_monitor,
NULL);
}
@@ -826,7 +902,11 @@
{
list_it = GNUNET_NAMESTORE_zone_iteration_start (ns,
&zone_pkey,
+ &zone_iteration_error_cb,
+ NULL,
&display_record,
+ NULL,
+ &zone_iteration_finished,
NULL);
}
if (NULL != reverse_pkey)
@@ -846,6 +926,8 @@
reverse_qe = GNUNET_NAMESTORE_zone_to_name (ns,
&zone_pkey,
&pubkey,
+ &reverse_error_cb,
+ NULL,
&handle_reverse_lookup,
NULL);
}
@@ -860,7 +942,10 @@
"gnunet://gns/%52s/%63s",
sh,
sname)) ) ||
- (GNUNET_OK != GNUNET_CRYPTO_ecdsa_public_key_from_string (sh, strlen
(sh), &pkey)) )
+ (GNUNET_OK !=
+ GNUNET_CRYPTO_ecdsa_public_key_from_string (sh,
+ strlen (sh),
+ &pkey)) )
{
fprintf (stderr,
_("Invalid URI `%s'\n"),
@@ -912,7 +997,10 @@
zm = GNUNET_NAMESTORE_zone_monitor_start (cfg,
&zone_pkey,
GNUNET_YES,
+ &monitor_error_cb,
+ NULL,
&display_record,
+ NULL,
&sync_cb,
NULL);
}
Modified: gnunet/src/namestore/namestore_api.c
===================================================================
--- gnunet/src/namestore/namestore_api.c 2016-07-08 19:35:27 UTC (rev
37512)
+++ gnunet/src/namestore/namestore_api.c 2016-07-09 14:29:34 UTC (rev
37513)
@@ -84,6 +84,16 @@
void *proc_cls;
/**
+ * Function to call on errors.
+ */
+ GNUNET_SCHEDULER_TaskCallback error_cb;
+
+ /**
+ * Closure for @e error_cb.
+ */
+ void *error_cb_cls;
+
+ /**
* Envelope of the message to send to the service, if not yet
* sent.
*/
@@ -119,6 +129,16 @@
struct GNUNET_NAMESTORE_Handle *h;
/**
+ * Function to call on completion.
+ */
+ GNUNET_SCHEDULER_TaskCallback finish_cb;
+
+ /**
+ * Closure for @e error_cb.
+ */
+ void *finish_cb_cls;
+
+ /**
* The continuation to call with the results
*/
GNUNET_NAMESTORE_RecordMonitor proc;
@@ -129,6 +149,16 @@
void *proc_cls;
/**
+ * Function to call on errors.
+ */
+ GNUNET_SCHEDULER_TaskCallback error_cb;
+
+ /**
+ * Closure for @e error_cb.
+ */
+ void *error_cb_cls;
+
+ /**
* Envelope of the message to send to the service, if not yet
* sent.
*/
@@ -543,9 +573,11 @@
ntohl (msg->gns_header.r_id));
qe = find_qe (h,
ntohl (msg->gns_header.r_id));
- if ( (NULL == ze) && (NULL == qe) )
+ if ( (NULL == ze) &&
+ (NULL == qe) )
return; /* rid not found */
- if ( (NULL != ze) && (NULL != qe) )
+ if ( (NULL != ze) &&
+ (NULL != qe) )
{
GNUNET_break (0); /* rid ambigous */
force_reconnect (h);
@@ -564,8 +596,8 @@
force_reconnect (h);
return;
}
- if (NULL != ze->proc)
- ze->proc (ze->proc_cls, NULL, NULL, 0, NULL);
+ if (NULL != ze->finish_cb)
+ ze->finish_cb (ze->finish_cb_cls);
free_ze (ze);
return;
}
@@ -706,7 +738,8 @@
qe->proc (qe->proc_cls,
&msg->zone,
name_tmp,
- rd_count, rd);
+ rd_count,
+ rd);
/* return is important here: break would call continuation with error! */
free_qe (qe);
return;
@@ -717,8 +750,8 @@
return;
}
/* error case, call continuation with error */
- if (NULL != qe->proc)
- qe->proc (qe->proc_cls, NULL, NULL, 0, NULL);
+ if (NULL != qe->error_cb)
+ qe->error_cb (qe->error_cb_cls);
free_qe (qe);
}
@@ -826,18 +859,18 @@
h->mq = NULL;
while (NULL != (ze = h->z_head))
{
- /* FIXME: This does not allow clients to distinguish
- iteration error from successful termination! */
- if (NULL != ze->proc)
- ze->proc (ze->proc_cls, NULL, NULL, 0, NULL);
+ if (NULL != ze->error_cb)
+ ze->error_cb (ze->error_cb_cls);
free_ze (ze);
}
while (NULL != (qe = h->op_head))
{
- /* FIXME: This does not allow clients to distinguish
- iteration error from successful termination! */
- if (NULL != qe->proc)
- qe->proc (qe->proc_cls, NULL, NULL, 0, NULL);
+ if (NULL != qe->error_cb)
+ qe->error_cb (qe->error_cb_cls);
+ if (NULL != qe->cont)
+ qe->cont (qe->cont_cls,
+ GNUNET_SYSERR,
+ "failure in communication with namestore service");
free_qe (qe);
}
@@ -1058,6 +1091,8 @@
* @param h handle to the namestore
* @param pkey private key of the zone
* @param label name that is being mapped (at most 255 characters long)
+ * @param error_cb function to call on error (i.e. disconnect)
+ * @param error_cb_cls closure for @a error_cb
* @param rm function to call with the result (with 0 records if we don't have
that label)
* @param rm_cls closure for @a rm
* @return handle to abort the request
@@ -1066,6 +1101,8 @@
GNUNET_NAMESTORE_records_lookup (struct GNUNET_NAMESTORE_Handle *h,
const struct GNUNET_CRYPTO_EcdsaPrivateKey
*pkey,
const char *label,
+ GNUNET_SCHEDULER_TaskCallback error_cb,
+ void *error_cb_cls,
GNUNET_NAMESTORE_RecordMonitor rm,
void *rm_cls)
{
@@ -1082,6 +1119,8 @@
qe = GNUNET_new (struct GNUNET_NAMESTORE_QueueEntry);
qe->h = h;
+ qe->error_cb = error_cb;
+ qe->error_cb_cls = error_cb_cls;
qe->proc = rm;
qe->proc_cls = rm_cls;
qe->op_id = get_op_id(h);
@@ -1114,6 +1153,8 @@
* @param h handle to the namestore
* @param zone public key of the zone to look up in, never NULL
* @param value_zone public key of the target zone (value), never NULL
+ * @param error_cb function to call on error (i.e. disconnect)
+ * @param error_cb_cls closure for @a error_cb
* @param proc function to call on the matching records, or with
* NULL (rd_count == 0) if there are no matching records
* @param proc_cls closure for @a proc
@@ -1124,6 +1165,8 @@
GNUNET_NAMESTORE_zone_to_name (struct GNUNET_NAMESTORE_Handle *h,
const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone,
const struct GNUNET_CRYPTO_EcdsaPublicKey
*value_zone,
+ GNUNET_SCHEDULER_TaskCallback error_cb,
+ void *error_cb_cls,
GNUNET_NAMESTORE_RecordMonitor proc,
void *proc_cls)
{
@@ -1135,6 +1178,8 @@
rid = get_op_id(h);
qe = GNUNET_new (struct GNUNET_NAMESTORE_QueueEntry);
qe->h = h;
+ qe->error_cb = error_cb;
+ qe->error_cb_cls = error_cb_cls;
qe->proc = proc;
qe->proc_cls = proc_cls;
qe->op_id = rid;
@@ -1166,17 +1211,24 @@
*
* @param h handle to the namestore
* @param zone zone to access, NULL for all zones
+ * @param error_cb function to call on error (i.e. disconnect)
+ * @param error_cb_cls closure for @a error_cb
* @param proc function to call on each name from the zone; it
* will be called repeatedly with a value (if available)
- * and always once at the end with a name of NULL.
* @param proc_cls closure for @a proc
+ * @param finish_cb function to call on completion
+ * @param finish_cb_cls closure for @a finish_cb
* @return an iterator handle to use for iteration
*/
struct GNUNET_NAMESTORE_ZoneIterator *
GNUNET_NAMESTORE_zone_iteration_start (struct GNUNET_NAMESTORE_Handle *h,
const struct
GNUNET_CRYPTO_EcdsaPrivateKey *zone,
+ GNUNET_SCHEDULER_TaskCallback error_cb,
+ void *error_cb_cls,
GNUNET_NAMESTORE_RecordMonitor proc,
- void *proc_cls)
+ void *proc_cls,
+ GNUNET_SCHEDULER_TaskCallback finish_cb,
+ void *finish_cb_cls)
{
struct GNUNET_NAMESTORE_ZoneIterator *it;
struct GNUNET_MQ_Envelope *env;
@@ -1183,9 +1235,15 @@
struct ZoneIterationStartMessage *msg;
uint32_t rid;
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Sending ZONE_ITERATION_START message\n");
rid = get_op_id (h);
it = GNUNET_new (struct GNUNET_NAMESTORE_ZoneIterator);
it->h = h;
+ it->error_cb = error_cb;
+ it->error_cb_cls = error_cb_cls;
+ it->finish_cb = finish_cb;
+ it->finish_cb_cls = finish_cb_cls;
it->proc = proc;
it->proc_cls = proc_cls;
it->op_id = rid;
Modified: gnunet/src/namestore/namestore_api_monitor.c
===================================================================
--- gnunet/src/namestore/namestore_api_monitor.c 2016-07-08 19:35:27 UTC
(rev 37512)
+++ gnunet/src/namestore/namestore_api_monitor.c 2016-07-09 14:29:34 UTC
(rev 37513)
@@ -51,19 +51,34 @@
struct GNUNET_MQ_Handle *mq;
/**
+ * Function to call on errors.
+ */
+ GNUNET_SCHEDULER_TaskCallback error_cb;
+
+ /**
+ * Closure for @e error_cb.
+ */
+ void *error_cb_cls;
+
+ /**
* Function to call on events.
*/
GNUNET_NAMESTORE_RecordMonitor monitor;
/**
+ * Closure for @e monitor.
+ */
+ void *monitor_cls;
+
+ /**
* Function called when we've synchronized.
*/
- GNUNET_NAMESTORE_RecordsSynchronizedCallback sync_cb;
+ GNUNET_SCHEDULER_TaskCallback sync_cb;
/**
- * Closure for @e monitor and @e sync_cb.
+ * Closure for @e sync_cb.
*/
- void *cls;
+ void *sync_cb_cls;
/**
* Monitored zone.
@@ -100,7 +115,7 @@
struct GNUNET_NAMESTORE_ZoneMonitor *zm = cls;
if (NULL != zm->sync_cb)
- zm->sync_cb (zm->cls);
+ zm->sync_cb (zm->sync_cb_cls);
}
@@ -193,7 +208,7 @@
rd_ser_tmp,
rd_count,
rd));
- zm->monitor (zm->cls,
+ zm->monitor (zm->monitor_cls,
&lrm->private_key,
name_tmp,
rd_count,
@@ -245,11 +260,7 @@
if (NULL != zm->mq)
{
GNUNET_MQ_destroy (zm->mq);
- zm->monitor (zm->cls,
- NULL,
- NULL,
- 0,
- NULL);
+ zm->error_cb (zm->error_cb_cls);
}
zm->mq = GNUNET_CLIENT_connecT (zm->cfg,
"namestore",
@@ -278,9 +289,16 @@
* @param zone zone to monitor
* @param iterate_first #GNUNET_YES to first iterate over all existing records,
* #GNUNET_NO to only return changes that happen from now
on
+ * @param error_cb function to call on error (i.e. disconnect); note that
+ * unlike the other error callbacks in this API, a call to this
+ * function does NOT destroy the monitor handle, it merely signals
+ * that monitoring is down. You need to still explicitly call
+ * #GNUNET_NAMESTORE_zone_monitor_stop().
+ * @param error_cb_cls closure for @a error_cb
* @param monitor function to call on zone changes
+ * @param monitor_cls closure for @a monitor
* @param sync_cb function called when we're in sync with the namestore
- * @param cls closure for @a monitor and @a sync_cb
+ * @param cls closure for @a sync_cb
* @return handle to stop monitoring
*/
struct GNUNET_NAMESTORE_ZoneMonitor *
@@ -287,9 +305,12 @@
GNUNET_NAMESTORE_zone_monitor_start (const struct GNUNET_CONFIGURATION_Handle
*cfg,
const struct GNUNET_CRYPTO_EcdsaPrivateKey
*zone,
int iterate_first,
+ GNUNET_SCHEDULER_TaskCallback error_cb,
+ void *error_cb_cls,
GNUNET_NAMESTORE_RecordMonitor monitor,
-
GNUNET_NAMESTORE_RecordsSynchronizedCallback sync_cb,
- void *cls)
+ void *monitor_cls,
+ GNUNET_SCHEDULER_TaskCallback sync_cb,
+ void *sync_cb_cls)
{
struct GNUNET_NAMESTORE_ZoneMonitor *zm;
@@ -297,9 +318,12 @@
if (NULL != zone)
zm->zone = *zone;
zm->iterate_first = iterate_first;
+ zm->error_cb = error_cb;
+ zm->error_cb_cls = error_cb_cls;
zm->monitor = monitor;
+ zm->monitor_cls = monitor_cls;
zm->sync_cb = sync_cb;
- zm->cls = cls;
+ zm->sync_cb_cls = sync_cb_cls;
zm->cfg = cfg;
reconnect (zm);
if (NULL == zm->mq)
Modified: gnunet/src/namestore/plugin_rest_namestore.c
===================================================================
--- gnunet/src/namestore/plugin_rest_namestore.c 2016-07-08 19:35:27 UTC
(rev 37512)
+++ gnunet/src/namestore/plugin_rest_namestore.c 2016-07-09 14:29:34 UTC
(rev 37513)
@@ -388,6 +388,38 @@
/**
+ * Iteration over all results finished, build final
+ * response.
+ *
+ * @param cls the `struct RequestHandle`
+ */
+static void
+namestore_list_finished (void *cls)
+{
+ struct RequestHandle *handle = cls;
+ char *result;
+ struct MHD_Response *resp;
+
+ handle->list_it = NULL;
+ if (GNUNET_SYSERR ==
+ GNUNET_JSONAPI_document_serialize (handle->resp_object,
+ &result))
+ {
+ do_error (handle);
+ return;
+ }
+ resp = GNUNET_REST_create_response (result);
+ handle->proc (handle->proc_cls,
+ resp,
+ MHD_HTTP_OK);
+ GNUNET_free_non_null (result);
+ GNUNET_SCHEDULER_add_now (&cleanup_handle_delayed,
+ handle);
+}
+
+
+
+/**
* Create a response with requested records
*
* @param handle the RequestHandle
@@ -401,31 +433,13 @@
{
struct RequestHandle *handle = cls;
struct GNUNET_JSONAPI_Resource *json_resource;
- struct MHD_Response *resp;
json_t *result_array;
json_t *record_obj;
int i;
- char *result;
if (NULL == handle->resp_object)
handle->resp_object = GNUNET_JSONAPI_document_new ();
- if (NULL == rname)
- {
- handle->list_it = NULL;
- //Handle response
- if (GNUNET_SYSERR == GNUNET_JSONAPI_document_serialize
(handle->resp_object, &result))
- {
- GNUNET_SCHEDULER_add_now (&do_error, handle);
- return;
- }
- resp = GNUNET_REST_create_response (result);
- handle->proc (handle->proc_cls, resp, MHD_HTTP_OK);
- GNUNET_free_non_null (result);
- GNUNET_SCHEDULER_add_now (&cleanup_handle_delayed, handle);
- return;
- }
-
if ( (NULL != handle->name) &&
(0 != strcmp (handle->name, rname)) )
{
@@ -464,6 +478,7 @@
GNUNET_NAMESTORE_zone_iterator_next (handle->list_it);
}
+
static void
create_finished (void *cls, int32_t success, const char *emsg)
{
@@ -506,11 +521,10 @@
struct RequestHandle *handle = cls;
handle->add_qe = NULL;
- if ( (NULL != zone_key) &&
- (0 != strcmp (rec_name, handle->name)) )
+ if (0 != strcmp (rec_name, handle->name))
{
GNUNET_break (0);
- GNUNET_SCHEDULER_add_now (&do_error, handle);
+ do_error (handle);
return;
}
@@ -533,6 +547,7 @@
handle);
}
+
static void
del_finished (void *cls,
int32_t success,
@@ -565,6 +580,7 @@
GNUNET_SCHEDULER_add_now (&cleanup_handle_delayed, handle);
}
+
static void
del_cont (void *cls,
const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone,
@@ -573,6 +589,7 @@
const struct GNUNET_GNSRECORD_Data *rd)
{
struct RequestHandle *handle = cls;
+
handle->add_qe = NULL;
if (0 == rd_count)
{
@@ -579,7 +596,7 @@
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
_("There are no records under label `%s' that could be
deleted.\n"),
label);
- GNUNET_SCHEDULER_add_now (&do_error, handle);
+ do_error (handle);
return;
}
@@ -591,6 +608,7 @@
handle);
}
+
static void
namestore_delete_cont (struct GNUNET_REST_RequestHandle *con,
const char *url,
@@ -607,10 +625,13 @@
handle->add_qe = GNUNET_NAMESTORE_records_lookup (handle->ns_handle,
&handle->zone_pkey,
handle->name,
+ &do_error,
+ handle,
&del_cont,
handle);
}
+
static int
json_to_gnsrecord (const json_t *records_json,
struct GNUNET_GNSRECORD_Data **rd,
@@ -713,6 +734,7 @@
return GNUNET_OK;
}
+
static void
namestore_create_cont (struct GNUNET_REST_RequestHandle *con,
const char *url,
@@ -730,7 +752,7 @@
GNUNET_JSON_spec_jsonapi_document (&json_obj),
GNUNET_JSON_spec_end()
};
-
+
if (strlen (GNUNET_REST_API_NS_NAMESTORE) != strlen (handle->url))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
@@ -805,9 +827,13 @@
handle->add_qe = GNUNET_NAMESTORE_records_lookup (handle->ns_handle,
&handle->zone_pkey,
handle->name,
- &create_new_record_cont,
handle );
+ &do_error,
+ handle,
+ &create_new_record_cont,
+ handle);
}
+
static void
namestore_zkey_response (void *cls,
const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone,
@@ -847,10 +873,9 @@
GNUNET_JSONAPI_document_delete (json_obj);
GNUNET_free (result);
GNUNET_SCHEDULER_add_now (&cleanup_handle_delayed, handle);
- return;
-
}
+
static void
namestore_zkey_cont (struct GNUNET_REST_RequestHandle *con,
const char *url,
@@ -887,10 +912,13 @@
handle->reverse_qe = GNUNET_NAMESTORE_zone_to_name (handle->ns_handle,
&handle->zone_pkey,
&pubkey,
+ &do_error,
+ handle,
&namestore_zkey_response,
handle);
}
+
static void
namestore_info_cont (struct GNUNET_REST_RequestHandle *con,
const char *url,
@@ -897,12 +925,18 @@
void *cls)
{
struct RequestHandle *handle = cls;
+
handle->list_it = GNUNET_NAMESTORE_zone_iteration_start (handle->ns_handle,
&handle->zone_pkey,
+ &do_error,
+ handle,
&namestore_list_response,
+ handle,
+
&namestore_list_finished,
handle);
}
+
static char*
get_name_from_url (const char* url)
{
Modified: gnunet/src/namestore/test_namestore_api.conf
===================================================================
--- gnunet/src/namestore/test_namestore_api.conf 2016-07-08 19:35:27 UTC
(rev 37512)
+++ gnunet/src/namestore/test_namestore_api.conf 2016-07-09 14:29:34 UTC
(rev 37513)
@@ -13,3 +13,6 @@
[nse]
WORKBITS = 0
+
+[transport]
+PLUGINS =
Modified: gnunet/src/namestore/test_namestore_api_lookup_nick.c
===================================================================
--- gnunet/src/namestore/test_namestore_api_lookup_nick.c 2016-07-08
19:35:27 UTC (rev 37512)
+++ gnunet/src/namestore/test_namestore_api_lookup_nick.c 2016-07-09
14:29:34 UTC (rev 37513)
@@ -222,6 +222,13 @@
static void
+fail_cb (void *cls)
+{
+ GNUNET_assert (0);
+}
+
+
+static void
put_cont (void *cls, int32_t success, const char *emsg)
{
const char *name = cls;
@@ -240,9 +247,16 @@
return;
}
/* Lookup */
- nsqe = GNUNET_NAMESTORE_records_lookup (nsh, privkey, name, lookup_it, NULL);
+ nsqe = GNUNET_NAMESTORE_records_lookup (nsh,
+ privkey,
+ name,
+ &fail_cb,
+ NULL,
+ &lookup_it,
+ NULL);
}
+
static void
nick_cont (void *cls, int32_t success, const char *emsg)
{
Modified: gnunet/src/namestore/test_namestore_api_lookup_private.c
===================================================================
--- gnunet/src/namestore/test_namestore_api_lookup_private.c 2016-07-08
19:35:27 UTC (rev 37512)
+++ gnunet/src/namestore/test_namestore_api_lookup_private.c 2016-07-09
14:29:34 UTC (rev 37513)
@@ -103,7 +103,9 @@
{
nsqe = NULL;
- if (0 != memcmp(privkey, zone, sizeof (struct
GNUNET_CRYPTO_EcdsaPrivateKey)))
+ if (0 != memcmp (privkey,
+ zone,
+ sizeof (struct GNUNET_CRYPTO_EcdsaPrivateKey)))
{
GNUNET_break(0);
GNUNET_SCHEDULER_cancel (endbadly_task);
@@ -144,6 +146,13 @@
static void
+fail_cb (void *cls)
+{
+ GNUNET_assert (0);
+}
+
+
+static void
put_cont (void *cls, int32_t success, const char *emsg)
{
const char *name = cls;
@@ -162,7 +171,13 @@
return;
}
/* Lookup */
- nsqe = GNUNET_NAMESTORE_records_lookup (nsh, privkey, name, lookup_it, NULL);
+ nsqe = GNUNET_NAMESTORE_records_lookup (nsh,
+ privkey,
+ name,
+ &fail_cb,
+ NULL,
+ &lookup_it,
+ NULL);
}
Modified: gnunet/src/namestore/test_namestore_api_monitoring.c
===================================================================
--- gnunet/src/namestore/test_namestore_api_monitoring.c 2016-07-08
19:35:27 UTC (rev 37512)
+++ gnunet/src/namestore/test_namestore_api_monitoring.c 2016-07-09
14:29:34 UTC (rev 37513)
@@ -215,11 +215,11 @@
char *label = cls;
if (0 == strcmp (label, s_name_1))
- ns_ops[0] = NULL;
+ ns_ops[0] = NULL;
else if (0 == strcmp (label, s_name_2))
- ns_ops[1] = NULL;
+ ns_ops[1] = NULL;
else if (0 == strcmp (label, s_name_3))
- ns_ops[2] = NULL;
+ ns_ops[2] = NULL;
if (success == GNUNET_OK)
{
@@ -261,6 +261,20 @@
static void
+fail_cb (void *cls)
+{
+ GNUNET_assert (0);
+}
+
+
+static void
+sync_cb (void *cls)
+{
+ /* do nothing */
+}
+
+
+static void
run (void *cls,
const struct GNUNET_CONFIGURATION_Handle *cfg,
struct GNUNET_TESTING_Peer *peer)
@@ -288,8 +302,11 @@
zm = GNUNET_NAMESTORE_zone_monitor_start (cfg,
privkey,
GNUNET_YES,
+ &fail_cb,
+ NULL,
&zone_proc,
NULL,
+ &sync_cb,
NULL);
if (NULL == zm)
{
Modified: gnunet/src/namestore/test_namestore_api_monitoring_existing.c
===================================================================
--- gnunet/src/namestore/test_namestore_api_monitoring_existing.c
2016-07-08 19:35:27 UTC (rev 37512)
+++ gnunet/src/namestore/test_namestore_api_monitoring_existing.c
2016-07-09 14:29:34 UTC (rev 37513)
@@ -59,6 +59,7 @@
static char *directory;
+
static void
do_shutdown ()
{
@@ -204,11 +205,24 @@
else
GNUNET_SCHEDULER_add_now (&end, NULL);
}
+}
+
+static void
+fail_cb (void *cls)
+{
+ GNUNET_assert (0);
}
static void
+sync_cb (void *cls)
+{
+ /* do nothing */
+}
+
+
+static void
put_cont (void *cls, int32_t success, const char *emsg)
{
static int c = 0;
@@ -240,8 +254,11 @@
zm = GNUNET_NAMESTORE_zone_monitor_start (cfg,
privkey,
GNUNET_YES,
+ &fail_cb,
+ NULL,
&zone_proc,
NULL,
+ &sync_cb,
NULL);
if (NULL == zm)
{
Modified: gnunet/src/namestore/test_namestore_api_zone_iteration.c
===================================================================
--- gnunet/src/namestore/test_namestore_api_zone_iteration.c 2016-07-08
19:35:27 UTC (rev 37512)
+++ gnunet/src/namestore/test_namestore_api_zone_iteration.c 2016-07-09
14:29:34 UTC (rev 37513)
@@ -156,6 +156,32 @@
static void
+zone_end (void *cls)
+{
+ GNUNET_break (3 == returned_records);
+ if (3 == returned_records)
+ {
+ res = 0; /* Last iteraterator callback, we are done */
+ zi = NULL;
+ }
+ else
+ res = 1;
+
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Received last result, iteration done after receing %u
results\n",
+ returned_records);
+ GNUNET_SCHEDULER_add_now (&end, NULL);
+}
+
+
+static void
+fail_cb (void *cls)
+{
+ GNUNET_assert (0);
+}
+
+
+static void
zone_proc (void *cls,
const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone,
const char *label,
@@ -164,23 +190,6 @@
{
int failed = GNUNET_NO;
- if ((zone == NULL) && (label == NULL))
- {
- GNUNET_break (3 == returned_records);
- if (3 == returned_records)
- {
- res = 0; /* Last iteraterator callback, we are done */
- zi = NULL;
- }
- else
- res = 1;
-
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Received last result, iteration done after receing %u
results\n",
- returned_records);
- GNUNET_SCHEDULER_add_now (&end, NULL);
- return;
- }
GNUNET_assert (NULL != zone);
if (0 == memcmp (zone, privkey, sizeof (struct
GNUNET_CRYPTO_EcdsaPrivateKey)))
{
@@ -305,7 +314,11 @@
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "All records created, starting
iteration over all zones \n");
zi = GNUNET_NAMESTORE_zone_iteration_start (nsh,
NULL,
+ &fail_cb,
+ NULL,
&zone_proc,
+ NULL,
+ &zone_end,
NULL);
if (zi == NULL)
{
@@ -352,8 +365,6 @@
unsigned int rd_count,
const struct GNUNET_GNSRECORD_Data *rd)
{
- char *hostkey_file;
-
GNUNET_assert (nsh == cls);
if (NULL != zone)
{
@@ -375,18 +386,31 @@
endbadly_task = GNUNET_SCHEDULER_add_now (&endbadly, NULL);
return;
}
+ GNUNET_assert (0);
+}
+static void
+empty_zone_end (void *cls)
+{
+ char *hostkey_file;
+
zi = NULL;
- GNUNET_asprintf(&hostkey_file,"zonefiles%s%s",DIR_SEPARATOR_STR,
- "N0UJMP015AFUNR2BTNM3FKPBLG38913BL8IDMCO2H0A1LIB81960.zkey");
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Using zonekey file `%s' \n",
hostkey_file);
+ GNUNET_asprintf (&hostkey_file,
+ "zonefiles%s%s",
+ DIR_SEPARATOR_STR,
+
"N0UJMP015AFUNR2BTNM3FKPBLG38913BL8IDMCO2H0A1LIB81960.zkey");
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Using zonekey file `%s' \n",
+ hostkey_file);
privkey = GNUNET_CRYPTO_ecdsa_key_create_from_file(hostkey_file);
GNUNET_free (hostkey_file);
GNUNET_assert (privkey != NULL);
- GNUNET_asprintf(&hostkey_file,"zonefiles%s%s",DIR_SEPARATOR_STR,
- "HGU0A0VCU334DN7F2I9UIUMVQMM7JMSD142LIMNUGTTV9R0CF4EG.zkey");
+ GNUNET_asprintf (&hostkey_file,
+ "zonefiles%s%s",
+ DIR_SEPARATOR_STR,
+
"HGU0A0VCU334DN7F2I9UIUMVQMM7JMSD142LIMNUGTTV9R0CF4EG.zkey");
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Using zonekey file `%s' \n",
hostkey_file);
privkey2 = GNUNET_CRYPTO_ecdsa_key_create_from_file(hostkey_file);
GNUNET_free (hostkey_file);
@@ -396,7 +420,9 @@
GNUNET_asprintf(&s_name_1, "dummy1");
s_rd_1 = create_record(1);
- GNUNET_NAMESTORE_records_store (nsh, privkey, s_name_1,
+ GNUNET_NAMESTORE_records_store (nsh,
+ privkey,
+ s_name_1,
1, s_rd_1,
&put_cont, NULL);
@@ -404,8 +430,12 @@
"Created record 2 \n");
GNUNET_asprintf(&s_name_2, "dummy2");
s_rd_2 = create_record(1);
- GNUNET_NAMESTORE_records_store (nsh, privkey, s_name_2,
- 1, s_rd_2, &put_cont, NULL);
+ GNUNET_NAMESTORE_records_store (nsh,
+ privkey,
+ s_name_2,
+ 1, s_rd_2,
+ &put_cont,
+ NULL);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Created record 3\n");
@@ -436,7 +466,13 @@
GNUNET_break (NULL != nsh);
/* first, iterate over empty namestore */
zi = GNUNET_NAMESTORE_zone_iteration_start(nsh,
- NULL, &empty_zone_proc, nsh);
+ NULL,
+ &fail_cb,
+ NULL,
+ &empty_zone_proc,
+ nsh,
+ &empty_zone_end,
+ NULL);
if (NULL == zi)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to create zone iterator\n");
Modified: gnunet/src/namestore/test_namestore_api_zone_iteration_nick.c
===================================================================
--- gnunet/src/namestore/test_namestore_api_zone_iteration_nick.c
2016-07-08 19:35:27 UTC (rev 37512)
+++ gnunet/src/namestore/test_namestore_api_zone_iteration_nick.c
2016-07-09 14:29:34 UTC (rev 37513)
@@ -199,6 +199,18 @@
static void
+zone_proc_end (void *cls)
+{
+ zi = NULL;
+ res = 0;
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Received last result, iteration done after receing %u
results\n",
+ returned_records);
+ GNUNET_SCHEDULER_add_now (&end, NULL);
+}
+
+
+static void
zone_proc (void *cls,
const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone,
const char *label,
@@ -206,16 +218,7 @@
const struct GNUNET_GNSRECORD_Data *rd)
{
int failed = GNUNET_NO;
- if ((zone == NULL) && (label == NULL))
- {
- zi = NULL;
- res = 0;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Received last result, iteration done after receing %u
results\n",
- returned_records);
- GNUNET_SCHEDULER_add_now (&end, NULL);
- return;
- }
+
GNUNET_assert (NULL != zone);
if (0 == memcmp (zone, privkey, sizeof (struct
GNUNET_CRYPTO_EcdsaPrivateKey)))
{
@@ -254,6 +257,13 @@
static void
+fail_cb (void *cls)
+{
+ GNUNET_assert (0);
+}
+
+
+static void
put_cont (void *cls, int32_t success, const char *emsg)
{
static int c = 0;
@@ -281,7 +291,11 @@
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "All records created, starting
iteration over all zones \n");
zi = GNUNET_NAMESTORE_zone_iteration_start (nsh,
NULL,
+ &fail_cb,
+ NULL,
&zone_proc,
+ NULL,
+ &zone_proc_end,
NULL);
if (zi == NULL)
{
@@ -378,8 +392,8 @@
unsigned int rd_count,
const struct GNUNET_GNSRECORD_Data *rd)
{
- char *hostkey_file;
GNUNET_assert (nsh == cls);
+
if (NULL != zone)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
@@ -400,7 +414,16 @@
endbadly_task = GNUNET_SCHEDULER_add_now (&endbadly, NULL);
return;
}
+ GNUNET_assert (0);
+}
+
+static void
+empty_zone_end (void *cls)
+{
+ char *hostkey_file;
+ GNUNET_assert (nsh == cls);
+
zi = NULL;
GNUNET_asprintf(&hostkey_file,"zonefiles%s%s",DIR_SEPARATOR_STR,
"N0UJMP015AFUNR2BTNM3FKPBLG38913BL8IDMCO2H0A1LIB81960.zkey");
@@ -445,7 +468,13 @@
/* first, iterate over empty namestore */
zi = GNUNET_NAMESTORE_zone_iteration_start(nsh,
- NULL, &empty_zone_proc, nsh);
+ NULL,
+ &fail_cb,
+ NULL,
+ &empty_zone_proc,
+ nsh,
+ &empty_zone_end,
+ nsh);
if (NULL == zi)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
Modified: gnunet/src/namestore/test_namestore_api_zone_iteration_specific_zone.c
===================================================================
--- gnunet/src/namestore/test_namestore_api_zone_iteration_specific_zone.c
2016-07-08 19:35:27 UTC (rev 37512)
+++ gnunet/src/namestore/test_namestore_api_zone_iteration_specific_zone.c
2016-07-09 14:29:34 UTC (rev 37513)
@@ -156,30 +156,21 @@
static void
+fail_cb (void *cls)
+{
+ GNUNET_assert (0);
+}
+
+
+static void
zone_proc (void *cls,
- const struct
GNUNET_CRYPTO_EcdsaPrivateKey *zone,
- const char *label,
- unsigned int rd_count,
- const struct GNUNET_GNSRECORD_Data *rd)
+ const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone,
+ const char *label,
+ unsigned int rd_count,
+ const struct GNUNET_GNSRECORD_Data *rd)
{
int failed = GNUNET_NO;
- if ((zone == NULL) && (label == NULL))
- {
- GNUNET_break (2 == returned_records);
- if (2 == returned_records)
- {
- res = 0; /* Last iteraterator callback, we are done */
- zi = NULL;
- }
- else
- res = 1;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Received last result, iteration done after receing %u
results\n",
- returned_records );
- GNUNET_SCHEDULER_add_now (&end, NULL);
- return;
- }
GNUNET_assert (NULL != zone);
if (0 == memcmp (zone,
privkey,
@@ -258,6 +249,25 @@
static void
+zone_proc_end (void *cls)
+{
+ GNUNET_break (2 == returned_records);
+ if (2 == returned_records)
+ {
+ res = 0; /* Last iteraterator callback, we are done */
+ zi = NULL;
+ }
+ else
+ res = 1;
+
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Received last result, iteration done after receing %u
results\n",
+ returned_records);
+ GNUNET_SCHEDULER_add_now (&end, NULL);
+}
+
+
+static void
put_cont (void *cls, int32_t success, const char *emsg)
{
static int c = 0;
@@ -288,8 +298,12 @@
"All records created, starting iteration over all zones \n");
zi = GNUNET_NAMESTORE_zone_iteration_start(nsh,
privkey,
+ &fail_cb,
+ NULL,
&zone_proc,
- NULL);
+ NULL,
+ &zone_proc_end,
+ NULL);
if (zi == NULL)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
@@ -336,42 +350,55 @@
unsigned int rd_count,
const struct GNUNET_GNSRECORD_Data *rd)
{
- char *hostkey_file;
-
GNUNET_assert (nsh == cls);
if (NULL != zone)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- _("Expected empty zone but received zone private key\n"));
- GNUNET_break (0);
- if (endbadly_task != NULL)
- GNUNET_SCHEDULER_cancel (endbadly_task);
- endbadly_task = GNUNET_SCHEDULER_add_now (&endbadly, NULL);
- return;
- }
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ _("Expected empty zone but received zone private key\n"));
+ GNUNET_break (0);
+ if (endbadly_task != NULL)
+ GNUNET_SCHEDULER_cancel (endbadly_task);
+ endbadly_task = GNUNET_SCHEDULER_add_now (&endbadly, NULL);
+ return;
+ }
if ((NULL != label) || (NULL != rd) || (0 != rd_count))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- _("Expected no zone content but received data\n"));
- GNUNET_break (0);
- if (endbadly_task != NULL)
- GNUNET_SCHEDULER_cancel (endbadly_task);
- endbadly_task = GNUNET_SCHEDULER_add_now (&endbadly, NULL);
- return;
- }
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ _("Expected no zone content but received data\n"));
+ GNUNET_break (0);
+ if (endbadly_task != NULL)
+ GNUNET_SCHEDULER_cancel (endbadly_task);
+ endbadly_task = GNUNET_SCHEDULER_add_now (&endbadly, NULL);
+ return;
+ }
+ GNUNET_assert (0);
+}
+static void
+empty_zone_proc_end (void *cls)
+{
+ char *hostkey_file;
+
zi = NULL;
- GNUNET_asprintf(&hostkey_file,"zonefiles%s%s",DIR_SEPARATOR_STR,
- "N0UJMP015AFUNR2BTNM3FKPBLG38913BL8IDMCO2H0A1LIB81960.zkey");
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Using zonekey file `%s' \n",
hostkey_file);
- privkey = GNUNET_CRYPTO_ecdsa_key_create_from_file(hostkey_file);
+ GNUNET_asprintf (&hostkey_file,
+ "zonefiles%s%s",
+ DIR_SEPARATOR_STR,
+
"N0UJMP015AFUNR2BTNM3FKPBLG38913BL8IDMCO2H0A1LIB81960.zkey");
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Using zonekey file `%s'\n",
+ hostkey_file);
+ privkey = GNUNET_CRYPTO_ecdsa_key_create_from_file (hostkey_file);
GNUNET_free (hostkey_file);
GNUNET_assert (privkey != NULL);
- GNUNET_asprintf(&hostkey_file,"zonefiles%s%s",DIR_SEPARATOR_STR,
- "HGU0A0VCU334DN7F2I9UIUMVQMM7JMSD142LIMNUGTTV9R0CF4EG.zkey");
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Using zonekey file `%s' \n",
hostkey_file);
+ GNUNET_asprintf(&hostkey_file,
+ "zonefiles%s%s",
+ DIR_SEPARATOR_STR,
+ "HGU0A0VCU334DN7F2I9UIUMVQMM7JMSD142LIMNUGTTV9R0CF4EG.zkey");
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Using zonekey file `%s' \n",
+ hostkey_file);
privkey2 = GNUNET_CRYPTO_ecdsa_key_create_from_file(hostkey_file);
GNUNET_free (hostkey_file);
GNUNET_assert (privkey2 != NULL);
@@ -380,16 +407,26 @@
"Created record 1\n");
GNUNET_asprintf(&s_name_1, "dummy1");
- s_rd_1 = create_record(1);
- GNUNET_NAMESTORE_records_store(nsh, privkey, s_name_1,
- 1, s_rd_1, &put_cont, NULL);
+ s_rd_1 = create_record (1);
+ GNUNET_NAMESTORE_records_store (nsh,
+ privkey,
+ s_name_1,
+ 1,
+ s_rd_1,
+ &put_cont,
+ NULL);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Created record 2 \n");
GNUNET_asprintf(&s_name_2, "dummy2");
- s_rd_2 = create_record(1);
- GNUNET_NAMESTORE_records_store(nsh, privkey, s_name_2,
- 1, s_rd_2, &put_cont, NULL);
+ s_rd_2 = create_record (1);
+ GNUNET_NAMESTORE_records_store (nsh,
+ privkey,
+ s_name_2,
+ 1,
+ s_rd_2,
+ &put_cont,
+ NULL);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Created record 3\n");
@@ -396,9 +433,13 @@
/* name in different zone */
GNUNET_asprintf(&s_name_3, "dummy3");
- s_rd_3 = create_record(1);
- GNUNET_NAMESTORE_records_store(nsh, privkey2, s_name_3,
- 1, s_rd_3, &put_cont, NULL);
+ s_rd_3 = create_record (1);
+ GNUNET_NAMESTORE_records_store (nsh,
+ privkey2,
+ s_name_3,
+ 1, s_rd_3,
+ &put_cont,
+ NULL);
}
@@ -423,7 +464,12 @@
/* first, iterate over empty namestore */
zi = GNUNET_NAMESTORE_zone_iteration_start (nsh,
NULL,
- &empty_zone_proc, nsh);
+ &fail_cb,
+ NULL,
+ &empty_zone_proc,
+ nsh,
+ &empty_zone_proc_end,
+ nsh);
if (NULL == zi)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
Modified: gnunet/src/namestore/test_namestore_api_zone_iteration_stop.c
===================================================================
--- gnunet/src/namestore/test_namestore_api_zone_iteration_stop.c
2016-07-08 19:35:27 UTC (rev 37512)
+++ gnunet/src/namestore/test_namestore_api_zone_iteration_stop.c
2016-07-09 14:29:34 UTC (rev 37513)
@@ -156,6 +156,13 @@
static void
+fail_cb (void *cls)
+{
+ GNUNET_assert (0);
+}
+
+
+static void
zone_proc (void *cls,
const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone,
const char *label,
@@ -163,20 +170,7 @@
const struct GNUNET_GNSRECORD_Data *rd)
{
int failed = GNUNET_NO;
- if ((zone == NULL) && (label == NULL))
- {
- GNUNET_break (1 <= returned_records);
- if (1 >= returned_records)
- res = 1; /* Last iteraterator callback, we are done */
- else
- res = 0;
- zi = NULL;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Received last result, iteration done after receing %u
results\n",
- returned_records );
- GNUNET_SCHEDULER_add_now (&end, NULL);
- return;
- }
+
GNUNET_assert (NULL != zone);
if (0 == memcmp (zone, privkey, sizeof (struct
GNUNET_CRYPTO_EcdsaPrivateKey)))
{
@@ -288,6 +282,22 @@
static void
+zone_proc_end (void *cls)
+{
+ GNUNET_break (1 <= returned_records);
+ if (1 >= returned_records)
+ res = 1; /* Last iteraterator callback, we are done */
+ else
+ res = 0;
+ zi = NULL;
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Received last result, iteration done after receing %u
results\n",
+ returned_records);
+ GNUNET_SCHEDULER_add_now (&end, NULL);
+}
+
+
+static void
put_cont (void *cls, int32_t success, const char *emsg)
{
static int c = 0;
@@ -312,14 +322,20 @@
{
res = 1;
returned_records = 0;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "All records created, starting
iteration over all zones \n");
- zi = GNUNET_NAMESTORE_zone_iteration_start(nsh,
- NULL,
- &zone_proc,
- NULL);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "All records created, starting iteration over all zones \n");
+ zi = GNUNET_NAMESTORE_zone_iteration_start (nsh,
+ NULL,
+ &fail_cb,
+ NULL,
+ &zone_proc,
+ NULL,
+ &zone_proc_end,
+ NULL);
if (zi == NULL)
{
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to create zone iterator\n");
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Failed to create zone iterator\n");
GNUNET_break (0);
if (NULL != endbadly_task)
GNUNET_SCHEDULER_cancel (endbadly_task);
@@ -362,7 +378,6 @@
unsigned int rd_count,
const struct GNUNET_GNSRECORD_Data *rd)
{
- char *hostkey_file;
GNUNET_assert (nsh == cls);
if (NULL != zone)
@@ -385,42 +400,72 @@
endbadly_task = GNUNET_SCHEDULER_add_now (&endbadly, NULL);
return;
}
+ GNUNET_assert (0);
+}
+
+static void
+empty_zone_proc_end (void *cls)
+{
+ char *hostkey_file;
+
+ GNUNET_assert (nsh == cls);
zi = NULL;
- GNUNET_asprintf(&hostkey_file,"zonefiles%s%s",DIR_SEPARATOR_STR,
- "N0UJMP015AFUNR2BTNM3FKPBLG38913BL8IDMCO2H0A1LIB81960.zkey");
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Using zonekey file `%s' \n",
hostkey_file);
+ GNUNET_asprintf(&hostkey_file,
+ "zonefiles%s%s",
+ DIR_SEPARATOR_STR,
+ "N0UJMP015AFUNR2BTNM3FKPBLG38913BL8IDMCO2H0A1LIB81960.zkey");
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Using zonekey file `%s' \n",
+ hostkey_file);
privkey = GNUNET_CRYPTO_ecdsa_key_create_from_file(hostkey_file);
GNUNET_free (hostkey_file);
GNUNET_assert (privkey != NULL);
- GNUNET_asprintf(&hostkey_file,"zonefiles%s%s",DIR_SEPARATOR_STR,
- "HGU0A0VCU334DN7F2I9UIUMVQMM7JMSD142LIMNUGTTV9R0CF4EG.zkey");
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Using zonekey file `%s' \n",
hostkey_file);
+ GNUNET_asprintf (&hostkey_file,
+ "zonefiles%s%s",
+ DIR_SEPARATOR_STR,
+
"HGU0A0VCU334DN7F2I9UIUMVQMM7JMSD142LIMNUGTTV9R0CF4EG.zkey");
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Using zonekey file `%s'\n",
+ hostkey_file);
privkey2 = GNUNET_CRYPTO_ecdsa_key_create_from_file(hostkey_file);
GNUNET_free (hostkey_file);
GNUNET_assert (privkey2 != NULL);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Created record 1\n");
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Created record 1\n");
- GNUNET_asprintf(&s_name_1, "dummy1");
+ GNUNET_asprintf(&s_name_1,
+ "dummy1");
s_rd_1 = create_record(1);
GNUNET_NAMESTORE_records_store(nsh, privkey, s_name_1,
1, s_rd_1, &put_cont, NULL);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Created record 2 \n");
- GNUNET_asprintf(&s_name_2, "dummy2");
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Created record 2 \n");
+ GNUNET_asprintf(&s_name_2,
+ "dummy2");
s_rd_2 = create_record(1);
- GNUNET_NAMESTORE_records_store(nsh, privkey, s_name_2,
- 1, s_rd_2, &put_cont, NULL);
+ GNUNET_NAMESTORE_records_store (nsh,
+ privkey,
+ s_name_2,
+ 1,
+ s_rd_2,
+ &put_cont, NULL);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Created record 3\n");
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Created record 3\n");
/* name in different zone */
GNUNET_asprintf(&s_name_3, "dummy3");
s_rd_3 = create_record(1);
- GNUNET_NAMESTORE_records_store(nsh, privkey2, s_name_3,
- 1, s_rd_3, &put_cont, NULL);
+ GNUNET_NAMESTORE_records_store(nsh,
+ privkey2,
+ s_name_3,
+ 1,
+ s_rd_3,
+ &put_cont, NULL);
}
@@ -441,7 +486,13 @@
GNUNET_break (NULL != nsh);
/* first, iterate over empty namestore */
zi = GNUNET_NAMESTORE_zone_iteration_start(nsh,
- NULL, &empty_zone_proc, nsh);
+ NULL,
+ &fail_cb,
+ NULL,
+ &empty_zone_proc,
+ nsh,
+ &empty_zone_proc_end,
+ nsh);
if (NULL == zi)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
Modified: gnunet-gtk/src/conversation/gnunet-conversation-gtk_contacts.c
===================================================================
--- gnunet-gtk/src/conversation/gnunet-conversation-gtk_contacts.c
2016-07-08 19:35:27 UTC (rev 37512)
+++ gnunet-gtk/src/conversation/gnunet-conversation-gtk_contacts.c
2016-07-09 14:29:34 UTC (rev 37513)
@@ -172,13 +172,6 @@
gboolean is_public;
char *value;
- if (NULL == zone_key)
- {
- /* disconnect, clear (and possibly freeze) view */
- gtk_list_store_clear (contacts_liststore);
- gtk_widget_hide (contacts_treeview);
- return;
- }
do_display = FALSE;
value = NULL;
for (i = 0; i < rd_len; i++)
@@ -290,6 +283,20 @@
/**
+ * Function called once the monitor has disconnected from the
+ * database.
+ *
+ * @param cls closure
+ */
+static void
+freeze_view (void *cls)
+{
+ gtk_list_store_clear (contacts_liststore);
+ gtk_widget_hide (contacts_treeview);
+}
+
+
+/**
* A different zone was selected in the zone toggle bar. Load the
* appropriate zone.
*
@@ -322,7 +329,10 @@
zone_mon = GNUNET_NAMESTORE_zone_monitor_start (GCG_get_configuration (),
temp_zone_pkey,
GNUNET_YES,
+ &freeze_view,
+ NULL,
&display_record,
+ NULL,
&unfreeze_view,
NULL);
}
@@ -451,4 +461,3 @@
}
/* end of gnunet-conversation-gtk_contacts.c */
-
Modified: gnunet-gtk/src/conversation/gnunet-conversation-gtk_get_label.c
===================================================================
--- gnunet-gtk/src/conversation/gnunet-conversation-gtk_get_label.c
2016-07-08 19:35:27 UTC (rev 37512)
+++ gnunet-gtk/src/conversation/gnunet-conversation-gtk_get_label.c
2016-07-09 14:29:34 UTC (rev 37513)
@@ -45,6 +45,17 @@
/**
+ * Called on error communicating with the namestore.
+ */
+static void
+handle_error (void *cls)
+{
+ qe = NULL;
+ GCG_log (_("Error communicating with namestore!\n"));
+}
+
+
+/**
* Process a record that was stored in the namestore.
*
* @param cls closure, NULL
@@ -123,6 +134,8 @@
qe = GNUNET_NAMESTORE_records_lookup (GCG_IMPORT_get_namestore (),
pkey,
label,
+ &handle_error,
+ builder,
&handle_existing_records,
builder);
}
Modified: gnunet-gtk/src/conversation/gnunet-conversation-gtk_import.c
===================================================================
--- gnunet-gtk/src/conversation/gnunet-conversation-gtk_import.c
2016-07-08 19:35:27 UTC (rev 37512)
+++ gnunet-gtk/src/conversation/gnunet-conversation-gtk_import.c
2016-07-09 14:29:34 UTC (rev 37513)
@@ -251,7 +251,8 @@
add_phone_qe = GNUNET_NAMESTORE_records_store (ns,
zone,
label,
- rd_count + 1, rd_new,
+ rd_count + 1,
+ rd_new,
&add_phone_continuation,
NULL);
}
@@ -258,6 +259,19 @@
/**
+ * Called on error communicating with the namestore.
+ */
+static void
+handle_add_error (void *cls)
+{
+ add_phone_qe = NULL;
+ GCG_log (_("Error communicating with namestore!\n"));
+ GNUNET_free (phone_label);
+ phone_label = NULL;
+}
+
+
+/**
* Add the data from #my_rd under the #phone_label to the namestore.
*/
static void
@@ -273,6 +287,8 @@
add_phone_qe = GNUNET_NAMESTORE_records_lookup (ns,
&zone_pkey,
phone_label,
+ &handle_add_error,
+ NULL,
&add_phone_handle_existing_records,
NULL);
}
@@ -409,6 +425,19 @@
/**
+ * Called on error communicating with the namestore.
+ */
+static void
+handle_remove_error (void *cls)
+{
+ remove_phone_qe = NULL;
+ GCG_log (_("Error communicating with namestore!\n"));
+ if (GNUNET_YES == in_shutdown)
+ finish_shutdown ();
+}
+
+
+/**
* Remove previously added phone address from namestore.
*/
void
@@ -420,6 +449,8 @@
remove_phone_qe = GNUNET_NAMESTORE_records_lookup (ns,
&zone_pkey,
phone_label,
+ &handle_remove_error,
+ NULL,
&remove_phone_handle_existing_records,
NULL);
GNUNET_free (phone_label);
@@ -492,4 +523,3 @@
/* end of gnunet-conversation-gtk_import.c */
-
Modified: gnunet-gtk/src/conversation/gnunet-conversation-gtk_phone.c
===================================================================
--- gnunet-gtk/src/conversation/gnunet-conversation-gtk_phone.c 2016-07-08
19:35:27 UTC (rev 37512)
+++ gnunet-gtk/src/conversation/gnunet-conversation-gtk_phone.c 2016-07-09
14:29:34 UTC (rev 37513)
@@ -876,8 +876,6 @@
struct IncomingCall *ic = cls;
ic->qe = NULL;
- if (NULL == label)
- return;
GNUNET_free (ic->caller_id_str);
ic->caller_id_str = GNUNET_strdup (label);
}
@@ -884,6 +882,19 @@
/**
+ * Failed to talk to namestore.
+ */
+static void
+handle_reverse_error (void *cls)
+{
+ struct IncomingCall *ic = cls;
+
+ ic->qe = NULL;
+ GCG_log (_("Error communicating with namestore!\n"));
+}
+
+
+/**
* Function called with an event emitted by a phone.
*
* @param cls closure
@@ -917,6 +928,8 @@
ic->qe = GNUNET_NAMESTORE_zone_to_name (GCG_IMPORT_get_namestore (),
GNUNET_IDENTITY_ego_get_private_key (my_zone),
&ic->caller_id,
+ &handle_reverse_error,
+ ic,
&handle_reverse_lookup_result,
ic);
ic->caller_num = caller_num_gen++;
Modified: gnunet-gtk/src/fs/gnunet-fs-gtk.c
===================================================================
--- gnunet-gtk/src/fs/gnunet-fs-gtk.c 2016-07-08 19:35:27 UTC (rev 37512)
+++ gnunet-gtk/src/fs/gnunet-fs-gtk.c 2016-07-09 14:29:34 UTC (rev 37513)
@@ -562,6 +562,24 @@
}
+static void
+monitor_zone_error (void *cls)
+{
+ GtkListStore *ls;
+
+ ls = GTK_LIST_STORE (GNUNET_FS_GTK_get_main_window_object
("namespace_label_liststore"));
+ gtk_list_store_clear (ls);
+ gtk_widget_hide (GTK_WIDGET (GNUNET_FS_GTK_get_main_window_object
("main_window_search_namespace_combobox")));
+}
+
+
+static void
+monitor_zone_sync (void *cls)
+{
+ gtk_widget_show (GTK_WIDGET (GNUNET_FS_GTK_get_main_window_object
("main_window_search_namespace_combobox")));
+}
+
+
/**
* Process a record that was stored in the namestore in the
* "sks_zone". Adds (or removes) the respective label to the
@@ -588,11 +606,6 @@
gchar *label_gnu;
ls = GTK_LIST_STORE (GNUNET_FS_GTK_get_main_window_object
("namespace_label_liststore"));
- if (NULL == zone)
- {
- gtk_list_store_clear (ls);
- return;
- }
label_gnu = g_strdup_printf ("%s.%s",
label,
"gnu");
@@ -660,8 +673,11 @@
main_context.zm = GNUNET_NAMESTORE_zone_monitor_start (main_context.cfg,
main_context.sks_zone,
GNUNET_YES,
+ &monitor_zone_error,
+ NULL,
&monitor_zone_records,
NULL,
+ &monitor_zone_sync,
NULL);
}
Modified: gnunet-gtk/src/namestore/gnunet-namestore-gtk.c
===================================================================
--- gnunet-gtk/src/namestore/gnunet-namestore-gtk.c 2016-07-08 19:35:27 UTC
(rev 37512)
+++ gnunet-gtk/src/namestore/gnunet-namestore-gtk.c 2016-07-09 14:29:34 UTC
(rev 37513)
@@ -902,12 +902,6 @@
{
struct MoveOperationContext *moc = cls;
- if (NULL == label)
- {
- moc->it = NULL;
- merge_with_existing_records (moc, 0, NULL);
- return;
- }
if (0 != strcmp (label,
moc->edc->name))
{
@@ -921,6 +915,40 @@
/**
+ * Error communicating with database, complain to user.
+ *
+ * @param cls the `struct MoveOperationContext`
+ */
+static void
+handle_records_for_merge_error (void *cls)
+{
+ struct MoveOperationContext *moc = cls;
+ struct GNUNET_GTK_NAMESTORE_PluginEnvironment *edc = moc->edc;
+
+ show_error_message (_("Failed to communicate with database"),
+ _("Check that your peer is configured correctly."));
+ GNUNET_free (moc->data);
+ GNUNET_free (moc);
+ free_edit_dialog_context (edc);
+}
+
+
+/**
+ * Finished zone iteration. Proceed.
+ *
+ * @param cls the `struct MoveOperationContext`
+ */
+static void
+handle_records_for_merge_end (void *cls)
+{
+ struct MoveOperationContext *moc = cls;
+
+ moc->it = NULL;
+ merge_with_existing_records (moc, 0, NULL);
+}
+
+
+/**
* The edit dialog completed; update the namestore and the
* view based on the new values in @a edc.
*
@@ -1069,8 +1097,12 @@
GNUNET_CONTAINER_DLL_insert (moc_head, moc_tail, moc);
moc->it = GNUNET_NAMESTORE_zone_iteration_start (namestore,
pk,
+
&handle_records_for_merge_error,
+ moc,
&handle_records_for_merge,
- moc);
+ moc,
+
&handle_records_for_merge_end,
+ moc);
/* zone changed, remove record from old zone, add to new zone! */
if (GNUNET_YES == edc->old_record_in_namestore)
{
@@ -2237,6 +2269,33 @@
/**
+ * Function called once our model is again inconsistent with
+ * the current zone. Hides the view.
+ *
+ * @param cls NULL
+ */
+static void
+zone_iteration_error (void *cls)
+{
+ clear_zone_view ();
+ gtk_widget_hide (GTK_WIDGET (get_object ("gnunet_namestore_gtk_pseu_hbox")));
+#if HAVE_QRENCODE_H
+ setup_qrcode ();
+ gtk_widget_hide (GTK_WIDGET (get_object ("gnunet_namestore_gtk_qr_image")));
+ gtk_widget_hide (GTK_WIDGET (get_object
("gnunet_namestore_gtk_qr_saveas_button")));
+ gtk_widget_hide (GTK_WIDGET (get_object
("gnunet_namestore_gtk_qr_vseparator")));
+#else
+ gtk_widget_show (GTK_WIDGET (get_object ("gnunet_namestore_gtk_qr_image")));
+ gtk_widget_show (GTK_WIDGET (get_object
("gnunet_namestore_gtk_qr_saveas_button")));
+ gtk_widget_show (GTK_WIDGET (get_object
("gnunet_namestore_gtk_qr_vseparator")));
+#endif
+ gtk_widget_show (GTK_WIDGET (get_object
("gnunet_namestore_gtk_status_label")));
+ gtk_widget_hide (GTK_WIDGET (get_object
("gnunet_namestore_gtk_scrolledwindow")));
+ gtk_widget_hide (GTK_WIDGET (get_object
("gnunet_namestore_gtk_zone_combobox")));
+}
+
+
+/**
* Function called for each record in the current zone. Update the
* widgets accordingly.
*
@@ -2272,12 +2331,6 @@
GtkTreeIter sel_iter;
GtkTreePath *sel_path;
- if ((NULL == zone_key) && (NULL == name))
- {
- /* disconnect from namestore, clear view */
- clear_zone_view ();
- return;
- }
if ( (GNUNET_SYSERR == GNUNET_DNSPARSER_check_label (name)) &&
(0 != strcmp (name, GNUNET_GNS_MASTERZONE_STR)) )
{
@@ -2553,7 +2606,10 @@
#endif
zmon = GNUNET_NAMESTORE_zone_monitor_start (cfg, pkey,
GNUNET_YES,
+ &zone_iteration_error,
+ NULL,
&zone_iteration_proc,
+ NULL,
&zone_sync_proc,
NULL);
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r37513 - gnunet/src/gns gnunet/src/identity-provider gnunet/src/include gnunet/src/namestore gnunet-gtk/src/conversation gnunet-gtk/src/fs gnunet-gtk/src/namestore,
gnunet <=