aboutsummaryrefslogtreecommitdiff
path: root/src/cadet
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2017-02-16 22:08:55 +0100
committerChristian Grothoff <christian@grothoff.org>2017-02-16 22:08:55 +0100
commitfe2f5348fd84240ad682692a68f333c44f358515 (patch)
treeee67fd099bc6121a73408d6f0dc9e95b3e39c9a1 /src/cadet
parentdd5a385e16168f9d4fe43dde53e49b77a15afa6e (diff)
downloadgnunet-fe2f5348fd84240ad682692a68f333c44f358515.tar.gz
gnunet-fe2f5348fd84240ad682692a68f333c44f358515.zip
introduce loose state, fix channel state machine
Diffstat (limited to 'src/cadet')
-rw-r--r--src/cadet/gnunet-service-cadet-new_channel.c28
1 files changed, 24 insertions, 4 deletions
diff --git a/src/cadet/gnunet-service-cadet-new_channel.c b/src/cadet/gnunet-service-cadet-new_channel.c
index 9d9edc28d..68220fe67 100644
--- a/src/cadet/gnunet-service-cadet-new_channel.c
+++ b/src/cadet/gnunet-service-cadet-new_channel.c
@@ -76,7 +76,7 @@
76 76
77 77
78/** 78/**
79 * All the states a connection can be in. 79 * All the states a channel can be in.
80 */ 80 */
81enum CadetChannelState 81enum CadetChannelState
82{ 82{
@@ -86,7 +86,13 @@ enum CadetChannelState
86 CADET_CHANNEL_NEW, 86 CADET_CHANNEL_NEW,
87 87
88 /** 88 /**
89 * Connection create message sent, waiting for ACK. 89 * Channel is to a port that is not open, we're waiting for the
90 * port to be opened.
91 */
92 CADET_CHANNEL_LOOSE,
93
94 /**
95 * CHANNEL_OPEN message sent, waiting for CHANNEL_OPEN_ACK.
90 */ 96 */
91 CADET_CHANNEL_OPEN_SENT, 97 CADET_CHANNEL_OPEN_SENT,
92 98
@@ -644,6 +650,7 @@ GCCH_channel_local_new (struct CadetClient *owner,
644 if (NULL == c) 650 if (NULL == c)
645 { 651 {
646 /* port closed, wait for it to possibly open */ 652 /* port closed, wait for it to possibly open */
653 ch->state = CADET_CHANNEL_LOOSE;
647 (void) GNUNET_CONTAINER_multihashmap_put (loose_channels, 654 (void) GNUNET_CONTAINER_multihashmap_put (loose_channels,
648 port, 655 port,
649 ch, 656 ch,
@@ -740,6 +747,7 @@ GCCH_channel_incoming_new (struct CadetTunnel *t,
740 if (NULL == c) 747 if (NULL == c)
741 { 748 {
742 /* port closed, wait for it to possibly open */ 749 /* port closed, wait for it to possibly open */
750 ch->state = CADET_CHANNEL_LOOSE;
743 (void) GNUNET_CONTAINER_multihashmap_put (loose_channels, 751 (void) GNUNET_CONTAINER_multihashmap_put (loose_channels,
744 port, 752 port,
745 ch, 753 ch,
@@ -977,6 +985,7 @@ GCCH_bind (struct CadetChannel *ch,
977 else 985 else
978 { 986 {
979 /* notify other peer that we accepted the connection */ 987 /* notify other peer that we accepted the connection */
988 ch->state = CADET_CHANNEL_READY;
980 ch->retry_control_task 989 ch->retry_control_task
981 = GNUNET_SCHEDULER_add_now (&send_open_ack, 990 = GNUNET_SCHEDULER_add_now (&send_open_ack,
982 ch); 991 ch);
@@ -1044,12 +1053,19 @@ GCCH_channel_local_destroy (struct CadetChannel *ch,
1044 return; 1053 return;
1045 } 1054 }
1046 /* If the we ever sent the CHANNEL_CREATE, we need to send a destroy message. */ 1055 /* If the we ever sent the CHANNEL_CREATE, we need to send a destroy message. */
1047 if (CADET_CHANNEL_NEW == ch->state) 1056 switch (ch->state)
1057 {
1058 case CADET_CHANNEL_NEW:
1059 GNUNET_break (0);
1060 break;
1061 case CADET_CHANNEL_LOOSE:
1048 GSC_drop_loose_channel (&ch->port, 1062 GSC_drop_loose_channel (&ch->port,
1049 ch); 1063 ch);
1050 else 1064 break;
1065 default:
1051 GCT_send_channel_destroy (ch->t, 1066 GCT_send_channel_destroy (ch->t,
1052 ch->ctn); 1067 ch->ctn);
1068 }
1053 /* Nothing left to do, just finish destruction */ 1069 /* Nothing left to do, just finish destruction */
1054 channel_destroy (ch); 1070 channel_destroy (ch);
1055} 1071}
@@ -1072,6 +1088,10 @@ GCCH_handle_channel_open_ack (struct CadetChannel *ch,
1072 /* this should be impossible */ 1088 /* this should be impossible */
1073 GNUNET_break (0); 1089 GNUNET_break (0);
1074 break; 1090 break;
1091 case CADET_CHANNEL_LOOSE:
1092 /* This makes no sense. */
1093 GNUNET_break_op (0);
1094 break;
1075 case CADET_CHANNEL_OPEN_SENT: 1095 case CADET_CHANNEL_OPEN_SENT:
1076 if (NULL == ch->owner) 1096 if (NULL == ch->owner)
1077 { 1097 {