gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r10315 - gnunet/src/core


From: gnunet
Subject: [GNUnet-SVN] r10315 - gnunet/src/core
Date: Mon, 15 Feb 2010 23:07:20 +0100

Author: grothoff
Date: 2010-02-15 23:07:20 +0100 (Mon, 15 Feb 2010)
New Revision: 10315

Modified:
   gnunet/src/core/core.h
   gnunet/src/core/gnunet-service-core.c
   gnunet/src/core/test_core_api.c
   gnunet/src/core/test_core_api_peer1.conf
   gnunet/src/core/test_core_api_peer2.conf
Log:
found assertion problem in core

Modified: gnunet/src/core/core.h
===================================================================
--- gnunet/src/core/core.h      2010-02-15 21:40:54 UTC (rev 10314)
+++ gnunet/src/core/core.h      2010-02-15 22:07:20 UTC (rev 10315)
@@ -29,12 +29,12 @@
 /**
  * General core debugging.
  */
-#define DEBUG_CORE GNUNET_YES
+#define DEBUG_CORE GNUNET_NO
 
 /**
  * Debugging interaction core-clients.
  */
-#define DEBUG_CORE_CLIENT GNUNET_YES
+#define DEBUG_CORE_CLIENT GNUNET_NO
 
 /**
  * Definition of bits in the InitMessage's options field that specify

Modified: gnunet/src/core/gnunet-service-core.c
===================================================================
--- gnunet/src/core/gnunet-service-core.c       2010-02-15 21:40:54 UTC (rev 
10314)
+++ gnunet/src/core/gnunet-service-core.c       2010-02-15 22:07:20 UTC (rev 
10315)
@@ -376,6 +376,13 @@
   struct PingMessage *pending_ping;
 
   /**
+   * We received a PONG message before we got the "public_key"
+   * (or the SET_KEY).  We keep it here until we have a key
+   * to decrypt it.  NULL if no PONG is pending.
+   */
+  struct PingMessage *pending_pong;
+
+  /**
    * Non-NULL if we are currently looking up HELLOs for this peer.
    * for this peer.
    */
