gnunet-svn
[Top][All Lists]
Advanced

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

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


From: gnunet
Subject: [GNUnet-SVN] r18109 - gnunet/src/transport
Date: Fri, 11 Nov 2011 17:41:00 +0100

Author: wachs
Date: 2011-11-11 17:41:00 +0100 (Fri, 11 Nov 2011)
New Revision: 18109

Modified:
   gnunet/src/transport/gnunet-service-transport_neighbours.c
Log:
ATS  address  updatign and deletion


Modified: gnunet/src/transport/gnunet-service-transport_neighbours.c
===================================================================
--- gnunet/src/transport/gnunet-service-transport_neighbours.c  2011-11-11 
16:40:29 UTC (rev 18108)
+++ gnunet/src/transport/gnunet-service-transport_neighbours.c  2011-11-11 
16:41:00 UTC (rev 18109)
@@ -450,25 +450,28 @@
 static void
 ats_suggest_cancel (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc);
 
+
 static void
 reset_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
   struct NeighbourMapEntry *n = cls;
 
   n->state_reset = GNUNET_SCHEDULER_NO_TASK;
+  if (n->state == S_CONNECTED)
+    return;
 
 #if DEBUG_TRANSPORT
-#endif
-
   GNUNET_STATISTICS_update (GST_stats,
                             gettext_noop
                             ("# failed connection attempts due to timeout"), 1,
                             GNUNET_NO);
+#endif
 
   /* resetting state */
   n->state = S_NOT_CONNECTED;
 
   /* destroying address */
+
   GNUNET_ATS_address_destroyed (GST_ats, n->address, n->session);
 
   /* request new address */
@@ -1139,8 +1142,7 @@
   struct NeighbourMapEntry *n = lookup_neighbour (&cc->address->peer);
   
   if (GNUNET_YES != success)
-    GNUNET_ATS_address_destroyed (GST_ats, cc->address, NULL);
-    //GNUNET_ATS_address_destroyed (GST_ats, cc->address, cc->session);
+    GNUNET_ATS_address_destroyed (GST_ats, cc->address, cc->session);
   if ( (NULL == neighbours) ||
        (NULL == n) ||
        (n->state == S_DISCONNECT))
@@ -1170,9 +1172,9 @@
                 n->session);
 #endif
     change_state (n, S_NOT_CONNECTED);
-    GNUNET_ATS_address_destroyed (GST_ats, cc->address, NULL);
-    //GNUNET_ATS_address_destroyed (GST_ats, cc->address, cc->session);
 
+    GNUNET_ATS_address_destroyed (GST_ats, cc->address, cc->session);
+
     if (n->ats_suggest != GNUNET_SCHEDULER_NO_TASK)
       GNUNET_SCHEDULER_cancel (n->ats_suggest);
     n->ats_suggest =
@@ -1223,8 +1225,7 @@
                 GNUNET_i2s (&n->id), 
                GST_plugins_a2s (n->address), n->session);
 #endif
-    GNUNET_ATS_address_destroyed (GST_ats, cc->address, NULL);
-    //GNUNET_ATS_address_destroyed (GST_ats, cc->address, cc->session);
+    GNUNET_ATS_address_destroyed (GST_ats, cc->address, cc->session);
 
     if (n->ats_suggest != GNUNET_SCHEDULER_NO_TASK)
       GNUNET_SCHEDULER_cancel (n->ats_suggest);
@@ -1245,6 +1246,7 @@
                     cc->address,
                     cc->session,
                     GNUNET_YES);
+          GNUNET_ATS_address_update (GST_ats, cc->address, cc->session, NULL, 
0);
           GNUNET_ATS_address_in_use (GST_ats, cc->address, cc->session, 
GNUNET_YES);
           n->address_state = USED;
       }
@@ -1265,6 +1267,7 @@
                     cc->address,
                     cc->session,
                     GNUNET_YES);
+          GNUNET_ATS_address_update (GST_ats, cc->address, cc->session, NULL, 
0);
           GNUNET_ATS_address_in_use (GST_ats, cc->address, cc->session, 
GNUNET_YES);
           n->address_state = USED;
       }
@@ -1331,8 +1334,7 @@
 #endif
   change_state (n, S_NOT_CONNECTED);
 
