gnunet-svn
[Top][All Lists]
Advanced

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

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


From: gnunet
Subject: [GNUnet-SVN] r13386 - gnunet/src/transport
Date: Mon, 25 Oct 2010 11:04:43 +0200

Author: wachs
Date: 2010-10-25 11:04:43 +0200 (Mon, 25 Oct 2010)
New Revision: 13386

Modified:
   gnunet/src/transport/test_quota_compliance.c
Log:


Modified: gnunet/src/transport/test_quota_compliance.c
===================================================================
--- gnunet/src/transport/test_quota_compliance.c        2010-10-25 08:39:12 UTC 
(rev 13385)
+++ gnunet/src/transport/test_quota_compliance.c        2010-10-25 09:04:43 UTC 
(rev 13386)
@@ -82,6 +82,9 @@
 static int ok;
 
 static int connected;
+static int measurement_running;
+static int send_running;
+static int recv_running;
 
 static unsigned long long total_bytes;
 static unsigned long long current_quota_p1;
@@ -226,6 +229,10 @@
       ok = 42;
       return 0;
     }
+
+  if (measurement_running != GNUNET_YES)
+         return 0;
+
   ret = 0;
   s = get_size_new (n);
   GNUNET_assert (size >= s);
@@ -290,6 +297,7 @@
   if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
        return;
 
+  measurement_running = GNUNET_NO;
   struct GNUNET_TIME_Relative duration = 
GNUNET_TIME_absolute_get_difference(start_time, GNUNET_TIME_absolute_get());
 
   if (measurement_counter_task != GNUNET_SCHEDULER_NO_TASK)
@@ -297,17 +305,14 @@
     GNUNET_SCHEDULER_cancel (sched, measurement_counter_task);
     measurement_counter_task = GNUNET_SCHEDULER_NO_TASK;
   }
-
+#if VERBOSE
+  fprintf(stderr,"\n");
+#endif
   if (transmit_handle != NULL)
   {
          GNUNET_TRANSPORT_notify_transmit_ready_cancel(transmit_handle);
          transmit_handle = NULL;
   }
-  GNUNET_log (GNUNET_ERROR_TYPE_INFO,
-                 "\nQuota compliance ok: \n"\
-                 "Quota allowed: %10llu kb/s\n"\
-                 "Throughput   : %10llu kb/s\n", (current_quota_p1 / (1024)) , 
(total_bytes/(duration.value / 1000)/1024));
-
   if (current_quota_p1 < total_bytes/(duration.value / 1000))
   {
          GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
@@ -320,6 +325,11 @@
   }
   else
   {
+
+         GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+                         "\nQuota compliance ok: \n"\
+                         "Quota allowed: %10llu kb/s\n"\
+                         "Throughput   : %10llu kb/s\n", (current_quota_p1 / 
(1024)) , (total_bytes/(duration.value / 1000)/1024));
          ok = 0;
   }
   if (current_quota_p1 < (MEASUREMENT_MIN_QUOTA))
@@ -349,15 +359,6 @@
                          GNUNET_TIME_UNIT_FOREVER_REL,
                          NULL, NULL);
 
-               if (transmit_handle != NULL)
-                         
GNUNET_TRANSPORT_notify_transmit_ready_cancel(transmit_handle);
-
-               transmit_handle = GNUNET_TRANSPORT_notify_transmit_ready (p2.th,
-                                                                               
          &p1.id,
-                                                                               
          get_size_new (0), 0, TIMEOUT,
-                                                                               
          &notify_ready_new,
-                                                                               
          NULL);
-
                GNUNET_SCHEDULER_cancel (sched, die_task);
                die_task = GNUNET_SCHEDULER_add_delayed (sched,
                                                   TIMEOUT,
@@ -374,7 +375,17 @@
                                                   &measurement_end,
                                                   NULL);
                total_bytes = 0;
+               measurement_running = GNUNET_YES;
                start_time = GNUNET_TIME_absolute_get ();
+
+               if (transmit_handle != NULL)
+                         
GNUNET_TRANSPORT_notify_transmit_ready_cancel(transmit_handle);
+
+               transmit_handle = GNUNET_TRANSPORT_notify_transmit_ready (p2.th,
+                                                                               
          &p1.id,
+                                                                               
          get_size_new (0), 0, TIMEOUT,
+                                                                               
          &notify_ready_new,
+                                                                               
          NULL);
 }
 
 static void
@@ -490,11 +501,10 @@
                                           TIMEOUT,
                                           &end_badly,
                                           NULL);
+  measurement_running = GNUNET_NO;
+  send_running = GNUNET_NO;
+  recv_running = GNUNET_NO;
 
-  /* Setting initial quota for both peers */
-//  current_quota_p1 = 1024 * 1024 * 1024;
-//  current_quota_p2 = 1024 * 1024 * 1024;
-
   setup_peer (&p1, "test_quota_compliance_peer1.conf");
   setup_peer (&p2, "test_quota_compliance_peer2.conf");
 




reply via email to

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