summaryrefslogtreecommitdiff
path: root/src/credential/gnunet-service-credential.c
diff options
context:
space:
mode:
authorAndreas Ebner <a.e.bner@web.de>2019-09-20 10:49:02 +0200
committerSchanzenbach, Martin <mschanzenbach@posteo.de>2019-10-07 12:18:20 +0200
commit3099a7c25cf6b11b0f1909e5a2651d65c0e921c7 (patch)
treec8f10fe3551b35e40d6adcb5e1c68771a12a104e /src/credential/gnunet-service-credential.c
parent5be14856a356b087ad97b479efd9b06172fdfd2f (diff)
Cleanup TODOs, bugfix in cleanup and start of bidirectional chain resolution:
- removed and/or implemented all remaining TODOs - fixed a bug in cleanup_handle() which caused to not cleanup correctly when a solution was prematurely found - delegation_chain_bw/fw_resolution_start() not has a return value to indicate whether a solution was prematurely found - cleaned up the test_... files (an additional cleanup commit might follow)
Diffstat (limited to 'src/credential/gnunet-service-credential.c')
-rw-r--r--src/credential/gnunet-service-credential.c62
1 files changed, 36 insertions, 26 deletions
diff --git a/src/credential/gnunet-service-credential.c b/src/credential/gnunet-service-credential.c
index 5ce0f70d9..daffc0bb9 100644
--- a/src/credential/gnunet-service-credential.c
+++ b/src/credential/gnunet-service-credential.c
@@ -429,26 +429,28 @@ cleanup_handle (struct VerifyRequestHandle *vrh)
struct DelegateRecordEntry *del_entry;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Cleaning up...\n");
- if (NULL == vrh->dsq_head)
- return;
-
- for (struct DelegationSetQueueEntry *ds_entry = vrh->dsq_head; NULL != vrh->dsq_head;
- ds_entry = vrh->dsq_head)
+ if (NULL != vrh->dsq_head)
{
- GNUNET_CONTAINER_DLL_remove (vrh->dsq_head, vrh->dsq_tail, ds_entry);
- cleanup_dsq_entry(ds_entry);
+ for (struct DelegationSetQueueEntry *ds_entry = vrh->dsq_head; NULL != vrh->dsq_head;
+ ds_entry = vrh->dsq_head)
+ {
+ GNUNET_CONTAINER_DLL_remove (vrh->dsq_head, vrh->dsq_tail, ds_entry);
+ cleanup_dsq_entry(ds_entry);
+ }
}
-
- GNUNET_free_non_null (vrh->issuer_attribute);
- for (del_entry = vrh->del_chain_head; NULL != vrh->del_chain_head;
- del_entry = vrh->del_chain_head)
+ if (NULL != vrh->del_chain_head)
{
- GNUNET_CONTAINER_DLL_remove (vrh->del_chain_head,
- vrh->del_chain_tail,
- del_entry);
- GNUNET_free_non_null (del_entry->delegate);
- GNUNET_free (del_entry);
+ for (del_entry = vrh->del_chain_head; NULL != vrh->del_chain_head;
+ del_entry = vrh->del_chain_head)
+ {
+ GNUNET_CONTAINER_DLL_remove (vrh->del_chain_head,
+ vrh->del_chain_tail,
+ del_entry);
+ GNUNET_free_non_null (del_entry->delegate);
+ GNUNET_free (del_entry);
+ }
}
+ GNUNET_free_non_null (vrh->issuer_attribute);
GNUNET_free (vrh);
}
@@ -622,7 +624,6 @@ send_lookup_response (struct VerifyRequestHandle *vrh)
GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (vrh->client), env);
GNUNET_CONTAINER_DLL_remove (vrh_head, vrh_tail, vrh);
cleanup_handle (vrh);
-
GNUNET_STATISTICS_update (statistics,
"Completed verifications",
1,
@@ -1217,7 +1218,7 @@ backward_resolution (void *cls,
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"%s still to go...\n",
ds_entry->attr_trailer);
- // TODO remove
+
vrh->pending_lookups++;
ds_entry->handle = vrh;
ds_entry->lookup_request =
@@ -1247,9 +1248,11 @@ backward_resolution (void *cls,
*
* @param cls the closure (our client lookup handle)
*/
-static void
+static int
delegation_chain_bw_resolution_start (void *cls)
{
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Start Backward Resolution...\n");
+
struct VerifyRequestHandle *vrh = cls;
struct DelegationSetQueueEntry *ds_entry;
struct DelegateRecordEntry *del_entry;
@@ -1258,7 +1261,7 @@ delegation_chain_bw_resolution_start (void *cls)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No delegates found\n");
send_lookup_response (vrh);
- return;
+ return 2;
}
// Pre-check with vrh->dele_chain_.. if match issuer_key
@@ -1281,7 +1284,7 @@ delegation_chain_bw_resolution_start (void *cls)
del_entry->refcount++;
// Found match prematurely
send_lookup_response (vrh);
- return;
+ return 1;
}
@@ -1321,11 +1324,14 @@ delegation_chain_bw_resolution_start (void *cls)
GNUNET_GNS_LO_DEFAULT,
&backward_resolution,
ds_entry);
+ return 0;
}
-static void
+static int
delegation_chain_fw_resolution_start (void *cls)
{
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Start Forward Resolution...\n");
+
struct VerifyRequestHandle *vrh = cls;
struct DelegationSetQueueEntry *ds_entry;
struct DelegateRecordEntry *del_entry;
@@ -1337,7 +1343,7 @@ delegation_chain_fw_resolution_start (void *cls)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No delegations found\n");
send_lookup_response (vrh);
- return;
+ return 2;
}
// Pre-check with vrh->dele_chain_.. if match issuer_key
@@ -1359,7 +1365,7 @@ delegation_chain_fw_resolution_start (void *cls)
del_entry->refcount++;
// Found match prematurely
send_lookup_response (vrh);
- return;
+ return 1;
}
// None match, therefore start for every delegation found a lookup chain
@@ -1409,6 +1415,7 @@ delegation_chain_fw_resolution_start (void *cls)
&forward_resolution,
ds_entry);
}
+ return 0;
}
static int
@@ -1528,7 +1535,8 @@ handle_verify (void *cls, const struct VerifyMessage *v_msg)
if (GNUNET_CREDENTIAL_FLAG_BACKWARD & vrh->resolution_algo &&
GNUNET_CREDENTIAL_FLAG_FORWARD & vrh->resolution_algo)
{
- delegation_chain_fw_resolution_start (vrh);
+ if(1 == delegation_chain_fw_resolution_start (vrh))
+ return;
delegation_chain_bw_resolution_start (vrh);
}
else if (GNUNET_CREDENTIAL_FLAG_BACKWARD & vrh->resolution_algo)
@@ -1561,7 +1569,9 @@ delegate_collection_finished (void *cls)
if (GNUNET_CREDENTIAL_FLAG_BACKWARD & vrh->resolution_algo &&
GNUNET_CREDENTIAL_FLAG_FORWARD & vrh->resolution_algo)
{
- delegation_chain_fw_resolution_start (vrh);
+ // if premature match found don't start bw resultion
+ if(1 == delegation_chain_fw_resolution_start (vrh))
+ return;
delegation_chain_bw_resolution_start (vrh);
}
else if (GNUNET_CREDENTIAL_FLAG_BACKWARD & vrh->resolution_algo)