diff options
author | Bart Polot <bart@net.in.tum.de> | 2012-01-25 17:27:55 +0000 |
---|---|---|
committer | Bart Polot <bart@net.in.tum.de> | 2012-01-25 17:27:55 +0000 |
commit | 3d1cbeafcd29434ab4b9910a55181c14ccfb3437 (patch) | |
tree | 39f235ee288aa063c56d107a4f3087b99692a6df /src/mesh | |
parent | 1f1a1fdb66cbd1fe922034e73797e4bd6e8464b5 (diff) | |
download | gnunet-3d1cbeafcd29434ab4b9910a55181c14ccfb3437.tar.gz gnunet-3d1cbeafcd29434ab4b9910a55181c14ccfb3437.zip |
- When a client destroys an incoming tunnel, dont send him notifications about the tunnel anymore
Diffstat (limited to 'src/mesh')
-rw-r--r-- | src/mesh/gnunet-service-mesh.c | 34 |
1 files changed, 20 insertions, 14 deletions
diff --git a/src/mesh/gnunet-service-mesh.c b/src/mesh/gnunet-service-mesh.c index cb3812e16..e8ce74d97 100644 --- a/src/mesh/gnunet-service-mesh.c +++ b/src/mesh/gnunet-service-mesh.c | |||
@@ -315,12 +315,12 @@ struct MeshTunnel | |||
315 | struct MeshClient *owner; | 315 | struct MeshClient *owner; |
316 | 316 | ||
317 | /** | 317 | /** |
318 | * Clients destination of the tunnel, if any | 318 | * Clients that have been informed about the tunnel, if any |
319 | */ | 319 | */ |
320 | struct MeshClient **clients; | 320 | struct MeshClient **clients; |
321 | 321 | ||
322 | /** | 322 | /** |
323 | * Number of destination clients | 323 | * Number of elements in clients |
324 | */ | 324 | */ |
325 | unsigned int nclients; | 325 | unsigned int nclients; |
326 | 326 | ||
@@ -836,6 +836,7 @@ send_subscribed_clients (const struct GNUNET_MessageHeader *msg, | |||
836 | struct MeshClient *c; | 836 | struct MeshClient *c; |
837 | struct MeshTunnel *t; | 837 | struct MeshTunnel *t; |
838 | MESH_TunnelNumber *tid; | 838 | MESH_TunnelNumber *tid; |
839 | GNUNET_HashCode hash; | ||
839 | unsigned int count; | 840 | unsigned int count; |
840 | uint16_t type; | 841 | uint16_t type; |
841 | char cbuf[htons (msg->size)]; | 842 | char cbuf[htons (msg->size)]; |
@@ -896,7 +897,7 @@ send_subscribed_clients (const struct GNUNET_MessageHeader *msg, | |||
896 | { | 897 | { |
897 | if (-1 == tunnel_get_client_index (t, c)) | 898 | if (-1 == tunnel_get_client_index (t, c)) |
898 | { | 899 | { |
899 | /* This client isn't in the tunnel */ | 900 | /* This client doesn't know the tunnel */ |
900 | struct GNUNET_MESH_TunnelNotification tmsg; | 901 | struct GNUNET_MESH_TunnelNotification tmsg; |
901 | GNUNET_HashCode hash; | 902 | GNUNET_HashCode hash; |
902 | 903 | ||
@@ -915,6 +916,12 @@ send_subscribed_clients (const struct GNUNET_MessageHeader *msg, | |||
915 | } | 916 | } |
916 | *tid = htonl (t->local_tid_dest); | 917 | *tid = htonl (t->local_tid_dest); |
917 | } | 918 | } |
919 | |||
920 | /* Check if the client wants to get traffic from the tunnel */ | ||
921 | GNUNET_CRYPTO_hash(&t->local_tid_dest, sizeof (MESH_TunnelNumber), &hash); | ||
922 | if (GNUNET_NO == | ||
923 | GNUNET_CONTAINER_multihashmap_contains(c->incoming_tunnels, &hash)) | ||
924 | continue; | ||
918 | count++; | 925 | count++; |
919 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: sending\n"); | 926 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: sending\n"); |
920 | GNUNET_SERVER_notification_context_unicast (nc, c->handle, | 927 | GNUNET_SERVER_notification_context_unicast (nc, c->handle, |
@@ -2382,19 +2389,18 @@ tunnel_delete_peer (struct MeshTunnel *t, GNUNET_PEER_Id peer) | |||
2382 | * @param t Tunnel from which to remove the client. | 2389 | * @param t Tunnel from which to remove the client. |
2383 | * @param c Client that should be removed. | 2390 | * @param c Client that should be removed. |
2384 | * | 2391 | * |
2385 | * FIXME blacklist client to avoid adding it at next data packet | 2392 | * FIXME when to delete an incoming tunnel? |
2386 | */ | 2393 | */ |
2387 | static void | 2394 | static void |
2388 | tunnel_delete_client (struct MeshTunnel *t, struct MeshClient *c) | 2395 | tunnel_delete_client (struct MeshTunnel *t, struct MeshClient *c) |
2389 | { | 2396 | { |
2390 | unsigned int i; | 2397 | GNUNET_HashCode hash; |
2398 | |||
2399 | GNUNET_CRYPTO_hash(&t->local_tid_dest, sizeof (MESH_TunnelNumber), &hash); | ||
2400 | GNUNET_break (GNUNET_YES == | ||
2401 | GNUNET_CONTAINER_multihashmap_remove (c->incoming_tunnels, | ||
2402 | &hash, t)); | ||
2391 | 2403 | ||
2392 | for (i = 0; i < t->nclients; i++) | ||
2393 | if (t->clients[i] == c) | ||
2394 | break; | ||
2395 | GNUNET_assert (i < t->nclients); | ||
2396 | t->clients[i] = t->clients [t->nclients - 1]; | ||
2397 | GNUNET_array_grow (t->clients, t->nclients, t->nclients - 1); | ||
2398 | } | 2404 | } |
2399 | 2405 | ||
2400 | /** | 2406 | /** |
@@ -3894,19 +3900,19 @@ handle_local_tunnel_destroy (void *cls, struct GNUNET_SERVER_Client *client, | |||
3894 | if (c != t->owner) | 3900 | if (c != t->owner) |
3895 | { | 3901 | { |
3896 | tunnel_delete_client (t, c); | 3902 | tunnel_delete_client (t, c); |
3903 | #if 0 | ||
3904 | // TODO: when to destroy incoming tunnel? | ||
3897 | if (t->nclients == 0) | 3905 | if (t->nclients == 0) |
3898 | { | 3906 | { |
3899 | // TODO: destroy tunnel? what if a packet comes with another message type? | ||
3900 | #if 0 | ||
3901 | GNUNET_assert (GNUNET_YES == | 3907 | GNUNET_assert (GNUNET_YES == |
3902 | GNUNET_CONTAINER_multihashmap_remove (incoming_tunnels, | 3908 | GNUNET_CONTAINER_multihashmap_remove (incoming_tunnels, |
3903 | &hash, t)); | 3909 | &hash, t)); |
3904 | #endif | ||
3905 | GNUNET_assert (GNUNET_YES == | 3910 | GNUNET_assert (GNUNET_YES == |
3906 | GNUNET_CONTAINER_multihashmap_remove (t->peers, | 3911 | GNUNET_CONTAINER_multihashmap_remove (t->peers, |
3907 | &my_full_id.hashPubKey, | 3912 | &my_full_id.hashPubKey, |
3908 | t)); | 3913 | t)); |
3909 | } | 3914 | } |
3915 | #endif | ||
3910 | GNUNET_SERVER_receive_done (client, GNUNET_OK); | 3916 | GNUNET_SERVER_receive_done (client, GNUNET_OK); |
3911 | return; | 3917 | return; |
3912 | } | 3918 | } |