gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r15934 - gnunet/src/transport


From: gnunet
Subject: [GNUnet-SVN] r15934 - gnunet/src/transport
Date: Mon, 11 Jul 2011 19:02:19 +0200

Author: nevans
Date: 2011-07-11 19:02:19 +0200 (Mon, 11 Jul 2011)
New Revision: 15934

Modified:
   gnunet/src/transport/gnunet-service-transport.c
Log:
testing HACK to see if it helps connection issues, NOT A FIX

Modified: gnunet/src/transport/gnunet-service-transport.c
===================================================================
--- gnunet/src/transport/gnunet-service-transport.c     2011-07-11 16:33:55 UTC 
(rev 15933)
+++ gnunet/src/transport/gnunet-service-transport.c     2011-07-11 17:02:19 UTC 
(rev 15934)
@@ -47,6 +47,8 @@
 
 #define DEBUG_TRANSPORT_HELLO GNUNET_NO
 
+#define DEBUG_INBOUND GNUNET_YES
+
 /**
  * Should we do some additional checks (to validate behavior
  * of clients)?
@@ -827,6 +829,11 @@
 
 
 /**
+ * All zero hash for comparison.
+ */
+static GNUNET_HashCode null_hash;
+
+/**
  * Our HELLO message.
  */
 static struct GNUNET_HELLO_Message *our_hello;
@@ -1922,46 +1929,101 @@
  * @param fal address to set to 'connected'
  */
 static void
-mark_address_connected (struct ForeignAddressList *fal)
+mark_address_connected(struct ForeignAddressList *fal)
 {
   struct ForeignAddressList *pos;
+  struct ForeignAddressList *inbound;
+  struct ForeignAddressList *outbound;
   int cnt;
 
   GNUNET_assert (GNUNET_YES == fal->validated);
   if (fal->connected == GNUNET_YES)
     return; /* nothing to do */
   cnt = GNUNET_YES;
+  inbound = NULL;
+  outbound = NULL;
+
   pos = fal->ready_list->addresses;
+  while (pos != NULL)
+    {
+      /* Already have inbound address, and this is also an inbound address, 
don't switch!! */
+      if ((GNUNET_YES == pos->connected) && (0 == pos->addrlen) && (0
+          == fal->addrlen))
+        return;
+      else if ((0 == pos->addrlen) && (GNUNET_YES == pos->connected))
+        inbound = pos;
+      pos = pos->next;
+    }
 
+  pos = fal->ready_list->addresses;
   while (pos != NULL)
     {
-      if (GNUNET_YES == pos->connected)
-       {
+      /* Already have outbound address, and this is also an outbound address, 
don't switch!! */
+      if ((GNUNET_YES == pos->connected) && (0 < pos->addrlen) && (0
+          < fal->addrlen))
+        return;
+      else if ((0 < pos->addrlen) && (GNUNET_YES == pos->connected))
+        outbound = pos;
+      pos = pos->next;
+    }
+
+#if DEBUG_INBOUND
+  if (inbound != NULL)
+    fprintf(stderr, "Peer: %s, have inbound connection.\n", 
GNUNET_i2s(&my_identity));
+  if (outbound != NULL)
+    fprintf(stderr, "Peer: %s, have outbound connection.\n", 
GNUNET_i2s(&my_identity));
+#endif
+
+  /* Have an inbound connection to this peer which is valid; our id is lower, 
ignore outbound connection! */
+  if ((inbound != NULL) && (0 != fal->addrlen) && (1
+      == GNUNET_CRYPTO_hash_xorcmp 
(&inbound->ready_list->neighbour->id.hashPubKey,
+                                    &my_identity.hashPubKey, &null_hash)))
+    {
+#if DEBUG_INBOUND
+      fprintf(stderr, "Peer: %s, had inbound connection, ignoring 
outbound!\n", GNUNET_i2s(&my_identity));
+#endif
+      return;
+    }
+  else if ((outbound != NULL) && (0 == fal->addrlen) && ((-1
+      == GNUNET_CRYPTO_hash_xorcmp 
(&outbound->ready_list->neighbour->id.hashPubKey,
+                                    &my_identity.hashPubKey, &null_hash))))
+    {
+#if DEBUG_INBOUND
+      fprintf(stderr, "Peer: %s, have outbound connection, ignoring 
inbound!\n", GNUNET_i2s(&my_identity));
+#endif
+      return;
+    }
+
+  pos = fal->ready_list->addresses;
+  while (pos != NULL)
+    {
+      if ((GNUNET_YES == pos->connected) && (0 < pos->addrlen))
+        {
 #if DEBUG_TRANSPORT
-         GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                     "Marking address `%s' as no longer connected (due to 
connect on other address)\n",
-                     a2s (pos->ready_list->plugin->short_name,
-                          pos->addr,
-                          pos->addrlen));
+          GNUNET_log (
+                      GNUNET_ERROR_TYPE_DEBUG,
+                      "Marking address `%s' as no longer connected (due to 
connect on other address)\n",
+                      a2s (pos->ready_list->plugin->short_name, pos->addr,
+                           pos->addrlen));
 #endif
-         GNUNET_break (cnt == GNUNET_YES);
-         cnt = GNUNET_NO;
-         pos->connected = GNUNET_NO;
-         GNUNET_STATISTICS_update (stats,
-                                   gettext_noop ("# connected addresses"),
-                                   -1,
-                                   GNUNET_NO);
-       }
+          GNUNET_break (cnt == GNUNET_YES);
+          cnt = GNUNET_NO;
+#if DEBUG_INBOUND
+          fprintf(stderr, "Peer: %s, setting %s connection to 
disconnected.\n", GNUNET_i2s(&my_identity), (0 == pos->addrlen) ? "INBOUND" : 
"OUTBOUND");
+#endif
+          pos->connected = GNUNET_NO;
+          GNUNET_STATISTICS_update (stats,
+                                    gettext_noop ("# connected addresses"), -1,
+                                    GNUNET_NO);
+        }
       pos = pos->next;
     }
 
   fal->connected = GNUNET_YES;
   if (GNUNET_YES == cnt)
     {
-      GNUNET_STATISTICS_update (stats,
-                               gettext_noop ("# connected addresses"),
-                               1,
-                               GNUNET_NO);
+      GNUNET_STATISTICS_update (stats, gettext_noop ("# connected addresses"),
+                                1, GNUNET_NO);
     }
 }
 
