From 98be109b2e59b634ceb5d459b6542aff5b5e2a7e Mon Sep 17 00:00:00 2001 From: Bart Polot Date: Fri, 16 Sep 2011 17:53:31 +0000 Subject: [PATCH] Added notification of client that peers disconnected from tunnel --- src/mesh/gnunet-service-mesh.c | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/src/mesh/gnunet-service-mesh.c b/src/mesh/gnunet-service-mesh.c index b84f07621..5002571ed 100644 --- a/src/mesh/gnunet-service-mesh.c +++ b/src/mesh/gnunet-service-mesh.c @@ -1131,6 +1131,32 @@ tunnel_find_peer(struct MeshTunnelPathNode *root, struct MeshPeerInfo *peer) } +/** + * Recusively mark peer and children as disconnected, notify client + * + * @param parent Node to be clean, potentially with children + */ +static void +tunnel_mark_peers_disconnected (struct MeshTunnelPathNode *parent) +{ + struct GNUNET_MESH_PeerControl msg; + unsigned int i; + + parent->status = MESH_PEER_RECONNECTING; + for (i = 0; i < parent->nchildren; i++) + { + tunnel_mark_peers_disconnected (&parent->children[i]); + } + if (NULL == parent->t->client) + return; + msg.header.size = htons(sizeof(msg)); + msg.header.type = htons (GNUNET_MESSAGE_TYPE_MESH_LOCAL_PEER_DEL); + msg.tunnel_id = htonl(parent->t->local_tid); + GNUNET_PEER_resolve(parent->peer->id, &msg.peer); + GNUNET_SERVER_notification_context_unicast (nc, parent->t->client->handle, + &msg.header, GNUNET_NO); +} + /** * Delete the current path to the peer, including all now unused relays. * @@ -1166,6 +1192,9 @@ tunnel_del_path(struct MeshTunnel *t, struct MeshPeerInfo *peer) *n = parent->children[parent->nchildren - 1]; parent->nchildren--; parent->children = GNUNET_realloc (parent->children, parent->nchildren); + + tunnel_mark_peers_disconnected(node); + return node; } @@ -1247,7 +1276,6 @@ tunnel_add_path(struct MeshTunnel *t, struct MeshPeerPath *p) memcpy (n, oldnode, sizeof(struct MeshTunnelPathNode)); GNUNET_free (oldnode); } - n->status = MESH_PEER_WAITING; } else { -- 2.25.1