diff options
author | Bart Polot <bart@net.in.tum.de> | 2013-11-29 13:02:07 +0000 |
---|---|---|
committer | Bart Polot <bart@net.in.tum.de> | 2013-11-29 13:02:07 +0000 |
commit | 3a8fae3866a7bea35e500e6b131be4ef386516f1 (patch) | |
tree | 501e782899d731f93c81a6f77907c0778f98b596 | |
parent | c4e793586b16cb0351e3e72bf6a6d58f48befc3a (diff) | |
download | gnunet-3a8fae3866a7bea35e500e6b131be4ef386516f1.tar.gz gnunet-3a8fae3866a7bea35e500e6b131be4ef386516f1.zip |
- initialize timing info with real round trip time if available
- fix channel queues on unnecessary retransmissions
-rw-r--r-- | src/mesh/gnunet-service-mesh_channel.c | 42 |
1 files changed, 33 insertions, 9 deletions
diff --git a/src/mesh/gnunet-service-mesh_channel.c b/src/mesh/gnunet-service-mesh_channel.c index 799148e86..d876fbdfa 100644 --- a/src/mesh/gnunet-service-mesh_channel.c +++ b/src/mesh/gnunet-service-mesh_channel.c | |||
@@ -116,7 +116,7 @@ struct MeshReliableMessage | |||
116 | /** | 116 | /** |
117 | * Tunnel Queue. | 117 | * Tunnel Queue. |
118 | */ | 118 | */ |
119 | struct MeshTunnel3Queue *q; | 119 | struct MeshChannelQueue *q; |
120 | 120 | ||
121 | /** | 121 | /** |
122 | * When was this message issued (to calculate ACK delay) | 122 | * When was this message issued (to calculate ACK delay) |
@@ -391,7 +391,7 @@ add_destination (struct MeshChannel *ch, struct MeshClient *c) | |||
391 | GNUNET_break (NULL == ch->dest_rel); | 391 | GNUNET_break (NULL == ch->dest_rel); |
392 | ch->dest_rel = GNUNET_new (struct MeshChannelReliability); | 392 | ch->dest_rel = GNUNET_new (struct MeshChannelReliability); |
393 | ch->dest_rel->ch = ch; | 393 | ch->dest_rel->ch = ch; |
394 | ch->dest_rel->expected_delay = MESH_RETRANSMIT_TIME; | 394 | ch->dest_rel->expected_delay.rel_value_us = 0; |
395 | 395 | ||
396 | ch->dest = c; | 396 | ch->dest = c; |
397 | } | 397 | } |
@@ -734,9 +734,14 @@ rel_message_free (struct MeshReliableMessage *copy, int update_time) | |||
734 | if (update_time) | 734 | if (update_time) |
735 | { | 735 | { |
736 | time = GNUNET_TIME_absolute_get_duration (copy->timestamp); | 736 | time = GNUNET_TIME_absolute_get_duration (copy->timestamp); |
737 | rel->expected_delay.rel_value_us *= 7; | 737 | if (0 == rel->expected_delay.rel_value_us) |
738 | rel->expected_delay.rel_value_us += time.rel_value_us; | 738 | rel->expected_delay = time; |
739 | rel->expected_delay.rel_value_us /= 8; | 739 | else |
740 | { | ||
741 | rel->expected_delay.rel_value_us *= 7; | ||
742 | rel->expected_delay.rel_value_us += time.rel_value_us; | ||
743 | rel->expected_delay.rel_value_us /= 8; | ||
744 | } | ||
740 | LOG (GNUNET_ERROR_TYPE_DEBUG, "!!! took %s\n", | 745 | LOG (GNUNET_ERROR_TYPE_DEBUG, "!!! took %s\n", |
741 | GNUNET_STRINGS_relative_time_to_string (time, GNUNET_NO)); | 746 | GNUNET_STRINGS_relative_time_to_string (time, GNUNET_NO)); |
742 | LOG (GNUNET_ERROR_TYPE_DEBUG, "!!! new expected delay %s\n", | 747 | LOG (GNUNET_ERROR_TYPE_DEBUG, "!!! new expected delay %s\n", |
@@ -755,6 +760,10 @@ rel_message_free (struct MeshReliableMessage *copy, int update_time) | |||
755 | GMCH_destroy (rel->ch); | 760 | GMCH_destroy (rel->ch); |
756 | GMT_destroy_if_empty (t); | 761 | GMT_destroy_if_empty (t); |
757 | } | 762 | } |
763 | if (NULL != copy->q) | ||
764 | { | ||
765 | GMT_cancel (copy->q->q); | ||
766 | } | ||
758 | GNUNET_CONTAINER_DLL_remove (rel->head_sent, rel->tail_sent, copy); | 767 | GNUNET_CONTAINER_DLL_remove (rel->head_sent, rel->tail_sent, copy); |
759 | GNUNET_free (copy); | 768 | GNUNET_free (copy); |
760 | } | 769 | } |
@@ -871,14 +880,22 @@ ch_message_sent (void *cls, | |||
871 | rel = copy->rel; | 880 | rel = copy->rel; |
872 | if (GNUNET_SCHEDULER_NO_TASK == rel->retry_task) | 881 | if (GNUNET_SCHEDULER_NO_TASK == rel->retry_task) |
873 | { | 882 | { |
874 | rel->retry_timer = | 883 | if (0 != rel->expected_delay.rel_value_us) |
875 | GNUNET_TIME_relative_multiply (rel->expected_delay, | 884 | { |
876 | MESH_RETRANSMIT_MARGIN); | 885 | rel->retry_timer = |
886 | GNUNET_TIME_relative_multiply (rel->expected_delay, | ||
887 | MESH_RETRANSMIT_MARGIN); | ||
888 | } | ||
889 | else | ||
890 | { | ||
891 | rel->retry_timer = MESH_RETRANSMIT_TIME; | ||
892 | } | ||
877 | rel->retry_task = | 893 | rel->retry_task = |
878 | GNUNET_SCHEDULER_add_delayed (rel->retry_timer, | 894 | GNUNET_SCHEDULER_add_delayed (rel->retry_timer, |
879 | &channel_retransmit_message, | 895 | &channel_retransmit_message, |
880 | rel); | 896 | rel); |
881 | } | 897 | } |
898 | copy->q = NULL; | ||
882 | break; | 899 | break; |
883 | 900 | ||
884 | 901 | ||
@@ -1595,7 +1612,7 @@ GMCH_handle_local_create (struct MeshClient *c, | |||
1595 | /* In unreliable channels, we'll use the DLL to buffer BCK data */ | 1612 | /* In unreliable channels, we'll use the DLL to buffer BCK data */ |
1596 | ch->root_rel = GNUNET_new (struct MeshChannelReliability); | 1613 | ch->root_rel = GNUNET_new (struct MeshChannelReliability); |
1597 | ch->root_rel->ch = ch; | 1614 | ch->root_rel->ch = ch; |
1598 | ch->root_rel->expected_delay = MESH_RETRANSMIT_TIME; | 1615 | ch->root_rel->expected_delay.rel_value_us = 0; |
1599 | 1616 | ||
1600 | LOG (GNUNET_ERROR_TYPE_DEBUG, "CREATED CHANNEL %s\n", GMCH_2s (ch)); | 1617 | LOG (GNUNET_ERROR_TYPE_DEBUG, "CREATED CHANNEL %s\n", GMCH_2s (ch)); |
1601 | 1618 | ||
@@ -2007,7 +2024,14 @@ GMCH_send_prebuilt_message (const struct GNUNET_MessageHeader *message, | |||
2007 | if (NULL == existing_copy) | 2024 | if (NULL == existing_copy) |
2008 | q->copy = channel_save_copy (ch, message, fwd); | 2025 | q->copy = channel_save_copy (ch, message, fwd); |
2009 | else | 2026 | else |
2027 | { | ||
2010 | q->copy = (struct MeshReliableMessage *) existing_copy; | 2028 | q->copy = (struct MeshReliableMessage *) existing_copy; |
2029 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
2030 | " ### using existing copy: %p {r:0x%p q:0x%p t:%u}\n", | ||
2031 | existing_copy, | ||
2032 | q->copy->rel, q->copy->q, q->copy->type); | ||
2033 | } | ||
2034 | q->copy->q = q; | ||
2011 | q->q = GMT_send_prebuilt_message (message, ch->t, ch, | 2035 | q->q = GMT_send_prebuilt_message (message, ch->t, ch, |
2012 | fwd, NULL != existing_copy, | 2036 | fwd, NULL != existing_copy, |
2013 | &ch_message_sent, q); | 2037 | &ch_message_sent, q); |