diff options
-rw-r--r-- | src/cadet/cadet.conf.in | 2 | ||||
-rw-r--r-- | src/cadet/gnunet-service-cadet-new.c | 9 | ||||
-rw-r--r-- | src/cadet/gnunet-service-cadet-new_channel.c | 74 |
3 files changed, 54 insertions, 31 deletions
diff --git a/src/cadet/cadet.conf.in b/src/cadet/cadet.conf.in index 86ba2e535..296a648e2 100644 --- a/src/cadet/cadet.conf.in +++ b/src/cadet/cadet.conf.in | |||
@@ -4,7 +4,7 @@ AUTOSTART = @AUTOSTART@ | |||
4 | @JAVAPORT@PORT = 2096 | 4 | @JAVAPORT@PORT = 2096 |
5 | HOSTNAME = localhost | 5 | HOSTNAME = localhost |
6 | BINARY = gnunet-service-cadet-new | 6 | BINARY = gnunet-service-cadet-new |
7 | # PREFIX = valgrind --leak-check=yes | 7 | PREFIX = valgrind --leak-check=yes |
8 | ACCEPT_FROM = 127.0.0.1; | 8 | ACCEPT_FROM = 127.0.0.1; |
9 | ACCEPT_FROM6 = ::1; | 9 | ACCEPT_FROM6 = ::1; |
10 | UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-service-cadet.sock | 10 | UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-service-cadet.sock |
diff --git a/src/cadet/gnunet-service-cadet-new.c b/src/cadet/gnunet-service-cadet-new.c index 1f28745e1..b16767fbb 100644 --- a/src/cadet/gnunet-service-cadet-new.c +++ b/src/cadet/gnunet-service-cadet-new.c | |||
@@ -1238,14 +1238,14 @@ channel_destroy_iterator (void *cls, | |||
1238 | "Destroying %s, due to %s disconnecting.\n", | 1238 | "Destroying %s, due to %s disconnecting.\n", |
1239 | GCCH_2s (ch), | 1239 | GCCH_2s (ch), |
1240 | GSC_2s (c)); | 1240 | GSC_2s (c)); |
1241 | GNUNET_assert (GNUNET_YES == | ||
1242 | GNUNET_CONTAINER_multihashmap32_remove (c->channels, | ||
1243 | key, | ||
1244 | ch)); | ||
1245 | ccn.channel_of_client = htonl (key); | 1241 | ccn.channel_of_client = htonl (key); |
1246 | GCCH_channel_local_destroy (ch, | 1242 | GCCH_channel_local_destroy (ch, |
1247 | c, | 1243 | c, |
1248 | ccn); | 1244 | ccn); |
1245 | GNUNET_assert (GNUNET_YES == | ||
1246 | GNUNET_CONTAINER_multihashmap32_remove (c->channels, | ||
1247 | key, | ||
1248 | ch)); | ||
1249 | return GNUNET_OK; | 1249 | return GNUNET_OK; |
1250 | } | 1250 | } |
1251 | 1251 | ||
@@ -1304,6 +1304,7 @@ client_disconnect_cb (void *cls, | |||
1304 | GNUNET_CONTAINER_multihashmap32_iterate (c->channels, | 1304 | GNUNET_CONTAINER_multihashmap32_iterate (c->channels, |
1305 | &channel_destroy_iterator, | 1305 | &channel_destroy_iterator, |
1306 | c); | 1306 | c); |
1307 | GNUNET_assert (0 == GNUNET_CONTAINER_multihashmap32_size (c->channels)); | ||
1307 | GNUNET_CONTAINER_multihashmap32_destroy (c->channels); | 1308 | GNUNET_CONTAINER_multihashmap32_destroy (c->channels); |
1308 | } | 1309 | } |
1309 | if (NULL != c->ports) | 1310 | if (NULL != c->ports) |
diff --git a/src/cadet/gnunet-service-cadet-new_channel.c b/src/cadet/gnunet-service-cadet-new_channel.c index 828c3daa7..9f565a7f4 100644 --- a/src/cadet/gnunet-service-cadet-new_channel.c +++ b/src/cadet/gnunet-service-cadet-new_channel.c | |||
@@ -661,11 +661,8 @@ GCCH_channel_local_new (struct CadetClient *owner, | |||
661 | } | 661 | } |
662 | else | 662 | else |
663 | { | 663 | { |
664 | ch->dest = GNUNET_new (struct CadetChannelClient); | ||
665 | ch->dest->c = c; | ||
666 | ch->dest->client_ready = GNUNET_YES; | ||
667 | GCCH_bind (ch, | 664 | GCCH_bind (ch, |
668 | ch->dest->c); | 665 | c); |
669 | } | 666 | } |
670 | } | 667 | } |
671 | else | 668 | else |
@@ -962,6 +959,7 @@ GCCH_bind (struct CadetChannel *ch, | |||
962 | if (ch->out_of_order) | 959 | if (ch->out_of_order) |
963 | options |= GNUNET_CADET_OPTION_OUT_OF_ORDER; | 960 | options |= GNUNET_CADET_OPTION_OUT_OF_ORDER; |
964 | cccd = GNUNET_new (struct CadetChannelClient); | 961 | cccd = GNUNET_new (struct CadetChannelClient); |
962 | GNUNET_assert (NULL == ch->dest); | ||
965 | ch->dest = cccd; | 963 | ch->dest = cccd; |
966 | cccd->c = c; | 964 | cccd->c = c; |
967 | cccd->client_ready = GNUNET_YES; | 965 | cccd->client_ready = GNUNET_YES; |
@@ -1000,6 +998,28 @@ GCCH_bind (struct CadetChannel *ch, | |||
1000 | 998 | ||
1001 | 999 | ||
1002 | /** | 1000 | /** |
1001 | * One of our clients has disconnected, tell the other one that we | ||
1002 | * are finished. Done asynchronously to avoid concurrent modification | ||
1003 | * issues if this is the same client. | ||
1004 | * | ||
1005 | * @param cls the `struct CadetChannel` where one of the ends is now dead | ||
1006 | */ | ||
1007 | static void | ||
1008 | signal_remote_destroy_cb (void *cls) | ||
1009 | { | ||
1010 | struct CadetChannel *ch = cls; | ||
1011 | struct CadetChannelClient *ccc; | ||
1012 | |||
1013 | /* Find which end is left... */ | ||
1014 | ccc = (NULL != ch->owner) ? ch->owner : ch->dest; | ||
1015 | GSC_handle_remote_channel_destroy (ccc->c, | ||
1016 | ccc->ccn, | ||
1017 | ch); | ||
1018 | channel_destroy (ch); | ||
1019 | } | ||
1020 | |||
1021 | |||
1022 | /** | ||
1003 | * Destroy locally created channel. Called by the local client, so no | 1023 | * Destroy locally created channel. Called by the local client, so no |
1004 | * need to tell the client. | 1024 | * need to tell the client. |
1005 | * | 1025 | * |
@@ -1052,32 +1072,34 @@ GCCH_channel_local_destroy (struct CadetChannel *ch, | |||
1052 | ch->destroy = GNUNET_YES; | 1072 | ch->destroy = GNUNET_YES; |
1053 | return; | 1073 | return; |
1054 | } | 1074 | } |
1055 | if (GNUNET_YES == ch->is_loopback) | 1075 | if ( (GNUNET_YES == ch->is_loopback) && |
1076 | ( (NULL != ch->owner) || | ||
1077 | (NULL != ch->dest) ) ) | ||
1056 | { | 1078 | { |
1057 | struct CadetChannelClient *ccc; | 1079 | if (NULL != ch->retry_control_task) |
1058 | 1080 | GNUNET_SCHEDULER_cancel (ch->retry_control_task); | |
1059 | /* Find which end is left... */ | 1081 | ch->retry_control_task |
1060 | ccc = (NULL != ch->owner) ? ch->owner : ch->dest; | 1082 | = GNUNET_SCHEDULER_add_now (&signal_remote_destroy_cb, |
1061 | GSC_handle_remote_channel_destroy (ccc->c, | 1083 | ch); |
1062 | ccc->ccn, | ||
1063 | ch); | ||
1064 | channel_destroy (ch); | ||
1065 | return; | 1084 | return; |
1066 | } | 1085 | } |
1067 | /* If the we ever sent the CHANNEL_CREATE, we need to send a destroy message. */ | 1086 | if (GNUNET_NO == ch->is_loopback) |
1068 | switch (ch->state) | ||
1069 | { | 1087 | { |
1070 | case CADET_CHANNEL_NEW: | 1088 | /* If the we ever sent the CHANNEL_CREATE, we need to send a destroy message. */ |
1071 | /* We gave up on a channel that we created as a client to a remote | 1089 | switch (ch->state) |
1072 | target, but that never went anywhere. Nothing to do here. */ | 1090 | { |
1073 | break; | 1091 | case CADET_CHANNEL_NEW: |
1074 | case CADET_CHANNEL_LOOSE: | 1092 | /* We gave up on a channel that we created as a client to a remote |
1075 | GSC_drop_loose_channel (&ch->port, | 1093 | target, but that never went anywhere. Nothing to do here. */ |
1076 | ch); | 1094 | break; |
1077 | break; | 1095 | case CADET_CHANNEL_LOOSE: |
1078 | default: | 1096 | GSC_drop_loose_channel (&ch->port, |
1079 | GCT_send_channel_destroy (ch->t, | 1097 | ch); |
1080 | ch->ctn); | 1098 | break; |
1099 | default: | ||
1100 | GCT_send_channel_destroy (ch->t, | ||
1101 | ch->ctn); | ||
1102 | } | ||
1081 | } | 1103 | } |
1082 | /* Nothing left to do, just finish destruction */ | 1104 | /* Nothing left to do, just finish destruction */ |
1083 | channel_destroy (ch); | 1105 | channel_destroy (ch); |