gnunet-svn
[Top][All Lists]
Advanced

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

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


From: gnunet
Subject: [GNUnet-SVN] r34992 - gnunet/src/transport
Date: Sun, 25 Jan 2015 22:07:24 +0100

Author: grothoff
Date: 2015-01-25 22:07:24 +0100 (Sun, 25 Jan 2015)
New Revision: 34992

Modified:
   gnunet/src/transport/gnunet-service-transport.c
   gnunet/src/transport/gnunet-service-transport_ats.c
   gnunet/src/transport/gnunet-service-transport_ats.h
   gnunet/src/transport/gnunet-service-transport_neighbours.c
   gnunet/src/transport/plugin_transport_tcp.c
   gnunet/src/transport/plugin_transport_udp.c
   gnunet/src/transport/plugin_transport_wlan.c
   gnunet/src/transport/test_transport_api_reliability.c
Log:
-indentation plugin_transport_udp.c


Modified: gnunet/src/transport/gnunet-service-transport.c
===================================================================
--- gnunet/src/transport/gnunet-service-transport.c     2015-01-25 19:41:24 UTC 
(rev 34991)
+++ gnunet/src/transport/gnunet-service-transport.c     2015-01-25 21:07:24 UTC 
(rev 34992)
@@ -732,11 +732,15 @@
               session,
               GNUNET_i2s (&address->peer),
               GST_plugins_a2s (address));
-  if (GNUNET_YES ==
-      GNUNET_HELLO_address_check_option (address,
-                                         GNUNET_HELLO_ADDRESS_INFO_INBOUND))
+  if ( (GNUNET_YES ==
+        GNUNET_HELLO_address_check_option (address,
+                                           GNUNET_HELLO_ADDRESS_INFO_INBOUND)) 
||
+       (GNUNET_NO ==
+        GST_ats_is_known (address, session) ) )
   {
-    /* inbound is always new */
+    /* inbound is always new, but outbound MAY already be known, but
+       for example for UNIX, we have symmetric connections and thus we
+       may not know the address yet; add if necessary! */
     GST_ats_add_address (address,
                          session,
                          ats,
@@ -744,7 +748,6 @@
   }
   else
   {
-    /* outbound should already be known */
     GST_ats_new_session (address,
                          session);
     GST_ats_update_metrics (address,
@@ -923,8 +926,8 @@
                const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
   GST_neighbours_stop ();
+  GST_plugins_unload ();
   GST_validation_stop ();
-  GST_plugins_unload ();
   GST_ats_done ();
   GNUNET_ATS_scheduling_done (GST_ats);
   GST_ats = NULL;

Modified: gnunet/src/transport/gnunet-service-transport_ats.c
===================================================================
--- gnunet/src/transport/gnunet-service-transport_ats.c 2015-01-25 19:41:24 UTC 
(rev 34991)
+++ gnunet/src/transport/gnunet-service-transport_ats.c 2015-01-25 21:07:24 UTC 
(rev 34992)
@@ -108,6 +108,8 @@
     fc->ret = ai;
     return GNUNET_NO;
   }
+  GNUNET_assert ( (fc->session != ai->session) ||
+                  (NULL == ai->session) );
   return GNUNET_YES;
 }
 
@@ -138,6 +140,21 @@
 
 
 /**
+ * Test if ATS knows about this address.
+ *
+ * @param address the address
+ * @param session the session
+ * @return #GNUNET_YES if address is known, #GNUNET_NO if not.
+ */
+int
+GST_ats_is_known (const struct GNUNET_HELLO_Address *address,
+                  struct Session *session)
+{
+  return (NULL != find_ai (address, session)) ? GNUNET_YES : GNUNET_NO;
+}
+
+
+/**
  * Notify ATS about the new address including the network this address is
  * located in.
  *
@@ -183,7 +200,7 @@
   if (NULL == (papi = GST_plugins_find (address->transport_name)))
   {
     /* we don't have the plugin for this address */
-    GNUNET_break(0);
+    GNUNET_assert (0);
     return;
   }
   if (NULL != session)
