diff options
author | Christian Grothoff <christian@grothoff.org> | 2015-03-03 21:59:04 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2015-03-03 21:59:04 +0000 |
commit | 1aebcd292bfe9863fe1609ed6c055e4db83cce9f (patch) | |
tree | b651501ffe4f039cdd411bac657b252fd9f4eed9 /src/transport/gnunet-service-transport_ats.c | |
parent | fb1487e62d1c659c45e2997f80b76f7c7b8c824c (diff) | |
download | gnunet-1aebcd292bfe9863fe1609ed6c055e4db83cce9f.tar.gz gnunet-1aebcd292bfe9863fe1609ed6c055e4db83cce9f.zip |
possible fix for #3690
Diffstat (limited to 'src/transport/gnunet-service-transport_ats.c')
-rw-r--r-- | src/transport/gnunet-service-transport_ats.c | 50 |
1 files changed, 33 insertions, 17 deletions
diff --git a/src/transport/gnunet-service-transport_ats.c b/src/transport/gnunet-service-transport_ats.c index 3a321e786..8c3c5fed8 100644 --- a/src/transport/gnunet-service-transport_ats.c +++ b/src/transport/gnunet-service-transport_ats.c | |||
@@ -80,6 +80,12 @@ struct AddressInfo | |||
80 | */ | 80 | */ |
81 | struct GNUNET_SCHEDULER_Task *unblock_task; | 81 | struct GNUNET_SCHEDULER_Task *unblock_task; |
82 | 82 | ||
83 | /** | ||
84 | * Set to #GNUNET_YES if the address has expired but we could | ||
85 | * not yet remove it because we still have a valid session. | ||
86 | */ | ||
87 | int expired; | ||
88 | |||
83 | }; | 89 | }; |
84 | 90 | ||
85 | 91 | ||
@@ -330,7 +336,8 @@ GST_ats_block_address (const struct GNUNET_HELLO_Address *address, | |||
330 | /* destroy session and address */ | 336 | /* destroy session and address */ |
331 | if ( (NULL == session) || | 337 | if ( (NULL == session) || |
332 | (GNUNET_NO == | 338 | (GNUNET_NO == |
333 | GNUNET_ATS_address_del_session (ai->ar, session)) ) | 339 | GNUNET_ATS_address_del_session (ai->ar, |
340 | session)) ) | ||
334 | GNUNET_ATS_address_destroy (ai->ar); | 341 | GNUNET_ATS_address_destroy (ai->ar); |
335 | ai->ar = NULL; | 342 | ai->ar = NULL; |
336 | 343 | ||
@@ -534,7 +541,8 @@ GST_ats_del_session (const struct GNUNET_HELLO_Address *address, | |||
534 | GNUNET_break (0); | 541 | GNUNET_break (0); |
535 | return; | 542 | return; |
536 | } | 543 | } |
537 | ai = find_ai (address, session); | 544 | ai = find_ai (address, |
545 | session); | ||
538 | if (NULL == ai) | 546 | if (NULL == ai) |
539 | { | 547 | { |
540 | /* We sometimes create sessions just for sending a PING, | 548 | /* We sometimes create sessions just for sending a PING, |
@@ -555,18 +563,20 @@ GST_ats_del_session (const struct GNUNET_HELLO_Address *address, | |||
555 | GNUNET_i2s (&address->peer)); | 563 | GNUNET_i2s (&address->peer)); |
556 | if (NULL == ai->ar) | 564 | if (NULL == ai->ar) |
557 | { | 565 | { |
558 | /* If ATS doesn't know about the address/session, and this | 566 | /* If ATS doesn't know about the address/session, and this was an |
559 | was an inbound session that expired, then we must forget | 567 | inbound session or one that expired, then we must forget about |
560 | about the address as well. Otherwise, we are done as | 568 | the address as well. Otherwise, we are done as we have set |
561 | we have set `ai->session` to NULL already. */ | 569 | `ai->session` to NULL already. */ |
562 | if (GNUNET_YES == | 570 | if ( (GNUNET_YES == ai->expired) || |
563 | GNUNET_HELLO_address_check_option (address, | 571 | (GNUNET_YES == |
564 | GNUNET_HELLO_ADDRESS_INFO_INBOUND)) | 572 | GNUNET_HELLO_address_check_option (address, |
573 | GNUNET_HELLO_ADDRESS_INFO_INBOUND)) ) | ||
565 | GST_ats_expire_address (address); | 574 | GST_ats_expire_address (address); |
566 | return; | 575 | return; |
567 | } | 576 | } |
568 | if (GNUNET_YES == | 577 | if (GNUNET_YES == |
569 | GNUNET_ATS_address_del_session (ai->ar, session)) | 578 | GNUNET_ATS_address_del_session (ai->ar, |
579 | session)) | ||
570 | { | 580 | { |
571 | ai->ar = NULL; | 581 | ai->ar = NULL; |
572 | GST_ats_expire_address (address); | 582 | GST_ats_expire_address (address); |
@@ -689,11 +699,23 @@ GST_ats_expire_address (const struct GNUNET_HELLO_Address *address) | |||
689 | GNUNET_assert (0); | 699 | GNUNET_assert (0); |
690 | return; | 700 | return; |
691 | } | 701 | } |
702 | if (NULL != ai->unblock_task) | ||
703 | { | ||
704 | GNUNET_SCHEDULER_cancel (ai->unblock_task); | ||
705 | ai->unblock_task = NULL; | ||
706 | num_blocked--; | ||
707 | } | ||
708 | if (NULL != ai->session) | ||
709 | { | ||
710 | ai->expired = GNUNET_YES; | ||
711 | GNUNET_ATS_address_destroy (ai->ar); | ||
712 | ai->ar = NULL; | ||
713 | return; | ||
714 | } | ||
692 | GNUNET_assert (GNUNET_YES == | 715 | GNUNET_assert (GNUNET_YES == |
693 | GNUNET_CONTAINER_multipeermap_remove (p2a, | 716 | GNUNET_CONTAINER_multipeermap_remove (p2a, |
694 | &address->peer, | 717 | &address->peer, |
695 | ai)); | 718 | ai)); |
696 | GNUNET_break (NULL == ai->session); | ||
697 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 719 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
698 | "Telling ATS to destroy address from peer %s\n", | 720 | "Telling ATS to destroy address from peer %s\n", |
699 | GNUNET_i2s (&address->peer)); | 721 | GNUNET_i2s (&address->peer)); |
@@ -710,12 +732,6 @@ GST_ats_expire_address (const struct GNUNET_HELLO_Address *address) | |||
710 | GNUNET_ATS_address_destroy (ai->ar); | 732 | GNUNET_ATS_address_destroy (ai->ar); |
711 | ai->ar = NULL; | 733 | ai->ar = NULL; |
712 | } | 734 | } |
713 | if (NULL != ai->unblock_task) | ||
714 | { | ||
715 | GNUNET_SCHEDULER_cancel (ai->unblock_task); | ||
716 | ai->unblock_task = NULL; | ||
717 | num_blocked--; | ||
718 | } | ||
719 | publish_p2a_stat_update (); | 735 | publish_p2a_stat_update (); |
720 | GNUNET_HELLO_address_free (ai->address); | 736 | GNUNET_HELLO_address_free (ai->address); |
721 | GNUNET_free (ai); | 737 | GNUNET_free (ai); |