gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r26606 - gnunet/src/ats


From: gnunet
Subject: [GNUnet-SVN] r26606 - gnunet/src/ats
Date: Tue, 26 Mar 2013 11:50:06 +0100

Author: wachs
Date: 2013-03-26 11:50:06 +0100 (Tue, 26 Mar 2013)
New Revision: 26606

Modified:
   gnunet/src/ats/gnunet-service-ats_addresses.c
   gnunet/src/ats/gnunet-service-ats_performance.c
   gnunet/src/ats/gnunet-service-ats_performance.h
   gnunet/src/ats/test_ats_api_performance_monitor.c
Log:
changes


Modified: gnunet/src/ats/gnunet-service-ats_addresses.c
===================================================================
--- gnunet/src/ats/gnunet-service-ats_addresses.c       2013-03-26 10:07:33 UTC 
(rev 26605)
+++ gnunet/src/ats/gnunet-service-ats_addresses.c       2013-03-26 10:50:06 UTC 
(rev 26606)
@@ -465,7 +465,9 @@
                struct GNUNET_ATS_Information *destats;
                int ats_count;
                ats_count = assemble_ats_information (dest, &destats);
-               GAS_handle_performance_update (&dest->peer, destats, ats_count);
+               GAS_handle_performance_update (&dest->peer, dest->plugin,
+                               dest->addr, dest->addr_len, dest->active,
+                               destats, ats_count, dest->assigned_bw_out, 
dest->assigned_bw_in);
                GNUNET_free (destats);
   }
   return res;

Modified: gnunet/src/ats/gnunet-service-ats_performance.c
===================================================================
--- gnunet/src/ats/gnunet-service-ats_performance.c     2013-03-26 10:07:33 UTC 
(rev 26605)
+++ gnunet/src/ats/gnunet-service-ats_performance.c     2013-03-26 10:50:06 UTC 
(rev 26606)
@@ -505,10 +505,24 @@
 
 void
 GAS_handle_performance_update (struct GNUNET_PeerIdentity *peer,
+                                                                               
                                         const char *plugin_name,
+                                                                               
                                         const void *plugin_addr,
+                                                                               
                                         size_t plugin_addr_len,
+                                                                               
                                         const int active,
                                                                                
                                         struct GNUNET_ATS_Information *ats,
-                                                                               
                                         uint32_t ats_count)
+                                                                               
                                         uint32_t ats_count,
+                                                                               
                                         struct GNUNET_BANDWIDTH_Value32NBO
+                                                                               
                                         bandwidth_out,
+                                                                               
                                         struct GNUNET_BANDWIDTH_Value32NBO
+                                                                               
                                         bandwidth_in)
 {
 /* Notify here */
+       GAS_performance_notify_all_clients (peer,
+                                                                               
                                                                        
plugin_name,
+                                                                               
                                                                        
plugin_addr, plugin_addr_len,
+                                                                               
                                                                        active,
+                                                                               
                                                                        ats, 
ats_count,
+                                                                               
                                                                        
bandwidth_out, bandwidth_in);
 
 #if 0
        struct PerformanceClient *cur;

Modified: gnunet/src/ats/gnunet-service-ats_performance.h
===================================================================
--- gnunet/src/ats/gnunet-service-ats_performance.h     2013-03-26 10:07:33 UTC 
(rev 26605)
+++ gnunet/src/ats/gnunet-service-ats_performance.h     2013-03-26 10:50:06 UTC 
(rev 26606)
@@ -54,9 +54,19 @@
 
 void
 GAS_handle_performance_update (struct GNUNET_PeerIdentity *peer,
+                                                                               
                                         const char *plugin_name,
+                                                                               
                                         const void *plugin_addr,
+                                                                               
                                         size_t plugin_addr_len,
+                                                                               
                                         const int active,
                                                                                
                                         struct GNUNET_ATS_Information *ats,
-                                                                               
                                         uint32_t ats_count);
+                                                                               
                                         uint32_t ats_count,
+                                                                               
                                         struct GNUNET_BANDWIDTH_Value32NBO
+                                                                               
                                         bandwidth_out,
+                                                                               
                                         struct GNUNET_BANDWIDTH_Value32NBO
+                                                                               
                                         bandwidth_in);
 