@@ -244,7 +261,12 @@
   ai = find_ai (address, NULL);
   if (NULL == ai)
   {
-    GNUNET_break (NULL != (find_ai (address, session)));
+    /* We may already be aware of the session, even if some other part
+       of the code could not tell if it just created a new session or
+       just got one recycled from the plugin; hence, we may be called
+       with "new" session even for an "old" session; in that case,
+       check that this is the case, but just ignore it. */
+    GNUNET_assert (NULL != (find_ai (address, session)));
     return;
   }
   GNUNET_break (NULL == ai->session);
@@ -330,9 +352,9 @@
        and if we get metrics for those, they were never known to
        ATS which means we end up here (however, in this
        case, the address must be an outbound address). */
-    GNUNET_break (GNUNET_YES !=
-                  GNUNET_HELLO_address_check_option (address,
-                                                     
GNUNET_HELLO_ADDRESS_INFO_INBOUND));
+    GNUNET_assert (GNUNET_YES !=
+                   GNUNET_HELLO_address_check_option (address,
+                                                      
GNUNET_HELLO_ADDRESS_INFO_INBOUND));
 
     return;
   }
@@ -394,7 +416,7 @@
   ai = find_ai (address, NULL);
   if (NULL == ai)
   {
-    GNUNET_break (0);
+    GNUNET_assert (0);
     return;
   }
   GNUNET_assert (GNUNET_YES ==

Modified: gnunet/src/transport/gnunet-service-transport_ats.h
===================================================================
--- gnunet/src/transport/gnunet-service-transport_ats.h 2015-01-25 19:41:24 UTC 
(rev 34991)
+++ gnunet/src/transport/gnunet-service-transport_ats.h 2015-01-25 21:07:24 UTC 
(rev 34992)
@@ -51,6 +51,17 @@
 
 
 /**
+ * Test if ATS knows about this address.
+ *
+ * @param address the address
+ * @param session the session
+ * @return #GNUNET_YES if address is known, #GNUNET_NO if not.
+ */
+int
+GST_ats_is_known (const struct GNUNET_HELLO_Address *address,
+                  struct Session *session);
+
+/**
  * Notify ATS about the new address including the network this address is
  * located in.
  *

Modified: gnunet/src/transport/gnunet-service-transport_neighbours.c
===================================================================
--- gnunet/src/transport/gnunet-service-transport_neighbours.c  2015-01-25 
19:41:24 UTC (rev 34991)
+++ gnunet/src/transport/gnunet-service-transport_neighbours.c  2015-01-25 
21:07:24 UTC (rev 34992)
@@ -800,11 +800,11 @@
  */
 static void
 set_primary_address (struct NeighbourMapEntry *n,
-            const struct GNUNET_HELLO_Address *address,
-            struct Session *session,
-            struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in,
-            struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out,
-            int is_active)
+                     const struct GNUNET_HELLO_Address *address,
+                     struct Session *session,
+                     struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in,
+                     struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out,
+                     int is_active)
 {
   struct GNUNET_TRANSPORT_PluginFunctions *papi;
 

Modified: gnunet/src/transport/plugin_transport_tcp.c
===================================================================
--- gnunet/src/transport/plugin_transport_tcp.c 2015-01-25 19:41:24 UTC (rev 
34991)
+++ gnunet/src/transport/plugin_transport_tcp.c 2015-01-25 21:07:24 UTC (rev 
34992)
@@ -2261,8 +2261,9 @@
   struct GNUNET_ATS_Information ats;
 
 
-  if (0 == memcmp (&wm->clientIdentity, plugin->env->my_identity,
-          sizeof(struct GNUNET_PeerIdentity)))
+  if (0 == memcmp (&wm->clientIdentity,
+                   plugin->env->my_identity,
+                   sizeof(struct GNUNET_PeerIdentity)))
   {
     /* refuse connections from ourselves */
     GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
@@ -2277,10 +2278,14 @@
     return;
   }
 
-  LOG(GNUNET_ERROR_TYPE_DEBUG, "Received %s message from `%4s' %p\n", 
"WELCOME",
+  LOG(GNUNET_ERROR_TYPE_DEBUG,
+      "Received %s message from `%4s' %p\n",
+      "WELCOME",
       GNUNET_i2s (&wm->clientIdentity), client);
   GNUNET_STATISTICS_update (plugin->env->stats,
-      gettext_noop ("# TCP WELCOME messages received"), 1, GNUNET_NO);
+                            gettext_noop ("# TCP WELCOME messages received"),
+                            1,
+                            GNUNET_NO);
   session = lookup_session_by_client (plugin, client);
   if (NULL != session)
   {
@@ -2288,8 +2293,9 @@
     {
       LOG (GNUNET_ERROR_TYPE_DEBUG,
            "Found existing session %p for peer `%s'\n",
-           session, GNUNET_a2s (vaddr, alen));
-      GNUNET_free(vaddr);
+           session,
+           GNUNET_a2s (vaddr, alen));
+      GNUNET_free (vaddr);
     }
   }
   else
