Added notification of client that peers disconnected from tunnel
authorBart Polot <bart@net.in.tum.de>
Fri, 16 Sep 2011 17:53:31 +0000 (17:53 +0000)
committerBart Polot <bart@net.in.tum.de>
Fri, 16 Sep 2011 17:53:31 +0000 (17:53 +0000)
src/mesh/gnunet-service-mesh.c

index b84f076211bdd12e200eb1f8668210de70a6d84f..5002571ed46bd1b13b1efe0579f1dae3dc1da279 100644 (file)
@@ -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
     {