diff options
-rw-r--r-- | src/transport/gnunet-service-transport_ats.c | 17 | ||||
-rw-r--r-- | src/transport/gnunet-service-transport_ats.h | 14 | ||||
-rw-r--r-- | src/transport/gnunet-service-transport_validation.c | 12 |
3 files changed, 39 insertions, 4 deletions
diff --git a/src/transport/gnunet-service-transport_ats.c b/src/transport/gnunet-service-transport_ats.c index 55b5e20a17..74658822ec 100644 --- a/src/transport/gnunet-service-transport_ats.c +++ b/src/transport/gnunet-service-transport_ats.c @@ -249,11 +249,11 @@ find_ai_no_session (const struct GNUNET_HELLO_Address *address) /** - * Test if ATS knows about this address. + * Test if ATS knows about this @a address and @a session. * * @param address the address * @param session the session - * @return #GNUNET_YES if address is known, #GNUNET_NO if not. + * @return #GNUNET_YES if @a address is known, #GNUNET_NO if not. */ int GST_ats_is_known (const struct GNUNET_HELLO_Address *address, @@ -264,6 +264,19 @@ GST_ats_is_known (const struct GNUNET_HELLO_Address *address, /** + * Test if ATS knows about this @a address. + * + * @param address the address + * @return #GNUNET_YES if @a address is known, #GNUNET_NO if not. + */ +int +GST_ats_is_known_no_session (const struct GNUNET_HELLO_Address *address) +{ + return (NULL != find_ai_no_session (address)) ? GNUNET_YES : GNUNET_NO; +} + + +/** * The blocking time for an address has expired, allow ATS to * suggest it again. * diff --git a/src/transport/gnunet-service-transport_ats.h b/src/transport/gnunet-service-transport_ats.h index 323191a4d9..de0800d0a4 100644 --- a/src/transport/gnunet-service-transport_ats.h +++ b/src/transport/gnunet-service-transport_ats.h @@ -42,11 +42,11 @@ GST_ats_done (void); /** - * Test if ATS knows about this address. + * Test if ATS knows about this @a address and @a session. * * @param address the address * @param session the session - * @return #GNUNET_YES if address is known, #GNUNET_NO if not. + * @return #GNUNET_YES if @a address is known, #GNUNET_NO if not. */ int GST_ats_is_known (const struct GNUNET_HELLO_Address *address, @@ -54,6 +54,16 @@ GST_ats_is_known (const struct GNUNET_HELLO_Address *address, /** + * Test if ATS knows about this @a address. + * + * @param address the address + * @return #GNUNET_YES if @a address is known, #GNUNET_NO if not. + */ +int +GST_ats_is_known_no_session (const struct GNUNET_HELLO_Address *address); + + +/** * Temporarily block a valid address for use by ATS for address * suggestions. This function should be called if an address was * suggested by ATS but failed to perform (i.e. failure to establish a diff --git a/src/transport/gnunet-service-transport_validation.c b/src/transport/gnunet-service-transport_validation.c index 314eefaec2..66f9f5409c 100644 --- a/src/transport/gnunet-service-transport_validation.c +++ b/src/transport/gnunet-service-transport_validation.c @@ -429,6 +429,8 @@ cleanup_validation_entry (void *cls, if (GNUNET_YES == ve->known_to_ats) { GST_ats_expire_address (ve->address); + GNUNET_assert (GNUNET_NO == + GST_ats_is_known_no_session (ve->address)); ve->known_to_ats = GNUNET_NO; } GNUNET_HELLO_address_free (ve->address); @@ -781,6 +783,8 @@ find_validation_entry (const struct GNUNET_HELLO_Address *address) &validation_entry_match, &vemc); if (NULL != (ve = vemc.ve)) return ve; + GNUNET_assert (GNUNET_NO == + GST_ats_is_known_no_session (address)); ve = GNUNET_new (struct ValidationEntry); ve->in_use = GNUNET_SYSERR; /* not defined */ ve->address = GNUNET_HELLO_address_copy (address); @@ -859,6 +863,8 @@ add_valid_address (void *cls, { ve->known_to_ats = GNUNET_YES; GST_ats_add_address (address, &prop); + GNUNET_assert (GNUNET_YES == + GST_ats_is_known_no_session (ve->address)); } return GNUNET_OK; } @@ -1490,6 +1496,8 @@ GST_validation_handle_pong (const struct GNUNET_PeerIdentity *sender, { if (GNUNET_YES == ve->known_to_ats) { + GNUNET_assert (GNUNET_YES == + GST_ats_is_known_no_session (ve->address)); GST_ats_update_delay (ve->address, GNUNET_TIME_relative_divide (ve->latency, 2)); } @@ -1500,8 +1508,12 @@ GST_validation_handle_pong (const struct GNUNET_PeerIdentity *sender, memset (&prop, 0, sizeof (prop)); prop.scope = ve->network; prop.delay = GNUNET_TIME_relative_divide (ve->latency, 2); + GNUNET_assert (GNUNET_NO == + GST_ats_is_known_no_session (ve->address)); ve->known_to_ats = GNUNET_YES; GST_ats_add_address (ve->address, &prop); + GNUNET_assert (GNUNET_YES == + GST_ats_is_known_no_session (ve->address)); } } if (validations_running > 0) |