diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2014-06-26 11:32:07 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2014-06-26 11:32:07 +0000 |
commit | c67882eaa194b1cf6eb11ed7eec0b1e3c3717499 (patch) | |
tree | e83e7bb49f5171d016f7189ac1ec20477274cce4 /src/transport/gnunet-service-transport_validation.c | |
parent | defbe9723888251205592d756315d743ae7a5fcc (diff) | |
download | gnunet-c67882eaa194b1cf6eb11ed7eec0b1e3c3717499.tar.gz gnunet-c67882eaa194b1cf6eb11ed7eec0b1e3c3717499.zip |
make delay computation readable
perform validation only if plugin is available, otherwise reschedule
Diffstat (limited to 'src/transport/gnunet-service-transport_validation.c')
-rw-r--r-- | src/transport/gnunet-service-transport_validation.c | 37 |
1 files changed, 32 insertions, 5 deletions
diff --git a/src/transport/gnunet-service-transport_validation.c b/src/transport/gnunet-service-transport_validation.c index 6312f7ea0..19e1379cb 100644 --- a/src/transport/gnunet-service-transport_validation.c +++ b/src/transport/gnunet-service-transport_validation.c | |||
@@ -656,11 +656,13 @@ revalidate_address (void *cls, | |||
656 | ve->revalidation_task = GNUNET_SCHEDULER_NO_TASK; | 656 | ve->revalidation_task = GNUNET_SCHEDULER_NO_TASK; |
657 | delay = GNUNET_TIME_absolute_get_remaining (ve->revalidation_block); | 657 | delay = GNUNET_TIME_absolute_get_remaining (ve->revalidation_block); |
658 | /* How long until we can possibly permit the next PING? */ | 658 | /* How long until we can possibly permit the next PING? */ |
659 | canonical_delay = | 659 | if (GNUNET_YES == ve->in_use) |
660 | (ve->in_use == | 660 | canonical_delay = CONNECTED_PING_FREQUENCY; |
661 | GNUNET_YES) ? CONNECTED_PING_FREQUENCY | 661 | else if (GNUNET_TIME_absolute_get_remaining (ve->valid_until).rel_value_us > 0) |
662 | : ((GNUNET_TIME_absolute_get_remaining (ve->valid_until).rel_value_us > | 662 | canonical_delay = VALIDATED_PING_FREQUENCY; |
663 | 0) ? VALIDATED_PING_FREQUENCY : UNVALIDATED_PING_KEEPALIVE); | 663 | else |
664 | canonical_delay = UNVALIDATED_PING_KEEPALIVE; | ||
665 | |||
664 | if (delay.rel_value_us > canonical_delay.rel_value_us * 2) | 666 | if (delay.rel_value_us > canonical_delay.rel_value_us * 2) |
665 | { | 667 | { |
666 | /* situation changed, recalculate delay */ | 668 | /* situation changed, recalculate delay */ |
@@ -1252,7 +1254,9 @@ validate_address_iterator (void *cls, | |||
1252 | struct GNUNET_TIME_Absolute expiration) | 1254 | struct GNUNET_TIME_Absolute expiration) |
1253 | { | 1255 | { |
1254 | const struct ValidateAddressContext *vac = cls; | 1256 | const struct ValidateAddressContext *vac = cls; |
1257 | struct GNUNET_TRANSPORT_PluginFunctions * papi; | ||
1255 | struct ValidationEntry *ve; | 1258 | struct ValidationEntry *ve; |
1259 | struct GNUNET_TIME_Relative canonical_delay; | ||
1256 | 1260 | ||
1257 | if (0 == GNUNET_TIME_absolute_get_remaining (expiration).rel_value_us) | 1261 | if (0 == GNUNET_TIME_absolute_get_remaining (expiration).rel_value_us) |
1258 | { | 1262 | { |
@@ -1261,6 +1265,29 @@ validate_address_iterator (void *cls, | |||
1261 | return GNUNET_OK; /* expired */ | 1265 | return GNUNET_OK; /* expired */ |
1262 | } | 1266 | } |
1263 | ve = find_validation_entry (&vac->public_key, address); | 1267 | ve = find_validation_entry (&vac->public_key, address); |
1268 | |||
1269 | papi = GST_plugins_find (ve->address->transport_name); | ||
1270 | if (papi == NULL) | ||
1271 | { | ||
1272 | /* This plugin is currently unvailable ... retry later */ | ||
1273 | if (GNUNET_SCHEDULER_NO_TASK == ve->revalidation_task) | ||
1274 | { | ||
1275 | if (ve->in_use == GNUNET_YES) | ||
1276 | { | ||
1277 | if (GNUNET_YES == ve->in_use) | ||
1278 | canonical_delay = CONNECTED_PING_FREQUENCY; | ||
1279 | else if (GNUNET_TIME_absolute_get_remaining (ve->valid_until).rel_value_us > 0) | ||
1280 | canonical_delay = VALIDATED_PING_FREQUENCY; | ||
1281 | else | ||
1282 | canonical_delay = UNVALIDATED_PING_KEEPALIVE; | ||
1283 | } | ||
1284 | ve->revalidation_task = GNUNET_SCHEDULER_add_delayed (canonical_delay, | ||
1285 | &revalidate_address, ve); | ||
1286 | } | ||
1287 | return GNUNET_OK; | ||
1288 | } | ||
1289 | |||
1290 | |||
1264 | if (GNUNET_SCHEDULER_NO_TASK == ve->revalidation_task) | 1291 | if (GNUNET_SCHEDULER_NO_TASK == ve->revalidation_task) |
1265 | { | 1292 | { |
1266 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 1293 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |