more checks
authorChristian Grothoff <christian@grothoff.org>
Sun, 14 Nov 2010 13:31:59 +0000 (13:31 +0000)
committerChristian Grothoff <christian@grothoff.org>
Sun, 14 Nov 2010 13:31:59 +0000 (13:31 +0000)
src/core/core_api.c
src/core/test_core_api.c

index 2211028fb65e3cd12a13e8f80b9f767251ed4890..ffffbea929bdfa2d334eb482e4bc8f20adedcccd 100644 (file)
@@ -819,10 +819,6 @@ main_notify_handler (void *cls,
       m = (const struct InitReplyMessage *) msg;
       GNUNET_break (0 == ntohl (m->reserved));
       /* start our message processing loop */
-#if DEBUG_CORE
-      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                 "Successfully connected to core service, starting processing loop.\n");
-#endif
       if (GNUNET_YES == h->currently_down)
        {
          h->currently_down = GNUNET_NO;
@@ -837,8 +833,20 @@ main_notify_handler (void *cls,
                              sizeof (struct
                                      GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded),
                              &h->me.hashPubKey);
+#if DEBUG_CORE
+         GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                     "Connected to core service of peer `%s'.\n",
+                     GNUNET_i2s (&h->me));
+#endif
          init (h->cls, h, &h->me, &m->publicKey);
        }
+      else
+       {
+#if DEBUG_CORE
+         GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                     "Successfully reconnected to core service.\n");
+#endif
+       }
       break;
     case GNUNET_MESSAGE_TYPE_CORE_NOTIFY_CONNECT:
       if (msize != sizeof (struct ConnectNotifyMessage))
index 004486525049130f995ff37ce9a5aae6bbe67b74..4a8546bbe6eaecf7f1c74640d2b89f6e2d897768 100644 (file)
@@ -34,7 +34,7 @@
 #include "gnunet_scheduler_lib.h"
 #include "gnunet_transport_service.h"
 
-#define VERBOSE GNUNET_NO
+#define VERBOSE GNUNET_YES
 
 #define START_ARM GNUNET_YES
 
@@ -123,25 +123,29 @@ connect_notify (void *cls,
                const struct GNUNET_TRANSPORT_ATS_Information *atsi)
 {
   struct PeerContext *pc = cls;
+
   GNUNET_assert (pc->connect_status == 0);
   pc->connect_status = 1;
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "Encrypted connection established to peer `%4s'\n",
-              GNUNET_i2s (peer));
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-             "Asking core (1) for transmission to peer `%4s'\n",
-             GNUNET_i2s (&p2.id));
-  if (NULL == GNUNET_CORE_notify_transmit_ready (p1.ch,
-                                                0,
-                                                GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 45),
-                                                &p2.id,
-                                                sizeof (struct GNUNET_MessageHeader),
-                                                &transmit_ready, &p1))
+  if (pc == &p1)
     {
       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                 "RECEIVED NULL when asking core (1) for transmission to peer `%4s'\n",
+                 "Encrypted connection established to peer `%4s'\n",
+                 GNUNET_i2s (peer));
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                 "Asking core (1) for transmission to peer `%4s'\n",
                  GNUNET_i2s (&p2.id));
-    }  
+      if (NULL == GNUNET_CORE_notify_transmit_ready (p1.ch,
+                                                    0,
+                                                    GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 45),
+                                                    &p2.id,
+                                                    sizeof (struct GNUNET_MessageHeader),
+                                                    &transmit_ready, &p1))
+       {
+         GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                     "RECEIVED NULL when asking core (1) for transmission to peer `%4s'\n",
+                     GNUNET_i2s (&p2.id));
+       }  
+    }
 }
 
 
@@ -150,6 +154,7 @@ disconnect_notify (void *cls,
                    const struct GNUNET_PeerIdentity *peer)
 {
   struct PeerContext *pc = cls;
+
   pc->connect_status = 0;
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Encrypted connection to `%4s' cut\n", GNUNET_i2s (peer));