From: Christian Grothoff Date: Thu, 16 Feb 2017 21:08:55 +0000 (+0100) Subject: introduce loose state, fix channel state machine X-Git-Tag: taler-0.2.1~166 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=fe2f5348fd84240ad682692a68f333c44f358515;p=oweals%2Fgnunet.git introduce loose state, fix channel state machine --- 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 @@ /** - * All the states a connection can be in. + * All the states a channel can be in. */ enum CadetChannelState { @@ -86,7 +86,13 @@ enum CadetChannelState CADET_CHANNEL_NEW, /** - * Connection create message sent, waiting for ACK. + * Channel is to a port that is not open, we're waiting for the + * port to be opened. + */ + CADET_CHANNEL_LOOSE, + + /** + * CHANNEL_OPEN message sent, waiting for CHANNEL_OPEN_ACK. */ CADET_CHANNEL_OPEN_SENT, @@ -644,6 +650,7 @@ GCCH_channel_local_new (struct CadetClient *owner, if (NULL == c) { /* port closed, wait for it to possibly open */ + ch->state = CADET_CHANNEL_LOOSE; (void) GNUNET_CONTAINER_multihashmap_put (loose_channels, port, ch, @@ -740,6 +747,7 @@ GCCH_channel_incoming_new (struct CadetTunnel *t, if (NULL == c) { /* port closed, wait for it to possibly open */ + ch->state = CADET_CHANNEL_LOOSE; (void) GNUNET_CONTAINER_multihashmap_put (loose_channels, port, ch, @@ -977,6 +985,7 @@ GCCH_bind (struct CadetChannel *ch, else { /* notify other peer that we accepted the connection */ + ch->state = CADET_CHANNEL_READY; ch->retry_control_task = GNUNET_SCHEDULER_add_now (&send_open_ack, ch); @@ -1044,12 +1053,19 @@ GCCH_channel_local_destroy (struct CadetChannel *ch, return; } /* If the we ever sent the CHANNEL_CREATE, we need to send a destroy message. */ - if (CADET_CHANNEL_NEW == ch->state) + switch (ch->state) + { + case CADET_CHANNEL_NEW: + GNUNET_break (0); + break; + case CADET_CHANNEL_LOOSE: GSC_drop_loose_channel (&ch->port, ch); - else + break; + default: GCT_send_channel_destroy (ch->t, ch->ctn); + } /* Nothing left to do, just finish destruction */ channel_destroy (ch); } @@ -1072,6 +1088,10 @@ GCCH_handle_channel_open_ack (struct CadetChannel *ch, /* this should be impossible */ GNUNET_break (0); break; + case CADET_CHANNEL_LOOSE: + /* This makes no sense. */ + GNUNET_break_op (0); + break; case CADET_CHANNEL_OPEN_SENT: if (NULL == ch->owner) {