aboutsummaryrefslogtreecommitdiff
path: root/src/mesh
diff options
context:
space:
mode:
authorBart Polot <bart@net.in.tum.de>2013-11-15 15:53:38 +0000
committerBart Polot <bart@net.in.tum.de>2013-11-15 15:53:38 +0000
commit7686e0acf1799807ac1db8a8b292450ddb666b23 (patch)
tree65ed0b693e2bc600f0b863da4b4a7e1fe8081d44 /src/mesh
parent81cea2a6c4dece69f8b5e7ca1ce6eaabc05c625d (diff)
downloadgnunet-7686e0acf1799807ac1db8a8b292450ddb666b23.tar.gz
gnunet-7686e0acf1799807ac1db8a8b292450ddb666b23.zip
- initiate retransmit timer only after message has been sent
Diffstat (limited to 'src/mesh')
-rw-r--r--src/mesh/gnunet-service-mesh_channel.c56
1 files changed, 41 insertions, 15 deletions
diff --git a/src/mesh/gnunet-service-mesh_channel.c b/src/mesh/gnunet-service-mesh_channel.c
index 0228e8532..d3de56f92 100644
--- a/src/mesh/gnunet-service-mesh_channel.c
+++ b/src/mesh/gnunet-service-mesh_channel.c
@@ -87,6 +87,11 @@ struct MeshReliableMessage
87 */ 87 */
88 uint32_t mid; 88 uint32_t mid;
89 89
90 /**
91 * Tunnel Queue.
92 */
93 struct MeshTunnel3Queue *q;
94
90 /** 95 /**
91 * When was this message issued (to calculate ACK delay) 96 * When was this message issued (to calculate ACK delay)
92 */ 97 */
@@ -801,6 +806,28 @@ channel_confirm (struct MeshChannel *ch, int fwd)
801 channel_send_ack (ch, !fwd); 806 channel_send_ack (ch, !fwd);
802} 807}
803 808
809static void
810message_sent (void *cls,
811 struct MeshTunnel3 *t,
812 struct MeshTunnel3Queue *q,
813 uint16_t type, size_t size)
814{
815 struct MeshReliableMessage *copy = cls;
816 struct MeshChannelReliability *rel = copy->rel;
817
818 copy->timestamp = GNUNET_TIME_absolute_get ();
819 if (GNUNET_SCHEDULER_NO_TASK == rel->retry_task)
820 {
821 rel->retry_timer =
822 GNUNET_TIME_relative_multiply (rel->expected_delay,
823 MESH_RETRANSMIT_MARGIN);
824 rel->retry_task =
825 GNUNET_SCHEDULER_add_delayed (rel->retry_timer,
826 &channel_retransmit_message,
827 rel);
828 }
829}
830
804 831
805/** 832/**
806 * Save a copy to retransmit in case it gets lost. 833 * Save a copy to retransmit in case it gets lost.
@@ -811,7 +838,7 @@ channel_confirm (struct MeshChannel *ch, int fwd)
811 * @param msg Message to copy. 838 * @param msg Message to copy.
812 * @param fwd Is this fwd traffic? 839 * @param fwd Is this fwd traffic?
813 */ 840 */
814static void 841static struct MeshReliableMessage *
815channel_save_copy (struct MeshChannel *ch, 842channel_save_copy (struct MeshChannel *ch,
816 const struct GNUNET_MessageHeader *msg, 843 const struct GNUNET_MessageHeader *msg,
817 int fwd) 844 int fwd)
@@ -831,21 +858,12 @@ channel_save_copy (struct MeshChannel *ch,
831 mid, GNUNET_MESH_DEBUG_M2S (type)); 858 mid, GNUNET_MESH_DEBUG_M2S (type));
832 copy = GNUNET_malloc (sizeof (struct MeshReliableMessage) + size); 859 copy = GNUNET_malloc (sizeof (struct MeshReliableMessage) + size);
833 copy->mid = mid; 860 copy->mid = mid;
834 copy->timestamp = GNUNET_TIME_absolute_get ();
835 copy->rel = rel; 861 copy->rel = rel;
836 copy->type = type; 862 copy->type = type;
837 memcpy (&copy[1], msg, size); 863 memcpy (&copy[1], msg, size);
838 GNUNET_CONTAINER_DLL_insert_tail (rel->head_sent, rel->tail_sent, copy); 864 GNUNET_CONTAINER_DLL_insert_tail (rel->head_sent, rel->tail_sent, copy);
839 if (GNUNET_SCHEDULER_NO_TASK == rel->retry_task) 865
840 { 866 return copy;
841 rel->retry_timer =
842 GNUNET_TIME_relative_multiply (rel->expected_delay,
843 MESH_RETRANSMIT_MARGIN);
844 rel->retry_task =
845 GNUNET_SCHEDULER_add_delayed (rel->retry_timer,
846 &channel_retransmit_message,
847 rel);
848 }
849} 867}
850 868
851 869
@@ -1415,8 +1433,6 @@ GMCH_handle_local_data (struct MeshChannel *ch,
1415 payload->header.type = htons (GNUNET_MESSAGE_TYPE_MESH_DATA); 1433 payload->header.type = htons (GNUNET_MESSAGE_TYPE_MESH_DATA);
1416 payload->chid = htonl (ch->gid); 1434 payload->chid = htonl (ch->gid);
1417 LOG (GNUNET_ERROR_TYPE_DEBUG, " sending on channel...\n"); 1435 LOG (GNUNET_ERROR_TYPE_DEBUG, " sending on channel...\n");
1418 if (GNUNET_YES == ch->reliable)
1419 channel_save_copy (ch, &payload->header, fwd);
1420 GMCH_send_prebuilt_message (&payload->header, ch, fwd); 1436 GMCH_send_prebuilt_message (&payload->header, ch, fwd);
1421 1437
1422 if (is_loopback (ch)) 1438 if (is_loopback (ch))
@@ -1920,7 +1936,17 @@ GMCH_send_prebuilt_message (const struct GNUNET_MessageHeader *message,
1920 return; 1936 return;
1921 } 1937 }
1922 1938
1923 GMT_send_prebuilt_message (message, ch->t, ch, fwd, NULL, NULL); 1939 if (GNUNET_YES == ch->reliable
1940 && ntohs (message->type) == GNUNET_MESSAGE_TYPE_MESH_DATA)
1941 {
1942 struct MeshReliableMessage *copy;
1943
1944 copy = channel_save_copy (ch, message, fwd);
1945 copy->q = GMT_send_prebuilt_message (message, ch->t, ch, fwd,
1946 &message_sent, copy);
1947 }
1948 else
1949 GMT_send_prebuilt_message (message, ch->t, ch, fwd, NULL, NULL);
1924} 1950}
1925 1951
1926 1952