@@ -2337,23 +2343,27 @@
       session->ats_address_network_type = plugin->env->get_address_type 
(plugin->env->cls, vaddr, alen);
       ats.type = htonl (GNUNET_ATS_NETWORK_TYPE);
       ats.value = htonl (session->ats_address_network_type);
-      LOG(GNUNET_ERROR_TYPE_DEBUG,
-          "Creating new%s session %p for peer `%s' client %p \n",
-          GNUNET_HELLO_address_check_option (session->address,
-                                             GNUNET_HELLO_ADDRESS_INFO_INBOUND)
-          ? " inbound" : "",
-          session,
-          tcp_plugin_address_to_string(NULL, (void *) 
session->address->address,
-                                       session->address->address_length),
-          client);
-      GNUNET_free(vaddr);
-      GNUNET_SERVER_client_set_user_context(session->client, session);
+      LOG (GNUNET_ERROR_TYPE_DEBUG,
+           "Creating new%s session %p for peer `%s' client %p \n",
+           GNUNET_HELLO_address_check_option (session->address,
+                                              
GNUNET_HELLO_ADDRESS_INFO_INBOUND)
+           ? " inbound" : "",
+           session,
+           tcp_plugin_address_to_string (NULL,
+                                         (void *) session->address->address,
+                                         session->address->address_length),
+           client);
+      GNUNET_free (vaddr);
+      GNUNET_SERVER_client_set_user_context (session->client, session);
       GNUNET_CONTAINER_multipeermap_put (plugin->sessionmap,
                                          &session->target,
                                          session,
                                          
GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
       /* Notify transport and ATS about new session */
-      plugin->env->session_start (NULL, session->address, session, &ats, 1);
+      plugin->env->session_start (plugin->env->cls,
+                                  session->address,
+                                  session,
+                                  &ats, 1);
       notify_session_monitor (plugin,
                               session,
                               GNUNET_TRANSPORT_SS_INIT);

Modified: gnunet/src/transport/plugin_transport_udp.c
===================================================================
--- gnunet/src/transport/plugin_transport_udp.c 2015-01-25 19:41:24 UTC (rev 
34991)
+++ gnunet/src/transport/plugin_transport_udp.c 2015-01-25 21:07:24 UTC (rev 
34992)
@@ -1327,10 +1327,13 @@
   struct UDP_MessageWrapper *next;
   struct FindReceiveContext frc;
 
-  GNUNET_assert(GNUNET_YES != s->in_destroy);
-  LOG(GNUNET_ERROR_TYPE_DEBUG, "Session %p to peer `%s' address ended\n", s,
+  GNUNET_assert (GNUNET_YES != s->in_destroy);
+  LOG(GNUNET_ERROR_TYPE_DEBUG,
+      "Session %p to peer `%s' address ended\n", s,
       GNUNET_i2s (&s->target),
-      udp_address_to_string (NULL, s->address->address, 
s->address->address_length));
+      udp_address_to_string (NULL,
+                             s->address->address,
+                             s->address->address_length));
   /* stop timeout task */
   if (NULL != s->timeout_task)
   {
@@ -1405,10 +1408,10 @@
     }
   }
 