+
+
 /**
  * Transmit the given performance information to all performance
  * clients.

Modified: gnunet/src/ats/test_ats_api_performance_monitor.c
===================================================================
--- gnunet/src/ats/test_ats_api_performance_monitor.c   2013-03-26 10:07:33 UTC 
(rev 26605)
+++ gnunet/src/ats/test_ats_api_performance_monitor.c   2013-03-26 10:50:06 UTC 
(rev 26606)
@@ -77,14 +77,12 @@
        addr[0].transport_name = "test0";
        addr[0].address = "test_addr0";
        addr[0].address_length = strlen ("test_addr0") + 1;
-       atsi[0].type = htonl(GNUNET_ATS_NETWORK_TYPE);
-       atsi[0].value = htonl(GNUNET_ATS_NET_LAN);
 
-       atsi[1].type = htonl(GNUNET_ATS_QUALITY_NET_DELAY);
-       atsi[1].value = htonl(100);
+       atsi[0].type = htonl(GNUNET_ATS_QUALITY_NET_DELAY);
+       atsi[0].value = htonl(100);
 
-       atsi[2].type = htonl(GNUNET_ATS_QUALITY_NET_DISTANCE);
-       atsi[2].value = htonl(5);
+       atsi[1].type = htonl(GNUNET_ATS_QUALITY_NET_DISTANCE);
+       atsi[1].value = htonl(5);
 
        GNUNET_ATS_address_add (sh, &addr[0], NULL, atsi, ATS_COUNT);
 
@@ -132,7 +130,15 @@
 end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
   die_task = GNUNET_SCHEDULER_NO_TASK;
-  GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Timeout\n");
+  GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Error!\n");
+  if (GNUNET_NO == res_perf_cb_p0)
+       GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Did not get performance 
information for requested peer!\n");
+  if (GNUNET_YES == res_perf_cb_p1)
+       GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Got suggestion for not requested 
peer!\n");
+  if (GNUNET_NO == res_suggest_cb_p0)
+       GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Did not get suggestion for not 
peer!\n");
+  if (GNUNET_YES == res_suggest_cb_p1)
+       GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Got suggestion for not requested 
peer!\n");
   end_now (1);
 }
 
@@ -179,10 +185,10 @@
        int c2;
        int c3;
 
-       GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                        "ATS notifies about perfomance change for peer `%s'\n", 
GNUNET_i2s (peer));
 
-       if ((1 != stage) || (2 == stage))
+       if ((1 != stage) && (2 != stage))
        {
                GNUNET_break (0);
                end_now(1);
@@ -193,9 +199,9 @@
        {
                        GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received 1st 
callback for peer `%s' with %u information\n",
                                        GNUNET_i2s (&addr[0].peer), ats_count);
-                       if ((0 != memcmp (peer, &addr[0].peer, sizeof 
(addr[0].peer))) ||
-                                       (ats_count < ATS_COUNT))
+                       if (0 != memcmp (peer, &addr[0].peer, sizeof 
(addr[0].peer)))
                        {
+                                       res_perf_cb_p1 = GNUNET_YES;
                                        GNUNET_break (0);
                                        if (GNUNET_SCHEDULER_NO_TASK != 
die_task)
                                                GNUNET_SCHEDULER_cancel 
(die_task);
@@ -203,6 +209,15 @@
                                        return;
                        }
 
+                       if (ats_count < ATS_COUNT)
+                       {
+                                       GNUNET_break (0);
+                                       if (GNUNET_SCHEDULER_NO_TASK != 
die_task)
+                                               GNUNET_SCHEDULER_cancel 
(die_task);
+                                       die_task = GNUNET_SCHEDULER_add_now 
(&end_badly, NULL);
+                                       return;
+                       }
+
                        c3 = 0;
                        for (c1 = 0; c1 < ats_count; c1++)
                        {
@@ -232,80 +247,74 @@
                        stage ++;
                        GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received %u 
correct ATS information \n", c3);
 
-                       atsi[1].type = htonl(GNUNET_ATS_QUALITY_NET_DELAY);
-                       atsi[1].value = htonl(1000);
+                       atsi[0].type = htonl(GNUNET_ATS_QUALITY_NET_DELAY);
+                       atsi[0].value = htonl(1000);
 
-                       atsi[2].type = htonl(GNUNET_ATS_QUALITY_NET_DISTANCE);
-                       atsi[2].value = htonl(50);
+                       atsi[1].type = htonl(GNUNET_ATS_QUALITY_NET_DISTANCE);
+                       atsi[1].value = htonl(50);
 
                        GNUNET_ATS_address_update (sh, &addr[0], NULL, atsi, 
ATS_COUNT);
+                       return;
        }
-       if (1 == stage)
+       if (2 == stage)
        {
                        GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received 2nd 
callback for peer `%s' with %u information\n",
                                        GNUNET_i2s (&addr[0].peer), ats_count);
-       }
+                       if (0 != memcmp (peer, &addr[0].peer, sizeof 
(addr[0].peer)))
+                       {
+                                       res_perf_cb_p1 = GNUNET_YES;
+                                       GNUNET_break (0);
+                                       if (GNUNET_SCHEDULER_NO_TASK != 
die_task)
+                                               GNUNET_SCHEDULER_cancel 
(die_task);
+                                       die_task = GNUNET_SCHEDULER_add_now 
(&end_badly, NULL);
+                                       return;
+                       }
 
-
-#if 0
-       static int stage_counter = 0;
-
-
-
-       if (0 == stage_counter)
-       {
-
-               c3 = 0;
-
-
-               stage_counter ++;
-
-       }
-       else if (1 == stage_counter)
-       {
-                       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received updated 
callback for peer `%s' with %u information\n",
-                                       GNUNET_i2s (&addr.peer), ats_count);
-
-                       if ((0 != memcmp (peer, &addr.peer, sizeof 
(addr.peer))) ||
-                                       (ats_count < ATS_COUNT))
+                       if (ats_count < ATS_COUNT)
                        {
                                        GNUNET_break (0);
-                                       GNUNET_SCHEDULER_add_now (&end_badly, 
NULL);
+                                       if (GNUNET_SCHEDULER_NO_TASK != 
die_task)
+                                               GNUNET_SCHEDULER_cancel 
(die_task);
+                                       die_task = GNUNET_SCHEDULER_add_now 
(&end_badly, NULL);
                                        return;
                        }
+
+
                        c3 = 0;
                        for (c1 = 0; c1 < ats_count; c1++)
                        {
-                                       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 
"ATS information [%u] %u : %u \n", c1, ntohl (ats[c1].type), ntohl 
(ats[c1].value));
-                                       for (c2 = 0; c2 < ATS_COUNT; c2++)
+                               GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ATS 
information [%u] %u : %u \n",
+                                               c1, ntohl (ats[c1].type), ntohl 
(ats[c1].value));
+                               for (c2 = 0; c2 < ATS_COUNT; c2++)
+                               {
+                                       if (ats[c1].type == atsi[c2].type)
                                        {
-                                               if (ats[c1].type == 
atsi[c2].type)
+                                               if (ats[c1].value == 
atsi[c2].value)
+                                                               c3++;
+                                               else
                                                {
-                                                       if (ats[c1].value == 
atsi[c2].value)
-                                                       {
-                                                                       c3++;
-                                                       }
-                                                       else
-                                                       {
-                                                                       
GNUNET_break (0);
-                                                       }
+                                                       GNUNET_log 
(GNUNET_ERROR_TYPE_DEBUG, "ATS information [%u] should be %u, but is %u \n",
+                                                                       ntohl 
(ats[c1].type), ntohl(atsi[c2].value),  ntohl (ats[c1].value));
+                                                               GNUNET_break 
(0);
                                                }
                                        }
+                               }
                        }
-
                        if (ATS_COUNT != c3)
                        {
-                         GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received only 
%u correct ATS information \n", c3);
-                               GNUNET_break (0);
-                               GNUNET_SCHEDULER_add_now (&end_badly, NULL);
+                               GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received 
only %u correct ATS information \n", c3);
+                               if (GNUNET_SCHEDULER_NO_TASK != die_task)
+                                       GNUNET_SCHEDULER_cancel (die_task);
+                               die_task = GNUNET_SCHEDULER_add_now 
(&end_badly, NULL);
                                return;
                        }
-                       stage_counter ++;
-                       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received %u 
correct ATS information, shutdown... \n", c3);
+
+                       /* Everything OK */
+                       stage ++;
+                       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received %u 
correct ATS information \n", c3);
                        GNUNET_SCHEDULER_add_now (&end, NULL);
                        return;
        }
-#endif
 }
 
 void ats_suggest_cb (void *cls,
@@ -316,7 +325,7 @@
                                                                                
const struct GNUNET_ATS_Information *ats,
                                                                                
uint32_t ats_count)
 {
-       GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                        "ATS is suggesting address for peer `%s'\n", GNUNET_i2s 
(&address->peer));
 
        if (0 != stage)




reply via email to

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