diff options
author | Bart Polot <bart@net.in.tum.de> | 2014-07-25 03:30:03 +0000 |
---|---|---|
committer | Bart Polot <bart@net.in.tum.de> | 2014-07-25 03:30:03 +0000 |
commit | 2a2846ad95d7dbf88f6cd73bc9441b62cff4f6ed (patch) | |
tree | 63b6b42aebfc5346cc665f74bbb72e7a82ef39b3 /src/cadet/gnunet-service-cadet_channel.c | |
parent | c54f0c24042fd60ab328f5b4c42eb5a758706925 (diff) | |
download | gnunet-2a2846ad95d7dbf88f6cd73bc9441b62cff4f6ed.tar.gz gnunet-2a2846ad95d7dbf88f6cd73bc9441b62cff4f6ed.zip |
- fix handling of SYNACK corner case
Diffstat (limited to 'src/cadet/gnunet-service-cadet_channel.c')
-rw-r--r-- | src/cadet/gnunet-service-cadet_channel.c | 44 |
1 files changed, 19 insertions, 25 deletions
diff --git a/src/cadet/gnunet-service-cadet_channel.c b/src/cadet/gnunet-service-cadet_channel.c index 677c859ea..bd869a355 100644 --- a/src/cadet/gnunet-service-cadet_channel.c +++ b/src/cadet/gnunet-service-cadet_channel.c | |||
@@ -336,10 +336,9 @@ send_create (struct CadetChannel *ch); | |||
336 | * | 336 | * |
337 | * @param ch The channel to confirm. | 337 | * @param ch The channel to confirm. |
338 | * @param fwd Should we send a FWD ACK? (going dest->root) | 338 | * @param fwd Should we send a FWD ACK? (going dest->root) |
339 | * @param reaction This ACK is a reaction to a duplicate CREATE, don't save. | ||
340 | */ | 339 | */ |
341 | static void | 340 | static void |
342 | send_ack (struct CadetChannel *ch, int fwd, int reaction); | 341 | send_ack (struct CadetChannel *ch, int fwd); |
343 | 342 | ||
344 | 343 | ||
345 | 344 | ||
@@ -777,7 +776,7 @@ channel_recreate (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
777 | } | 776 | } |
778 | else if (rel == rel->ch->dest_rel) | 777 | else if (rel == rel->ch->dest_rel) |
779 | { | 778 | { |
780 | send_ack (rel->ch, GNUNET_YES, GNUNET_NO); | 779 | send_ack (rel->ch, GNUNET_YES); |
781 | } | 780 | } |
782 | else | 781 | else |
783 | { | 782 | { |
@@ -903,10 +902,9 @@ send_create (struct CadetChannel *ch) | |||
903 | * | 902 | * |
904 | * @param ch The channel to confirm. | 903 | * @param ch The channel to confirm. |
905 | * @param fwd Should we send a FWD ACK? (going dest->root) | 904 | * @param fwd Should we send a FWD ACK? (going dest->root) |
906 | * @param reaction This ACK is a reaction to a duplicate CREATE, don't save. | ||
907 | */ | 905 | */ |
908 | static void | 906 | static void |
909 | send_ack (struct CadetChannel *ch, int fwd, int reaction) | 907 | send_ack (struct CadetChannel *ch, int fwd) |
910 | { | 908 | { |
911 | struct GNUNET_CADET_ChannelManage msg; | 909 | struct GNUNET_CADET_ChannelManage msg; |
912 | 910 | ||
@@ -916,7 +914,7 @@ send_ack (struct CadetChannel *ch, int fwd, int reaction) | |||
916 | GC_f2s (fwd), GCCH_2s (ch)); | 914 | GC_f2s (fwd), GCCH_2s (ch)); |
917 | 915 | ||
918 | msg.chid = htonl (ch->gid); | 916 | msg.chid = htonl (ch->gid); |
919 | GCCH_send_prebuilt_message (&msg.header, ch, !fwd, reaction ? &msg : NULL); | 917 | GCCH_send_prebuilt_message (&msg.header, ch, !fwd, NULL); |
920 | } | 918 | } |
921 | 919 | ||
922 | 920 | ||
@@ -1186,19 +1184,16 @@ channel_confirm (struct CadetChannel *ch, int fwd) | |||
1186 | GCT_cancel (rel->uniq->tq); | 1184 | GCT_cancel (rel->uniq->tq); |
1187 | /* ch_message_sent will free and NULL uniq */ | 1185 | /* ch_message_sent will free and NULL uniq */ |
1188 | } | 1186 | } |
1189 | else | 1187 | else if (GNUNET_NO == is_loopback (ch)) |
1190 | { | 1188 | { |
1191 | if (GNUNET_NO == is_loopback (ch)) | 1189 | /* We SHOULD have been trying to retransmit this! */ |
1192 | { | 1190 | GNUNET_break (0); |
1193 | /* We SHOULD have been trying to retransmit this! */ | ||
1194 | GNUNET_break (0); | ||
1195 | } | ||
1196 | } | 1191 | } |
1197 | } | 1192 | } |
1198 | 1193 | ||
1199 | /* In case of a FWD ACK (SYNACK) send a BCK ACK (ACK). */ | 1194 | /* In case of a FWD ACK (SYNACK) send a BCK ACK (ACK). */ |
1200 | if (GNUNET_YES == fwd) | 1195 | if (GNUNET_YES == fwd) |
1201 | send_ack (ch, GNUNET_NO, GNUNET_NO); | 1196 | send_ack (ch, GNUNET_NO); |
1202 | } | 1197 | } |
1203 | 1198 | ||
1204 | 1199 | ||
@@ -2106,9 +2101,7 @@ GCCH_handle_create (struct CadetTunnel *t, | |||
2106 | struct CadetChannel *ch; | 2101 | struct CadetChannel *ch; |
2107 | struct CadetClient *c; | 2102 | struct CadetClient *c; |
2108 | int new_channel; | 2103 | int new_channel; |
2109 | int reaction; | ||
2110 | 2104 | ||
2111 | reaction = GNUNET_NO; | ||
2112 | chid = ntohl (msg->chid); | 2105 | chid = ntohl (msg->chid); |
2113 | ch = GCT_get_channel (t, chid); | 2106 | ch = GCT_get_channel (t, chid); |
2114 | if (NULL == ch) | 2107 | if (NULL == ch) |
@@ -2163,7 +2156,6 @@ GCCH_handle_create (struct CadetTunnel *t, | |||
2163 | else | 2156 | else |
2164 | { | 2157 | { |
2165 | LOG (GNUNET_ERROR_TYPE_DEBUG, " duplicate create channel\n"); | 2158 | LOG (GNUNET_ERROR_TYPE_DEBUG, " duplicate create channel\n"); |
2166 | reaction = GNUNET_YES; | ||
2167 | if (GNUNET_SCHEDULER_NO_TASK != ch->dest_rel->retry_task) | 2159 | if (GNUNET_SCHEDULER_NO_TASK != ch->dest_rel->retry_task) |
2168 | { | 2160 | { |
2169 | LOG (GNUNET_ERROR_TYPE_DEBUG, " clearing retry task\n"); | 2161 | LOG (GNUNET_ERROR_TYPE_DEBUG, " clearing retry task\n"); |
@@ -2171,8 +2163,13 @@ GCCH_handle_create (struct CadetTunnel *t, | |||
2171 | GNUNET_SCHEDULER_cancel (ch->dest_rel->retry_task); | 2163 | GNUNET_SCHEDULER_cancel (ch->dest_rel->retry_task); |
2172 | ch->dest_rel->retry_task = GNUNET_SCHEDULER_NO_TASK; | 2164 | ch->dest_rel->retry_task = GNUNET_SCHEDULER_NO_TASK; |
2173 | } | 2165 | } |
2166 | else if (NULL != ch->dest_rel->uniq) | ||
2167 | { | ||
2168 | /* we are waiting to for our 'SYNACK' to leave the queue, all done! */ | ||
2169 | return ch; | ||
2170 | } | ||
2174 | } | 2171 | } |
2175 | send_ack (ch, GNUNET_YES, reaction); | 2172 | send_ack (ch, GNUNET_YES); |
2176 | 2173 | ||
2177 | return ch; | 2174 | return ch; |
2178 | } | 2175 | } |
@@ -2360,16 +2357,9 @@ GCCH_send_prebuilt_message (const struct GNUNET_MessageHeader *message, | |||
2360 | break; | 2357 | break; |
2361 | 2358 | ||
2362 | 2359 | ||
2363 | case GNUNET_MESSAGE_TYPE_CADET_CHANNEL_ACK: | ||
2364 | if (GNUNET_YES == fwd || NULL != existing_copy) | ||
2365 | { | ||
2366 | /* BCK ACK (going FWD) is just a response for a SYNACK, don't keep*/ | ||
2367 | fire_and_forget (message, ch, GNUNET_YES); | ||
2368 | return; | ||
2369 | } | ||
2370 | /* fall-trough */ | ||
2371 | case GNUNET_MESSAGE_TYPE_CADET_DATA_ACK: | 2360 | case GNUNET_MESSAGE_TYPE_CADET_DATA_ACK: |
2372 | case GNUNET_MESSAGE_TYPE_CADET_CHANNEL_CREATE: | 2361 | case GNUNET_MESSAGE_TYPE_CADET_CHANNEL_CREATE: |
2362 | case GNUNET_MESSAGE_TYPE_CADET_CHANNEL_ACK: | ||
2373 | chq = GNUNET_new (struct CadetChannelQueue); | 2363 | chq = GNUNET_new (struct CadetChannelQueue); |
2374 | chq->type = type; | 2364 | chq->type = type; |
2375 | chq->rel = fwd ? ch->root_rel : ch->dest_rel; | 2365 | chq->rel = fwd ? ch->root_rel : ch->dest_rel; |
@@ -2379,6 +2369,7 @@ GCCH_send_prebuilt_message (const struct GNUNET_MessageHeader *message, | |||
2379 | { | 2369 | { |
2380 | GCT_cancel (chq->rel->uniq->tq); | 2370 | GCT_cancel (chq->rel->uniq->tq); |
2381 | /* ch_message_sent is called, freeing and NULLing uniq */ | 2371 | /* ch_message_sent is called, freeing and NULLing uniq */ |
2372 | GNUNET_break (NULL == chq->rel->uniq); | ||
2382 | } | 2373 | } |
2383 | else | 2374 | else |
2384 | { | 2375 | { |
@@ -2386,6 +2377,9 @@ GCCH_send_prebuilt_message (const struct GNUNET_MessageHeader *message, | |||
2386 | GNUNET_free (chq->rel->uniq); | 2377 | GNUNET_free (chq->rel->uniq); |
2387 | } | 2378 | } |
2388 | } | 2379 | } |
2380 | else | ||
2381 | GNUNET_break (0); | ||
2382 | |||
2389 | chq->tq = GCT_send_prebuilt_message (message, ch->t, NULL, GNUNET_YES, | 2383 | chq->tq = GCT_send_prebuilt_message (message, ch->t, NULL, GNUNET_YES, |
2390 | &ch_message_sent, chq); | 2384 | &ch_message_sent, chq); |
2391 | if (NULL == chq->tq) | 2385 | if (NULL == chq->tq) |