-  GNUNET_assert(GNUNET_YES ==
-                GNUNET_CONTAINER_multipeermap_remove (plugin->sessions,
-                                                      &s->target,
-                                                      s));
+  GNUNET_assert (GNUNET_YES ==
+                 GNUNET_CONTAINER_multipeermap_remove (plugin->sessions,
+                                                       &s->target,
+                                                       s));
   GNUNET_STATISTICS_set (plugin->env->stats,
                          "# UDP sessions active",
                          GNUNET_CONTAINER_multipeermap_size (plugin->sessions),
@@ -2335,7 +2338,8 @@
   address = GNUNET_HELLO_address_allocate ( &msg->sender, PLUGIN_NAME,
                                             arg, args,
                                             GNUNET_HELLO_ADDRESS_INFO_INBOUND);
-  if (NULL == (s = udp_plugin_lookup_session (plugin, address)))
+  if ( (NULL == (s = udp_plugin_lookup_session (plugin, address))) &&
+       (GNUNET_YES != s->in_destroy) )
   {
     s = udp_plugin_create_session (plugin, address);
     plugin->env->session_start (NULL, address, s, NULL, 0);
@@ -2354,9 +2358,12 @@
   si.arg = arg;
   si.args = args;
   s->rc++;
-  GNUNET_SERVER_mst_receive (plugin->mst, &si, (const char *) &msg[1],
-      ntohs (msg->header.size) - sizeof(struct UDPMessage), GNUNET_YES,
-      GNUNET_NO);
+  GNUNET_SERVER_mst_receive (plugin->mst,
+                             &si,
+                             (const char *) &msg[1],
+                             ntohs (msg->header.size) - sizeof(struct 
UDPMessage),
+                             GNUNET_YES,
+                             GNUNET_NO);
   s->rc--;
   if ((0 == s->rc) && (GNUNET_YES == s->in_destroy))
     free_session (s);
@@ -3614,12 +3621,12 @@
     return NULL;
   }
   stop_broadcast (plugin);
-  if (plugin->select_task != NULL )
+  if (plugin->select_task != NULL)
   {
     GNUNET_SCHEDULER_cancel (plugin->select_task);
     plugin->select_task = NULL;
   }
-  if (plugin->select_task_v6 != NULL )
+  if (plugin->select_task_v6 != NULL)
   {
     GNUNET_SCHEDULER_cancel (plugin->select_task_v6);
     plugin->select_task_v6 = NULL;

Modified: gnunet/src/transport/plugin_transport_wlan.c
===================================================================
--- gnunet/src/transport/plugin_transport_wlan.c        2015-01-25 19:41:24 UTC 
(rev 34991)
+++ gnunet/src/transport/plugin_transport_wlan.c        2015-01-25 21:07:24 UTC 
(rev 34992)
@@ -1395,7 +1395,6 @@
   struct Plugin *plugin = cls;
   struct GNUNET_HELLO_Address *address;
   struct MacAndSession *mas = client;
-  struct MacAndSession xmas;
   struct GNUNET_ATS_Information ats;
   struct FragmentMessage *fm;
   struct GNUNET_PeerIdentity tmpsource;
@@ -1448,6 +1447,17 @@
                                              &mas->endpoint->wlan_addr,
                                              sizeof (mas->endpoint->wlan_addr),
                                              
GNUNET_HELLO_ADDRESS_INFO_INBOUND);
+    mas->session = lookup_session (mas->endpoint,
+                                   &tmpsource);
+    if (NULL == mas->session)
+    {
+      mas->session = create_session (mas->endpoint,
+                                     &tmpsource);
+      plugin->env->session_start (plugin->env->cls,
+                                  address,
+                                  mas->session,
+                                  &ats, 1);
+    }
     plugin->env->receive (plugin->env->cls,
                           address,
                           mas->session,
@@ -1557,34 +1567,34 @@
                                GNUNET_NO);
       break;
     }
