gnunet-svn
[Top][All Lists]
Advanced

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

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


From: gnunet
Subject: [GNUnet-SVN] r13690 - gnunet/src/core
Date: Tue, 16 Nov 2010 12:51:20 +0100

Author: wachs
Date: 2010-11-16 12:51:20 +0100 (Tue, 16 Nov 2010)
New Revision: 13690

Modified:
   gnunet/src/core/test_core_quota_compliance.c
Log:
Basic problem fixed:
Line 477: Timeout for GNUNET_CORE_peer_request_connect with 1 sec. too short to 
connect to other peer


Modified: gnunet/src/core/test_core_quota_compliance.c
===================================================================
--- gnunet/src/core/test_core_quota_compliance.c        2010-11-16 09:57:51 UTC 
(rev 13689)
+++ gnunet/src/core/test_core_quota_compliance.c        2010-11-16 11:51:20 UTC 
(rev 13690)
@@ -39,7 +39,7 @@
 #define VERBOSE GNUNET_YES
 
 #define START_ARM GNUNET_YES
-#define DEBUG_CONNECTIONS GNUNET_NO
+#define DEBUG_CONNECTIONS GNUNET_YES
 
 /**
  * Note that this value must not significantly exceed
@@ -157,64 +157,7 @@
   ok = 42;
 }
 
-static void connect_notify (void *cls,
-                const struct GNUNET_PeerIdentity *peer,
-               const struct GNUNET_TRANSPORT_ATS_Information *atsi)
-{
-  struct PeerContext *pc = cls;
-  GNUNET_assert (pc->connect_status == 0);
-  pc->connect_status = 1;
-#if DEBUG_CONNECTIONS
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "Encrypted connection established to peer `%4s'\n",
-              GNUNET_i2s (peer));
-#endif
-}
-
-
 static void
-disconnect_notify (void *cls,
-                   const struct GNUNET_PeerIdentity *peer)
-{
-  struct PeerContext *pc = cls;
-  pc->connect_status = 0;
-#if DEBUG_CONNECTIONS
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "Encrypted connection to `%4s' cut\n", GNUNET_i2s (peer));
-#endif
-}
-
-
-static int
-inbound_notify (void *cls,
-                const struct GNUNET_PeerIdentity *other,
-                const struct GNUNET_MessageHeader *message,
-               const struct GNUNET_TRANSPORT_ATS_Information *atsi)
-{
-  total_bytes_recv += ntohs (message->size);
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "Core provides inbound data from `%4s' size %u.\n", GNUNET_i2s 
(other), ntohs (message->size));
-#if DEBUG_CONNECTIONS
-  #endif
-  return GNUNET_OK;
-}
-
-
-static int
-outbound_notify (void *cls,
-                 const struct GNUNET_PeerIdentity *other,
-                 const struct GNUNET_MessageHeader *message,
-                const struct GNUNET_TRANSPORT_ATS_Information *atsi)
-{
-#if DEBUG_CONNECTIONS
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "Core notifies about outbound data for `%4s'.\n",
-              GNUNET_i2s (other));
-#endif
-  return GNUNET_OK;
-}
-
-static void
 next_fin (void *cls, int success)
 {
 
@@ -230,26 +173,43 @@
  return GNUNET_OK;
 }
 
+static size_t
+transmit_ready (void *cls, size_t size, void *buf);
+
 static void
+send_tsk (void *cls,
+          const struct GNUNET_SCHEDULER_TaskContext *tc)
+{
+  send_task = GNUNET_SCHEDULER_NO_TASK;
+
+  ch = GNUNET_CORE_notify_transmit_ready (p1.ch,
+                                         0,
+                                         FAST_TIMEOUT,
+                                         &p2.id,
+                                         sizeof (struct TestMessage) + 
MEASUREMENT_MSG_SIZE,
+                                         &transmit_ready, &p1);
+}
+
+static void
 measurement_end (void *cls,
           const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
   struct GNUNET_TIME_Relative duration;
-  
+
   measure_task  = GNUNET_SCHEDULER_NO_TASK;
   if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
     return;
-  
+
   if (err_task != GNUNET_SCHEDULER_NO_TASK)
     GNUNET_SCHEDULER_cancel (err_task);
   if (send_task != GNUNET_SCHEDULER_NO_TASK)
     GNUNET_SCHEDULER_cancel (send_task);
-  
+
   GNUNET_STATISTICS_get(p1.stats,"core","# discarded CORE_SEND 
requests",GNUNET_TIME_UNIT_SECONDS, &next_fin, &check_2, &p1);
   GNUNET_STATISTICS_get(p1.stats,"core","# discarded CORE_SEND 
requests",GNUNET_TIME_UNIT_SECONDS, &next_fin, &check_2, &p2);
   GNUNET_STATISTICS_get(p1.stats,"core","# discarded lower priority CORE_SEND 
requests",GNUNET_TIME_UNIT_SECONDS, &next_fin, &check_2, &p1);
   GNUNET_STATISTICS_get(p1.stats,"core","# discarded lower priority CORE_SEND 
requests",GNUNET_TIME_UNIT_SECONDS, &next_fin, &check_2, &p2);
-  
+
   GNUNET_STATISTICS_get(p1.stats,"core","# discarded CORE_SEND request 
bytes",GNUNET_TIME_UNIT_SECONDS, &next_fin, &check_2, &p1);
   GNUNET_STATISTICS_get(p1.stats,"core","# discarded CORE_SEND request 
bytes",GNUNET_TIME_UNIT_SECONDS, &next_fin, &check_2, &p2);
   GNUNET_STATISTICS_get(p1.stats,"core","# discarded lower priority CORE_SEND 
request bytes",GNUNET_TIME_UNIT_SECONDS, &next_fin, &check_2, &p1);
@@ -267,25 +227,8 @@
   GNUNET_SCHEDULER_add_now (&terminate_task, NULL);
 }
 
-static size_t
-transmit_ready (void *cls, size_t size, void *buf);
 
 static void
-send_tsk (void *cls,
-          const struct GNUNET_SCHEDULER_TaskContext *tc)
-{
-  send_task = GNUNET_SCHEDULER_NO_TASK;
-  
-  ch = GNUNET_CORE_notify_transmit_ready (p1.ch,
-                                         0,
-                                         FAST_TIMEOUT,
-                                         &p2.id,
-                                         sizeof (struct TestMessage) + 
MEASUREMENT_MSG_SIZE,
-                                         &transmit_ready, &p1);
-}
-
-
-static void 
 measure (unsigned long long quota_p1, unsigned long long quota_p2)
 {
 #if VERBOSE
@@ -320,6 +263,70 @@
                                          &transmit_ready, &p1);
 }
 
+static void connect_notify (void *cls,
+                const struct GNUNET_PeerIdentity *peer,
+               const struct GNUNET_TRANSPORT_ATS_Information *atsi)
+{
+         struct PeerContext *pc = cls;
+
+         GNUNET_assert (pc->connect_status == 0);
+         pc->connect_status = 1;
+         if (pc == &p1)
+           {
+             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));
+             measure (MEASUREMENT_MIN_QUOTA, MEASUREMENT_MIN_QUOTA);
+           }
+}
+
+
+static void
+disconnect_notify (void *cls,
+                   const struct GNUNET_PeerIdentity *peer)
+{
+  struct PeerContext *pc = cls;
+  pc->connect_status = 0;
+#if DEBUG_CONNECTIONS
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "Encrypted connection to `%4s' cut\n", GNUNET_i2s (peer));
+#endif
+}
+
+
+static int
+inbound_notify (void *cls,
+                const struct GNUNET_PeerIdentity *other,
+                const struct GNUNET_MessageHeader *message,
+               const struct GNUNET_TRANSPORT_ATS_Information *atsi)
+{
+  total_bytes_recv += ntohs (message->size);
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "Core provides inbound data from `%4s' size %u.\n", GNUNET_i2s 
(other), ntohs (message->size));
+#if DEBUG_CONNECTIONS
+  #endif
+  return GNUNET_OK;
+}
+
+
+static int
+outbound_notify (void *cls,
+                 const struct GNUNET_PeerIdentity *other,
+                 const struct GNUNET_MessageHeader *message,
+                const struct GNUNET_TRANSPORT_ATS_Information *atsi)
+{
+#if DEBUG_CONNECTIONS
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "Core notifies about outbound data for `%4s'.\n",
+              GNUNET_i2s (other));
+#endif
+  return GNUNET_OK;
+}
+
+
 static int tr_n;
 
 
@@ -369,7 +376,7 @@
   if (measurement_running != GNUNET_YES)
        return 0;
 
-  GNUNET_assert (size <= GNUNET_CONSTANTS_MAX_ENCRYPTED_MESSAGE_SIZE); 
+  GNUNET_assert (size <= GNUNET_CONSTANTS_MAX_ENCRYPTED_MESSAGE_SIZE);
   if (buf == NULL)
     {
       if (p1.ch != NULL)
@@ -414,7 +421,7 @@
   while (size - ret >= s);
   GNUNET_SCHEDULER_cancel (err_task);
   err_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT,
-                                 &terminate_task_error, 
+                                 &terminate_task_error,
                                  NULL);
 
   total_bytes += ret;
@@ -453,7 +460,7 @@
                            &init_notify,                        
                            &connect_notify,
                            &disconnect_notify,
-                          NULL,
+                           NULL,
                            &inbound_notify,
                            GNUNET_YES,
                            &outbound_notify, GNUNET_YES, handlers);
@@ -463,8 +470,13 @@
       GNUNET_assert (ok == 3);
       OKPP;
       GNUNET_assert (cls == &p2);
-
-      measure (MEASUREMENT_MIN_QUOTA, MEASUREMENT_MIN_QUOTA);
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                  "Asking core (1) to connect to peer `%4s'\n",
+                  GNUNET_i2s (&p2.id));
+      GNUNET_CORE_peer_request_connect (p1.ch,
+                       GNUNET_TIME_relative_multiply 
(GNUNET_TIME_UNIT_SECONDS, 5),
+                                       &p2.id,
+                                       NULL, NULL);
     }
 }
 




reply via email to

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