transport service hello reduction, klocwork fixes
authorNathan S. Evans <evans@in.tum.de>
Wed, 1 Sep 2010 13:18:50 +0000 (13:18 +0000)
committerNathan S. Evans <evans@in.tum.de>
Wed, 1 Sep 2010 13:18:50 +0000 (13:18 +0000)
src/transport/gnunet-service-transport.c
src/transport/plugin_transport_tcp.c
src/transport/plugin_transport_udp.c

index de25666fa1d9a270482b15ebbcfa1fbf5b4c85a7..9c873291fc9bd06900f1b59fcec0436e443c13a0 100644 (file)
@@ -2792,6 +2792,11 @@ setup_new_neighbour (const struct GNUNET_PeerIdentity *peer,
       n->piter = GNUNET_PEERINFO_iterate (peerinfo, peer,
                                          GNUNET_TIME_UNIT_FOREVER_REL,
                                          &add_hello_for_peer, n);
+
+      GNUNET_STATISTICS_update (stats,
+                                gettext_noop ("# HELLO's sent to new neighbors"),
+                                1,
+                                GNUNET_NO);
       transmit_to_peer (NULL, NULL, 0,
                        HELLO_ADDRESS_EXPIRATION,
                        (const char *) our_hello, GNUNET_HELLO_size(our_hello),
@@ -3258,8 +3263,14 @@ send_periodic_ping (void *cls,
                                      &neighbour->id.hashPubKey,
                                      va,
                                      GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
-  hello_size = GNUNET_HELLO_size(our_hello);
+
+  if (peer_address->validated != GNUNET_YES)
+    hello_size = GNUNET_HELLO_size(our_hello);
+  else
+    hello_size = 0;
+
   tsize = sizeof(struct TransportPingMessage) + hello_size;
+
   if (peer_address->addr != NULL)
     {
       slen = strlen (tp->short_name) + 1;
@@ -3273,7 +3284,9 @@ send_periodic_ping (void *cls,
   ping.header.type = htons(GNUNET_MESSAGE_TYPE_TRANSPORT_PING);
   ping.challenge = htonl(va->challenge);
   memcpy(&ping.target, &neighbour->id, sizeof(struct GNUNET_PeerIdentity));
-  memcpy(message_buf, our_hello, hello_size);
+  if (peer_address->validated != GNUNET_YES)
+    memcpy(message_buf, our_hello, hello_size);
+
   if (peer_address->addr != NULL)
     {
       ping.header.size = htons(sizeof(struct TransportPingMessage) +
@@ -3307,6 +3320,13 @@ send_periodic_ping (void *cls,
               "HELLO", hello_size,
               "PING");
 #endif
+  if (peer_address->validated != GNUNET_YES)
+    GNUNET_STATISTICS_update (stats,
+                              gettext_noop ("# PING+HELLO messages sent"),
+                              1,
+                              GNUNET_NO);
+
+
   GNUNET_STATISTICS_update (stats,
                            gettext_noop ("# PING messages sent for re-validation"),
                            1,
index d382b5108140a0c85af0b056924ea96d9de7c5e5..ffc738f5312465f368ef9f39f99f57de8786b673 100644 (file)
@@ -2043,7 +2043,6 @@ tcp_plugin_server_read (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc
       return;
     }
 
-  port = 0;
   port_start = NULL;
   for (i = 0; i < sizeof(mybuf); i++)
     {
index f8c68244ae6c973d52f8a740b04772daf9db6c4b..02f81a57656b0c9755726716d08862d48ef96c88 100644 (file)
@@ -978,7 +978,8 @@ process_interfaces (void *cls,
               &((struct sockaddr_in6 *) addr)->sin6_addr,
               sizeof (struct in6_addr));
       GNUNET_assert(NULL != inet_ntop(AF_INET6, &t6.ipv6_addr, &buf[0], INET6_ADDRSTRLEN));
-      if ((plugin->bind_address != NULL) || ((plugin->bind6_address != NULL) && (0 != strcmp(buf, plugin->bind_address))))
+      if (((plugin->bind_address != NULL) && (0 != strcmp(buf, plugin->bind_address)))
+          || ((plugin->bind6_address != NULL) && (0 != strcmp(buf, plugin->bind6_address))))
         {
           GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "%s: Not notifying transport of address %s\n", "UDP", GNUNET_a2s (addr, addrlen));
           return GNUNET_OK;
@@ -1177,7 +1178,6 @@ udp_plugin_server_read (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc
       return;
     }
 
-  port = 0;
   port_start = NULL;
   for (i = 0; i < sizeof(mybuf); i++)
     {