@@ -2315,6 +2322,93 @@
 
 
 /**
+ * We received a PONG message.  Validate and update our status.
+ *
+ * @param n sender of the PONG
+ * @param m the encrypted PONG message itself
+ */
+static void
+handle_pong (struct Neighbour *n, const struct PingMessage *m)
+{
+  struct PingMessage t;
+  struct ConnectNotifyMessage cnm;
+
+#if DEBUG_CORE
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "Core service receives `%s' request from `%4s'.\n",
+              "PONG", GNUNET_i2s (&n->peer));
+#endif
+  if (GNUNET_OK !=
+      do_decrypt (n,
+                  &n->peer.hashPubKey,
+                  &m->challenge,
+                  &t.challenge,
+                  sizeof (struct PingMessage) -
+                  sizeof (struct GNUNET_MessageHeader)))
+    return;
+#if DEBUG_CORE
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "Decrypted `%s' from `%4s' with challenge %u using key %u\n",
+              "PONG",
+              GNUNET_i2s (&t.target),
+              ntohl (t.challenge), n->decrypt_key.crc32);
+#endif
+  if ((0 != memcmp (&t.target,
+                    &n->peer,
+                    sizeof (struct GNUNET_PeerIdentity))) ||
+      (n->ping_challenge != ntohl (t.challenge)))
+    {
+      /* PONG malformed */
+#if DEBUG_CORE
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                  "Received malformed `%s' wanted sender `%4s' with challenge 
%u\n",
+                  "PONG", GNUNET_i2s (&n->peer), n->ping_challenge);
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                  "Received malformed `%s' received from `%4s' with challenge 
%u\n",
+                  "PONG", GNUNET_i2s (&t.target), ntohl (t.challenge));
+#endif
+      GNUNET_break_op (0);
+      return;
+    }
+  switch (n->status)
+    {
+    case PEER_STATE_DOWN:
+      GNUNET_break (0);         /* should be impossible */
+      return;
+    case PEER_STATE_KEY_SENT:
+      GNUNET_break (0);         /* should be impossible, how did we decrypt? */
+      return;
+    case PEER_STATE_KEY_RECEIVED:
+      n->status = PEER_STATE_KEY_CONFIRMED;
+#if DEBUG_CORE
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                  "Confirmed key via `%s' message for peer `%4s'\n",
+                  "PONG", GNUNET_i2s (&n->peer));
+#endif
+      if (n->retry_set_key_task != GNUNET_SCHEDULER_NO_TASK)
+        {
+          GNUNET_SCHEDULER_cancel (sched, n->retry_set_key_task);
+          n->retry_set_key_task = GNUNET_SCHEDULER_NO_TASK;
+        }      
+      cnm.header.size = htons (sizeof (struct ConnectNotifyMessage));
+      cnm.header.type = htons (GNUNET_MESSAGE_TYPE_CORE_NOTIFY_CONNECT);
+      cnm.distance = htonl (n->last_distance);
+      cnm.latency = GNUNET_TIME_relative_hton (n->last_latency);
+      cnm.peer = n->peer;
+      send_to_all_clients (&cnm.header, GNUNET_YES, 
GNUNET_CORE_OPTION_SEND_CONNECT);
+      process_encrypted_neighbour_queue (n);
+      break;
+    case PEER_STATE_KEY_CONFIRMED:
+      /* duplicate PONG? */
+      break;
+    default:
+      GNUNET_break (0);
+      break;
+    }
+}
+
+
+/**
  * We received a SET_KEY message.  Validate and update
  * our key material and status.
  *
@@ -2328,6 +2422,7 @@
   struct GNUNET_TIME_Absolute t;
   struct GNUNET_CRYPTO_AesSessionKey k;
   struct PingMessage *ping;
+  struct PingMessage *pong;
   enum PeerStateMachine sender_status;
 
 #if DEBUG_CORE
@@ -2467,93 +2562,13 @@
       handle_ping (n, ping);
       GNUNET_free (ping);
     }
-}
-
-
-/**
- * We received a PONG message.  Validate and update our status.
- *
- * @param n sender of the PONG
- * @param m the encrypted PONG message itself
- */
-static void
-handle_pong (struct Neighbour *n, const struct PingMessage *m)
-{
-  struct PingMessage t;
-  struct ConnectNotifyMessage cnm;
-
-#if DEBUG_CORE
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "Core service receives `%s' request from `%4s'.\n",
-              "PONG", GNUNET_i2s (&n->peer));
-#endif
-  if (GNUNET_OK !=
-      do_decrypt (n,
-                  &n->peer.hashPubKey,
-                  &m->challenge,
-                  &t.challenge,
-                  sizeof (struct PingMessage) -
-                  sizeof (struct GNUNET_MessageHeader)))
-    return;
-#if DEBUG_CORE
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "Decrypted `%s' from `%4s' with challenge %u using key %u\n",
-              "PONG",
-              GNUNET_i2s (&t.target),
-              ntohl (t.challenge), n->decrypt_key.crc32);
-#endif
-  if ((0 != memcmp (&t.target,
-                    &n->peer,
-                    sizeof (struct GNUNET_PeerIdentity))) ||
-      (n->ping_challenge != ntohl (t.challenge)))
+  if (n->pending_pong != NULL)
     {
-      /* PONG malformed */
-#if DEBUG_CORE
-      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                  "Received malformed `%s' wanted sender `%4s' with challenge 
%u\n",
-                  "PONG", GNUNET_i2s (&n->peer), n->ping_challenge);
-      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                  "Received malformed `%s' received from `%4s' with challenge 
%u\n",
-                  "PONG", GNUNET_i2s (&t.target), ntohl (t.challenge));
-#endif
-      GNUNET_break_op (0);
-      return;
+      pong = n->pending_pong;
+      n->pending_pong = NULL;
+      handle_pong (n, pong);
+      GNUNET_free (pong);
     }
-  switch (n->status)
-    {
-    case PEER_STATE_DOWN:
-      GNUNET_break (0);         /* should be impossible */
-      return;
-    case PEER_STATE_KEY_SENT:
-      GNUNET_break (0);         /* should be impossible, how did we decrypt? */
-      return;
-    case PEER_STATE_KEY_RECEIVED:
-      n->status = PEER_STATE_KEY_CONFIRMED;
-#if DEBUG_CORE
-      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                  "Confirmed key via `%s' message for peer `%4s'\n",
-                  "PONG", GNUNET_i2s (&n->peer));
-#endif
-      if (n->retry_set_key_task != GNUNET_SCHEDULER_NO_TASK)
-        {
-          GNUNET_SCHEDULER_cancel (sched, n->retry_set_key_task);
-          n->retry_set_key_task = GNUNET_SCHEDULER_NO_TASK;
-        }      
-      cnm.header.size = htons (sizeof (struct ConnectNotifyMessage));
-      cnm.header.type = htons (GNUNET_MESSAGE_TYPE_CORE_NOTIFY_CONNECT);
-      cnm.distance = htonl (n->last_distance);
-      cnm.latency = GNUNET_TIME_relative_hton (n->last_latency);
-      cnm.peer = n->peer;
-      send_to_all_clients (&cnm.header, GNUNET_YES, 
GNUNET_CORE_OPTION_SEND_CONNECT);
-      process_encrypted_neighbour_queue (n);
-      break;
-    case PEER_STATE_KEY_CONFIRMED:
-      /* duplicate PONG? */
-      break;
-    default:
-      GNUNET_break (0);
-      break;
-    }
 }
 
 