-    xmas.endpoint = mas->endpoint;
-    if (NULL == (xmas.session = lookup_session (mas->endpoint,
-                                                &wlanheader->sender)))
+    mas->session = lookup_session (mas->endpoint,
+                                   &wlanheader->sender);
+    if (NULL == mas->session)
     {
-      xmas.session = create_session (mas->endpoint,
+      mas->session = create_session (mas->endpoint,
                                      &wlanheader->sender);
       address = GNUNET_HELLO_address_allocate (&wlanheader->sender,
                                                PLUGIN_NAME,
                                                &mas->endpoint->wlan_addr,
                                                sizeof (struct WlanAddress),
                                                GNUNET_HELLO_ADDRESS_INFO_NONE);
-      plugin->env->session_start (NULL,
+      plugin->env->session_start (plugin->env->cls,
                                   address,
-                                  xmas.session,
+                                  mas->session,
                                   NULL, 0);
       LOG (GNUNET_ERROR_TYPE_DEBUG,
-          "Notifying transport about peer `%s''s new session %p \n",
+           "Notifying transport about peer `%s''s new session %p \n",
            GNUNET_i2s (&wlanheader->sender),
-           xmas.session);
+           mas->session);
       GNUNET_HELLO_address_free (address);
     }
     LOG (GNUNET_ERROR_TYPE_DEBUG,
          "Processing %u bytes of DATA from peer `%s'\n",
         (unsigned int) msize,
         GNUNET_i2s (&wlanheader->sender));
-    xmas.session->timeout = GNUNET_TIME_relative_to_absolute 
(GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT);
+    mas->session->timeout = GNUNET_TIME_relative_to_absolute 
(GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT);
     (void) GNUNET_SERVER_mst_receive (plugin->wlan_header_payload_tokenizer,
-                                     &xmas,
+                                     mas,
                                      (const char *) &wlanheader[1],
                                      msize - sizeof (struct WlanHeader),
                                      GNUNET_YES,
@@ -2188,9 +2198,12 @@
                                  GNUNET_BANDWIDTH_value_init (100 * 1024 *
                                                               1024 / 8),
                                  100);
-  plugin->fragment_data_tokenizer = GNUNET_SERVER_mst_create (&process_data, 
plugin);
-  plugin->wlan_header_payload_tokenizer = GNUNET_SERVER_mst_create 
(&process_data, plugin);
-  plugin->helper_payload_tokenizer = GNUNET_SERVER_mst_create (&process_data, 
plugin);
+  plugin->fragment_data_tokenizer = GNUNET_SERVER_mst_create (&process_data,
+                                                              plugin);
+  plugin->wlan_header_payload_tokenizer = GNUNET_SERVER_mst_create 
(&process_data,
+                                                                    plugin);
+  plugin->helper_payload_tokenizer = GNUNET_SERVER_mst_create (&process_data,
+                                                               plugin);
   plugin->beacon_task = GNUNET_SCHEDULER_add_now (&send_hello_beacon,
                                                  plugin);
 

Modified: gnunet/src/transport/test_transport_api_reliability.c
===================================================================
--- gnunet/src/transport/test_transport_api_reliability.c       2015-01-25 
19:41:24 UTC (rev 34991)
+++ gnunet/src/transport/test_transport_api_reliability.c       2015-01-25 
21:07:24 UTC (rev 34992)
@@ -87,22 +87,22 @@
 /**
  * Context of peer 1
  */
-struct PeerContext *p1;
+static struct PeerContext *p1;
 
 /**
  * Configuration file of peer 1
  */
-char *cfg_file_p1;
+static char *cfg_file_p1;
 
 /**
  * Context of peer 2
  */
-struct PeerContext *p2;
+static struct PeerContext *p2;
 
 /**
  * Configuration file of peer 1
  */
-char *cfg_file_p2;
+static char *cfg_file_p2;
 
 /**
  * Timeout task
@@ -112,12 +112,12 @@
 /**
  * Transport transmit handle used
  */
-struct GNUNET_TRANSPORT_TransmitHandle *th;
+static struct GNUNET_TRANSPORT_TransmitHandle *th;
 
 /**
  * Transport testing handle
  */
-struct GNUNET_TRANSPORT_TESTING_handle *tth;
+static struct GNUNET_TRANSPORT_TESTING_handle *tth;
 
 /*
  * Total amount of bytes sent
@@ -145,7 +145,9 @@
 static int msg_recv;
 
 static int test_connected;
+
 static int test_sending;
+
 static int test_send_timeout;
 
 
@@ -167,9 +169,11 @@
 #define OKPP do { ok++; } while (0)
 #endif
 
+
 static int
 get_bit (const char *map, unsigned int bit);
 
+
 static void
 end ()
 {




reply via email to

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