diff options
author | Christian Grothoff <christian@grothoff.org> | 2017-02-16 21:55:13 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2017-02-16 21:55:13 +0100 |
commit | dd5a385e16168f9d4fe43dde53e49b77a15afa6e (patch) | |
tree | cceccebe61875948fd84963b8cdc836fa94be42a | |
parent | a8948252a3d4432018af33221db82ef2b8cde41b (diff) | |
download | gnunet-dd5a385e16168f9d4fe43dde53e49b77a15afa6e.tar.gz gnunet-dd5a385e16168f9d4fe43dde53e49b77a15afa6e.zip |
properly clean up unbound channels
-rw-r--r-- | src/cadet/gnunet-service-cadet-new.c | 18 | ||||
-rw-r--r-- | src/cadet/gnunet-service-cadet-new.h | 11 | ||||
-rw-r--r-- | src/cadet/gnunet-service-cadet-new_channel.c | 26 |
3 files changed, 49 insertions, 6 deletions
diff --git a/src/cadet/gnunet-service-cadet-new.c b/src/cadet/gnunet-service-cadet-new.c index 55c7d1bdb..1f28745e1 100644 --- a/src/cadet/gnunet-service-cadet-new.c +++ b/src/cadet/gnunet-service-cadet-new.c | |||
@@ -1200,6 +1200,24 @@ GSC_handle_remote_channel_destroy (struct CadetClient *c, | |||
1200 | 1200 | ||
1201 | 1201 | ||
1202 | /** | 1202 | /** |
1203 | * A client that created a loose channel that was not bound to a port | ||
1204 | * disconnected, drop it from the #loose_channels list. | ||
1205 | * | ||
1206 | * @param port the port the channel was trying to bind to | ||
1207 | * @param ch the channel that was lost | ||
1208 | */ | ||
1209 | void | ||
1210 | GSC_drop_loose_channel (const struct GNUNET_HashCode *port, | ||
1211 | struct CadetChannel *ch) | ||
1212 | { | ||
1213 | GNUNET_assert (GNUNET_YES == | ||
1214 | GNUNET_CONTAINER_multihashmap_remove (loose_channels, | ||
1215 | port, | ||
1216 | ch)); | ||
1217 | } | ||
1218 | |||
1219 | |||
1220 | /** | ||
1203 | * Iterator for deleting each channel whose client endpoint disconnected. | 1221 | * Iterator for deleting each channel whose client endpoint disconnected. |
1204 | * | 1222 | * |
1205 | * @param cls Closure (client that has disconnected). | 1223 | * @param cls Closure (client that has disconnected). |
diff --git a/src/cadet/gnunet-service-cadet-new.h b/src/cadet/gnunet-service-cadet-new.h index dff0d3c8c..bee5c67cc 100644 --- a/src/cadet/gnunet-service-cadet-new.h +++ b/src/cadet/gnunet-service-cadet-new.h | |||
@@ -264,6 +264,17 @@ GSC_handle_remote_channel_destroy (struct CadetClient *c, | |||
264 | struct GNUNET_CADET_ClientChannelNumber ccn, | 264 | struct GNUNET_CADET_ClientChannelNumber ccn, |
265 | struct CadetChannel *ch); | 265 | struct CadetChannel *ch); |
266 | 266 | ||
267 | /** | ||
268 | * A client that created a loose channel that was not bound to a port | ||
269 | * disconnected, drop it from the #loose_channels list. | ||
270 | * | ||
271 | * @param port the port the channel was trying to bind to | ||
272 | * @param ch the channel that was lost | ||
273 | */ | ||
274 | void | ||
275 | GSC_drop_loose_channel (const struct GNUNET_HashCode *port, | ||
276 | struct CadetChannel *ch); | ||
277 | |||
267 | 278 | ||
268 | /** | 279 | /** |
269 | * Bind incoming channel to this client, and notify client | 280 | * Bind incoming channel to this client, and notify client |
diff --git a/src/cadet/gnunet-service-cadet-new_channel.c b/src/cadet/gnunet-service-cadet-new_channel.c index fe3faef5a..9d9edc28d 100644 --- a/src/cadet/gnunet-service-cadet-new_channel.c +++ b/src/cadet/gnunet-service-cadet-new_channel.c | |||
@@ -1044,7 +1044,10 @@ GCCH_channel_local_destroy (struct CadetChannel *ch, | |||
1044 | return; | 1044 | return; |
1045 | } | 1045 | } |
1046 | /* If the we ever sent the CHANNEL_CREATE, we need to send a destroy message. */ | 1046 | /* If the we ever sent the CHANNEL_CREATE, we need to send a destroy message. */ |
1047 | if (CADET_CHANNEL_NEW != ch->state) | 1047 | if (CADET_CHANNEL_NEW == ch->state) |
1048 | GSC_drop_loose_channel (&ch->port, | ||
1049 | ch); | ||
1050 | else | ||
1048 | GCT_send_channel_destroy (ch->t, | 1051 | GCT_send_channel_destroy (ch->t, |
1049 | ch->ctn); | 1052 | ch->ctn); |
1050 | /* Nothing left to do, just finish destruction */ | 1053 | /* Nothing left to do, just finish destruction */ |
@@ -1710,6 +1713,11 @@ GCCH_handle_local_data (struct CadetChannel *ch, | |||
1710 | GNUNET_break (0); | 1713 | GNUNET_break (0); |
1711 | return GNUNET_SYSERR; | 1714 | return GNUNET_SYSERR; |
1712 | } | 1715 | } |
1716 | if (GNUNET_YES == ch->destroy) | ||
1717 | { | ||
1718 | /* we are going down, drop messages */ | ||
1719 | return GNUNET_OK; | ||
1720 | } | ||
1713 | ch->pending_messages++; | 1721 | ch->pending_messages++; |
1714 | 1722 | ||
1715 | if (GNUNET_YES == ch->is_loopback) | 1723 | if (GNUNET_YES == ch->is_loopback) |
@@ -1722,19 +1730,25 @@ GCCH_handle_local_data (struct CadetChannel *ch, | |||
1722 | env = GNUNET_MQ_msg_extra (ld, | 1730 | env = GNUNET_MQ_msg_extra (ld, |
1723 | buf_len, | 1731 | buf_len, |
1724 | GNUNET_MESSAGE_TYPE_CADET_LOCAL_DATA); | 1732 | GNUNET_MESSAGE_TYPE_CADET_LOCAL_DATA); |
1725 | if (sender_ccn.channel_of_client == | 1733 | if ( (NULL != ch->owner) && |
1726 | ch->owner->ccn.channel_of_client) | 1734 | (sender_ccn.channel_of_client == |
1735 | ch->owner->ccn.channel_of_client) ) | ||
1727 | { | 1736 | { |
1728 | receiver = ch->dest; | 1737 | receiver = ch->dest; |
1729 | to_owner = GNUNET_NO; | 1738 | to_owner = GNUNET_NO; |
1730 | } | 1739 | } |
1731 | else | 1740 | else if ( (NULL != ch->dest) && |
1741 | (sender_ccn.channel_of_client == | ||
1742 | ch->dest->ccn.channel_of_client) ) | ||
1732 | { | 1743 | { |
1733 | GNUNET_assert (sender_ccn.channel_of_client == | ||
1734 | ch->dest->ccn.channel_of_client); | ||
1735 | receiver = ch->owner; | 1744 | receiver = ch->owner; |
1736 | to_owner = GNUNET_YES; | 1745 | to_owner = GNUNET_YES; |
1737 | } | 1746 | } |
1747 | else | ||
1748 | { | ||
1749 | GNUNET_break (0); | ||
1750 | return GNUNET_SYSERR; | ||
1751 | } | ||
1738 | ld->ccn = receiver->ccn; | 1752 | ld->ccn = receiver->ccn; |
1739 | GNUNET_memcpy (&ld[1], | 1753 | GNUNET_memcpy (&ld[1], |
1740 | buf, | 1754 | buf, |