core connect changes
authorNathan S. Evans <evans@in.tum.de>
Tue, 21 Dec 2010 13:49:43 +0000 (13:49 +0000)
committerNathan S. Evans <evans@in.tum.de>
Tue, 21 Dec 2010 13:49:43 +0000 (13:49 +0000)
src/dv/gnunet-service-dv.c
src/dv/test_transport_api_dv.c

index 28362b82f378d0e44cac6a18d9d47b12b9c07183..0ef8d48f7c05a7c88edc8605b6b38143fb638d4e 100644 (file)
@@ -2897,6 +2897,10 @@ handle_core_connect (void *cls,
 #endif
   uint32_t distance;
 
+  /* Check for connect to self message */
+  if (0 == memcmp(&my_identity, peer, sizeof(struct GNUNET_PeerIdentity)))
+    return;
+
   distance = get_atsi_distance (atsi);
   if ((distance == DIRECT_NEIGHBOR_COST) &&
       (GNUNET_CONTAINER_multihashmap_get(direct_neighbors, &peer->hashPubKey) == NULL))
@@ -2969,6 +2973,10 @@ void handle_core_disconnect (void *cls,
               "%s: Receives core peer disconnect message!\n", "dv");
 #endif
 
+  /* Check for disconnect from self message */
+  if (0 == memcmp(&my_identity, peer, sizeof(struct GNUNET_PeerIdentity)))
+    return;
+
   neighbor =
     GNUNET_CONTAINER_multihashmap_get (direct_neighbors, &peer->hashPubKey);
 
index c37448342cb563b8b14db99df41f57d8e3ba7e0b..48e30ada0bfc0524adeb72084bd983374d5550da 100644 (file)
@@ -547,9 +547,9 @@ static void connect_notify_peer2 (void *cls,
 
 static void
 init_notify_peer2 (void *cls,
-             struct GNUNET_CORE_Handle *server,
-             const struct GNUNET_PeerIdentity *my_identity,
-             const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *publicKey)
+                   struct GNUNET_CORE_Handle *server,
+                   const struct GNUNET_PeerIdentity *my_identity,
+                   const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *publicKey)
 {
 #if VERBOSE
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -597,9 +597,9 @@ static void connect_notify_peer1 (void *cls,
 
 static void
 init_notify_peer1 (void *cls,
-             struct GNUNET_CORE_Handle *server,
-             const struct GNUNET_PeerIdentity *my_identity,
-             const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *publicKey)
+                   struct GNUNET_CORE_Handle *server,
+                   const struct GNUNET_PeerIdentity *my_identity,
+                   const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *publicKey)
 {
   total_server_connections++;
 #if VERBOSE
@@ -877,6 +877,10 @@ static void all_connect_handler (void *cls,
   struct TestMessageContext *temp_context;
 #endif
   uint32_t distance;
+
+  if (0 == memcmp(&d->id, peer, sizeof(struct GNUNET_PeerIdentity)))
+    return;
+
   distance = get_atsi_distance(atsi);
 
 #if VERBOSE