@@ -3646,10 +3708,6 @@
   caec.session = peer_address->session;
   caec.exists = GNUNET_NO;
 
-  /* Inbound address, we won't have in validation map! */
-  if (0 == peer_address->addrlen)
-    fprintf(stderr, "Sending periodic ping to inbound address!??\n");
-
   GNUNET_CONTAINER_multihashmap_iterate (validation_map,
                                          &check_address_exists,
                                          &caec);
@@ -5889,16 +5947,22 @@
                                     foreign_address_iterator->addrlen),
                                (foreign_address_iterator->connected
                                    == GNUNET_YES) ? "CONNECTED"
-                                   : "DISCONNECTED");
+                                   : "DISCONNECTED",
+                               (foreign_address_iterator->validated
+                                   == GNUNET_YES) ? "VALIDATED"
+                                   : "UNVALIDATED");
               transmit_address_to_client(tc, addr_buf);
               GNUNET_free(addr_buf);
             }
           else if (foreign_address_iterator->addrlen == 0)
             {
-              GNUNET_asprintf (&addr_buf, "%s --- %s", "<inbound>",
+              GNUNET_asprintf (&addr_buf, "%s --- %s, %s", "<inbound>",
                                (foreign_address_iterator->connected
                                    == GNUNET_YES) ? "CONNECTED"
-                                   : "DISCONNECTED");
+                                   : "DISCONNECTED",
+                               (foreign_address_iterator->validated
+                                   == GNUNET_YES) ? "VALIDATED"
+                                   : "UNVALIDATED");
               transmit_address_to_client (tc, addr_buf);
               GNUNET_free(addr_buf);
             }
@@ -5979,7 +6043,7 @@
                 }
               else if (foreign_address_iterator->addrlen == 0)
                 {
-                  GNUNET_asprintf (&addr_buf, "%s:%s --- %s",
+                  GNUNET_asprintf (&addr_buf, "%s:%s --- %s, %s",
                                      GNUNET_i2s (&neighbor_iterator->id),
                                      "<inbound>",
                                      (foreign_address_iterator->connected




reply via email to

[Prev in Thread] Current Thread [Next in Thread]