@@ -2909,12 +2924,17 @@
           GNUNET_break_op (0);
           return;
         }
-      if ((n->status != PEER_STATE_KEY_SENT) &&
-          (n->status != PEER_STATE_KEY_RECEIVED) &&
-          (n->status != PEER_STATE_KEY_CONFIRMED))
+      if ( (n->status != PEER_STATE_KEY_RECEIVED) &&
+          (n->status != PEER_STATE_KEY_CONFIRMED) )
         {
-          /* could not decrypt pong, oops! */
-          GNUNET_break_op (0);
+#if DEBUG_CORE
+          GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                      "Core service receives `%s' request from `%4s' but have 
not processed key; marking as pending.\n",
+                      "PONG", GNUNET_i2s (&n->peer));
+#endif
+          GNUNET_free_non_null (n->pending_pong);
+          n->pending_pong = GNUNET_malloc (sizeof (struct PingMessage));
+          memcpy (n->pending_pong, message, sizeof (struct PingMessage));
           return;
         }
       handle_pong (n, (const struct PingMessage *) message);
@@ -3121,6 +3141,7 @@
     GNUNET_SCHEDULER_cancel (sched, n->quota_update_task);
   GNUNET_free_non_null (n->public_key);
   GNUNET_free_non_null (n->pending_ping);
+  GNUNET_free_non_null (n->pending_pong);
   GNUNET_free (n);
 }
 

Modified: gnunet/src/core/test_core_api.c
===================================================================
--- gnunet/src/core/test_core_api.c     2010-02-15 21:40:54 UTC (rev 10314)
+++ gnunet/src/core/test_core_api.c     2010-02-15 22:07:20 UTC (rev 10315)
@@ -34,7 +34,7 @@
 #include "gnunet_scheduler_lib.h"
 #include "gnunet_transport_service.h"
 
-#define VERBOSE GNUNET_YES
+#define VERBOSE GNUNET_NO
 
 #define START_ARM GNUNET_YES
 
@@ -78,9 +78,6 @@
 terminate_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
   GNUNET_assert (ok == 6);
-#if VERBOSE
-  fprintf(stderr, "ENDING WELL %u\n", ok);
-#endif
   GNUNET_CORE_disconnect (p1.ch);
   GNUNET_CORE_disconnect (p2.ch);
   GNUNET_TRANSPORT_disconnect (p1.th);

Modified: gnunet/src/core/test_core_api_peer1.conf
===================================================================
--- gnunet/src/core/test_core_api_peer1.conf    2010-02-15 21:40:54 UTC (rev 
10314)
+++ gnunet/src/core/test_core_api_peer1.conf    2010-02-15 22:07:20 UTC (rev 
10315)
@@ -13,7 +13,7 @@
 #PREFIX= xterm -e xterm -T transport1 -e gdb --args
 #PREFIX = xterm -T transport1 -e gdb --args
 #PREFIX = xterm -T transport1 -e valgrind --tool=memcheck
-DEBUG = YES
+DEBUG = NO
 
 [arm]
 PORT = 12466
@@ -40,7 +40,7 @@
 #OPTIONS = -l log-core-1
 #PREFIX = xterm -e xterm -T core1 -e gdb --args
 #PREFIX = xterm -T core1 -e 
-DEBUG = YES
+DEBUG = NO
 
 [testing]
 WEAKRANDOM = YES

Modified: gnunet/src/core/test_core_api_peer2.conf
===================================================================
--- gnunet/src/core/test_core_api_peer2.conf    2010-02-15 21:40:54 UTC (rev 
10314)
+++ gnunet/src/core/test_core_api_peer2.conf    2010-02-15 22:07:20 UTC (rev 
10315)
@@ -13,7 +13,7 @@
 #PREFIX = xterm -e xterm -T transport2 -e gdb --args
 #PREFIX = xterm -T transport2 -e
 #PREFIX = xterm -T transport2 -e valgrind --tool=memcheck
-DEBUG = YES
+DEBUG = NO
 
 [arm]
 PORT = 22466
@@ -38,7 +38,7 @@
 PORT = 22470
 #PREFIX = xterm -T core2 -e
 #PREFIX = xterm -T core2 -e valgrind --tool=memcheck
-DEBUG = YES
+DEBUG = NO
 
 [testing]
 WEAKRANDOM = YES





reply via email to

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