-  GNUNET_ATS_address_destroyed (GST_ats, cc->address, NULL);
-  //GNUNET_ATS_address_destroyed (GST_ats, cc->address, cc->session);
+  GNUNET_ATS_address_destroyed (GST_ats, cc->address, cc->session);
 
   if (n->ats_suggest != GNUNET_SCHEDULER_NO_TASK)
     GNUNET_SCHEDULER_cancel (n->ats_suggest);
@@ -1693,9 +1695,6 @@
     }
   }
 
-
-  //GNUNET_ATS_address_destroyed(GST_ats, n->address, n->session);
-
   if (NULL != n->address)
   {
     GNUNET_HELLO_address_free (n->address);
@@ -1704,7 +1703,7 @@
   n->session = NULL;
   
   /* not connected anymore anyway, shouldn't matter */
-  if ((S_CONNECTED != n->state) && (!is_connecting (n)))
+  if (S_CONNECTED != n->state)
     return;
 
   /* connected, try fast reconnect */
@@ -2011,7 +2010,9 @@
 
 
   if (n->latency.rel_value == GNUNET_TIME_relative_get_forever().rel_value)
+  {
     GNUNET_ATS_address_update (GST_ats, n->address, n->session, ats, 
ats_count);
+  }
   else
   {
     ats_new = GNUNET_malloc (sizeof (struct GNUNET_ATS_Information) * 
(ats_count + 1));
@@ -2297,15 +2298,17 @@
     return;
   }
 
+  change_state (n, S_CONNECTED);
+
   if (NULL != session)
+  {
     GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK,
                      "transport-ats",
                      "Giving ATS session %p of plugin %s for peer %s\n",
                      session, address->transport_name, GNUNET_i2s (peer));
+  }
   GNUNET_ATS_address_update (GST_ats, address, session, ats, ats_count);
   GNUNET_assert (NULL != n->address);
-
-  change_state (n, S_CONNECTED);
   if (n->address_state == FRESH)
   {
     GST_validation_set_address_use (&n->id,
@@ -2392,6 +2395,7 @@
                               GNUNET_NO);
     return;
   }
+  change_state (n, S_CONNECTED);
   if (NULL != session)
     GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK,
                      "transport-ats",
@@ -2399,11 +2403,6 @@
                      session, address->transport_name, GNUNET_i2s (peer));
   GNUNET_ATS_address_update (GST_ats, address, session, ats, ats_count);
   GNUNET_assert (n->address != NULL);
-  change_state (n, S_CONNECTED);
-
-  GST_neighbours_set_incoming_quota (&n->id, n->bandwidth_in);
-  if (n->keepalive_task == GNUNET_SCHEDULER_NO_TASK)
-        n->keepalive_task = GNUNET_SCHEDULER_add_now 
(&neighbour_keepalive_task, n);
   if (n->address_state == FRESH)
   {
     GST_validation_set_address_use (&n->id,
@@ -2413,10 +2412,14 @@
     GNUNET_ATS_address_in_use (GST_ats, n->address, n->session, GNUNET_YES);
     n->address_state = USED;
   }
+
   neighbours_connected++;
   GNUNET_STATISTICS_update (GST_stats, gettext_noop ("# peers connected"), 1,
                            GNUNET_NO);
   
+  GST_neighbours_set_incoming_quota (&n->id, n->bandwidth_in);
+  if (n->keepalive_task == GNUNET_SCHEDULER_NO_TASK)
+        n->keepalive_task = GNUNET_SCHEDULER_add_now 
(&neighbour_keepalive_task, n);
 #if DEBUG_TRANSPORT
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
              "Notify about connect of `%4s' using address '%s' session %X LINE 
%u\n",
@@ -2478,8 +2481,13 @@
                        bcc->session, 
                        GST_plugins_a2s (bcc->address),
                        GNUNET_i2s (peer));
-    GNUNET_ATS_address_update (GST_ats, bcc->address,
-                               bcc->session, bcc->ats, bcc->ats_count);
+    /* Tell ATS about the session, so ATS can suggest it if it likes it. */
+
+    GNUNET_ATS_address_update (GST_ats,
+                               bcc->address,
+                               bcc->session,
+                               bcc->ats,
+                               bcc->ats_count);
     n->connect_ts = bcc->ts;
   }
 




reply via email to

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