diff options
author | Bart Polot <bart@net.in.tum.de> | 2013-11-30 01:56:03 +0000 |
---|---|---|
committer | Bart Polot <bart@net.in.tum.de> | 2013-11-30 01:56:03 +0000 |
commit | ede6e60c18989ecb4555a2ba5591217b13f354f0 (patch) | |
tree | e006a1b19a15d428b6152d79ec6b3ff35999d081 /src/mesh/gnunet-service-mesh_channel.c | |
parent | 4afa5e9f2c53547a504f8b8970ab422468df2ff0 (diff) | |
download | gnunet-ede6e60c18989ecb4555a2ba5591217b13f354f0.tar.gz gnunet-ede6e60c18989ecb4555a2ba5591217b13f354f0.zip |
- refactor
Diffstat (limited to 'src/mesh/gnunet-service-mesh_channel.c')
-rw-r--r-- | src/mesh/gnunet-service-mesh_channel.c | 43 |
1 files changed, 14 insertions, 29 deletions
diff --git a/src/mesh/gnunet-service-mesh_channel.c b/src/mesh/gnunet-service-mesh_channel.c index 8717c7dcd..ce54571cb 100644 --- a/src/mesh/gnunet-service-mesh_channel.c +++ b/src/mesh/gnunet-service-mesh_channel.c | |||
@@ -733,8 +733,6 @@ ch_message_sent (void *cls, | |||
733 | GNUNET_assert (rel->uniq == ch_q); | 733 | GNUNET_assert (rel->uniq == ch_q); |
734 | if (MESH_CHANNEL_READY != rel->ch->state) | 734 | if (MESH_CHANNEL_READY != rel->ch->state) |
735 | { | 735 | { |
736 | struct GNUNET_TIME_Relative delay; | ||
737 | |||
738 | GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == rel->retry_task); | 736 | GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == rel->retry_task); |
739 | rel->retry_timer = GNUNET_TIME_STD_BACKOFF (rel->retry_timer); | 737 | rel->retry_timer = GNUNET_TIME_STD_BACKOFF (rel->retry_timer); |
740 | rel->retry_task = GNUNET_SCHEDULER_add_delayed (rel->retry_timer, | 738 | rel->retry_task = GNUNET_SCHEDULER_add_delayed (rel->retry_timer, |
@@ -761,7 +759,6 @@ static void | |||
761 | send_create (struct MeshChannel *ch) | 759 | send_create (struct MeshChannel *ch) |
762 | { | 760 | { |
763 | struct GNUNET_MESH_ChannelCreate msgcc; | 761 | struct GNUNET_MESH_ChannelCreate msgcc; |
764 | struct MeshChannelQueue *q; | ||
765 | 762 | ||
766 | msgcc.header.size = htons (sizeof (msgcc)); | 763 | msgcc.header.size = htons (sizeof (msgcc)); |
767 | msgcc.header.type = htons (GNUNET_MESSAGE_TYPE_MESH_CHANNEL_CREATE); | 764 | msgcc.header.type = htons (GNUNET_MESSAGE_TYPE_MESH_CHANNEL_CREATE); |
@@ -769,14 +766,7 @@ send_create (struct MeshChannel *ch) | |||
769 | msgcc.port = htonl (ch->port); | 766 | msgcc.port = htonl (ch->port); |
770 | msgcc.opt = htonl (channel_get_options (ch)); | 767 | msgcc.opt = htonl (channel_get_options (ch)); |
771 | 768 | ||
772 | q = GNUNET_new (struct MeshChannelQueue); | 769 | GMCH_send_prebuilt_message (&msgcc.header, ch, GNUNET_YES, NULL); |
773 | q->rel = ch->root_rel; | ||
774 | |||
775 | /* FIXME cancel on confirm */ | ||
776 | q->q = GMT_send_prebuilt_message (&msgcc.header, ch->t, ch, | ||
777 | GNUNET_YES, GNUNET_YES, | ||
778 | ch_message_sent, q); | ||
779 | q->rel->uniq = q; | ||
780 | } | 770 | } |
781 | 771 | ||
782 | 772 | ||
@@ -2111,6 +2101,7 @@ GMCH_send_prebuilt_message (const struct GNUNET_MessageHeader *message, | |||
2111 | struct MeshChannel *ch, int fwd, | 2101 | struct MeshChannel *ch, int fwd, |
2112 | void *existing_copy) | 2102 | void *existing_copy) |
2113 | { | 2103 | { |
2104 | struct MeshChannelQueue *q; | ||
2114 | uint16_t type; | 2105 | uint16_t type; |
2115 | 2106 | ||
2116 | type = ntohs (message->type); | 2107 | type = ntohs (message->type); |
@@ -2130,8 +2121,6 @@ GMCH_send_prebuilt_message (const struct GNUNET_MessageHeader *message, | |||
2130 | 2121 | ||
2131 | if (GNUNET_YES == ch->reliable) | 2122 | if (GNUNET_YES == ch->reliable) |
2132 | { | 2123 | { |
2133 | struct MeshChannelQueue *q; | ||
2134 | |||
2135 | q = GNUNET_new (struct MeshChannelQueue); | 2124 | q = GNUNET_new (struct MeshChannelQueue); |
2136 | q->type = type; | 2125 | q->type = type; |
2137 | if (NULL == existing_copy) | 2126 | if (NULL == existing_copy) |
@@ -2173,25 +2162,21 @@ GMCH_send_prebuilt_message (const struct GNUNET_MessageHeader *message, | |||
2173 | } | 2162 | } |
2174 | break; | 2163 | break; |
2175 | 2164 | ||
2176 | 2165 | ||
2177 | case GNUNET_MESSAGE_TYPE_MESH_DATA_ACK: | 2166 | case GNUNET_MESSAGE_TYPE_MESH_DATA_ACK: |
2167 | case GNUNET_MESSAGE_TYPE_MESH_CHANNEL_CREATE: | ||
2168 | q = GNUNET_new (struct MeshChannelQueue); | ||
2169 | q->type = type; | ||
2170 | q->rel = fwd ? ch->root_rel : ch->dest_rel; | ||
2171 | if (NULL != q->rel->uniq) | ||
2178 | { | 2172 | { |
2179 | struct MeshChannelReliability *rel; | 2173 | GMT_cancel (q->rel->uniq->q); |
2180 | 2174 | /* ch_message_sent is called, freeing and NULLing uniq */ | |
2181 | rel = fwd ? ch->root_rel : ch->dest_rel; | ||
2182 | if (NULL != rel->uniq) | ||
2183 | { | ||
2184 | GMT_cancel (rel->uniq->q); | ||
2185 | /* ch_message_sent is called, freeing ack_q */ | ||
2186 | } | ||
2187 | rel->uniq = GNUNET_new (struct MeshChannelQueue); | ||
2188 | rel->uniq->type = type; | ||
2189 | rel->uniq->rel = rel; | ||
2190 | rel->uniq->q = GMT_send_prebuilt_message (message, ch->t, ch, | ||
2191 | fwd, GNUNET_YES, | ||
2192 | &ch_message_sent, | ||
2193 | rel->uniq); | ||
2194 | } | 2175 | } |
2176 | q->q = GMT_send_prebuilt_message (message, ch->t, ch, | ||
2177 | fwd, GNUNET_YES, | ||
2178 | &ch_message_sent, q); | ||
2179 | q->rel->uniq = q; | ||
2195 | break; | 2180 | break; |
2196 | 2181 | ||
2197 | 2182 | ||