gnunet-svn
[Top][All Lists]
Advanced

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

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


From: gnunet
Subject: [GNUnet-SVN] r31666 - gnunet/src/transport
Date: Sun, 22 Dec 2013 01:38:42 +0100

Author: grothoff
Date: 2013-12-22 01:38:42 +0100 (Sun, 22 Dec 2013)
New Revision: 31666

Modified:
   gnunet/src/transport/gnunet-service-transport_neighbours.c
   gnunet/src/transport/plugin_transport_tcp.c
Log:
-code hygene

Modified: gnunet/src/transport/gnunet-service-transport_neighbours.c
===================================================================
--- gnunet/src/transport/gnunet-service-transport_neighbours.c  2013-12-22 
00:27:08 UTC (rev 31665)
+++ gnunet/src/transport/gnunet-service-transport_neighbours.c  2013-12-22 
00:38:42 UTC (rev 31666)
@@ -578,7 +578,7 @@
 
 
 /**
- * Context for blacklist checks and the 'handle_test_blacklist_cont'
+ * Context for blacklist checks and the #handle_test_blacklist_cont()
  * function.  Stores information about ongoing blacklist checks.
  */
 struct BlackListCheckContext
@@ -1904,7 +1904,7 @@
 /**
  * Function called with the result of a blacklist check.
  *
- * @param cls closure with the 'struct BlackListCheckContext'
+ * @param cls closure with the `struct BlackListCheckContext`
  * @param peer peer this check affects
  * @param result #GNUNET_OK if the address is allowed
  */

Modified: gnunet/src/transport/plugin_transport_tcp.c
===================================================================
--- gnunet/src/transport/plugin_transport_tcp.c 2013-12-22 00:27:08 UTC (rev 
31665)
+++ gnunet/src/transport/plugin_transport_tcp.c 2013-12-22 00:38:42 UTC (rev 
31666)
@@ -1129,8 +1129,8 @@
 {
   struct PendingMessage *pm;
 
-  GNUNET_assert (session->client != NULL);
-  if (session->transmit_handle != NULL)
+  GNUNET_assert (NULL != session->client);
+  if (NULL != session->transmit_handle)
     return;
   if (NULL == (pm = session->pending_messages_head))
     return;
@@ -1284,7 +1284,7 @@
                                                     &session->target,
                                                     session))
   {
-    GNUNET_assert (session->client != NULL);
+    GNUNET_assert (NULL != session->client);
     GNUNET_SERVER_client_set_timeout (session->client,
                                       
GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT);
     GNUNET_STATISTICS_update (plugin->env->stats,
@@ -1298,7 +1298,10 @@
     process_pending_messages (session);
     return msgbuf_size;
   }
-  else if (GNUNET_YES == 
GNUNET_CONTAINER_multipeermap_contains_value(plugin->nat_wait_conns, 
&session->target, session))
+  else if (GNUNET_YES ==
+           GNUNET_CONTAINER_multipeermap_contains_value(plugin->nat_wait_conns,
+                                                        &session->target,
+                                                        session))
   {
     LOG (GNUNET_ERROR_TYPE_DEBUG,
         "This NAT WAIT session for peer `%s' is not yet ready!\n",
@@ -1317,7 +1320,11 @@
     LOG (GNUNET_ERROR_TYPE_ERROR,
          "Invalid session %p\n", session);
     if (NULL != cont)
-      cont (cont_cls, &session->target, GNUNET_SYSERR, pm->message_size, 0);
+      cont (cont_cls,
+            &session->target,
+            GNUNET_SYSERR,
+            pm->message_size,
+            0);
     GNUNET_break (0);
     GNUNET_free (pm);
     return GNUNET_SYSERR; /* session does not exist here */
@@ -1362,34 +1369,11 @@
 {
   struct SessionItCtx * si_ctx = cls;
   struct Session * session = value;
-#if 0
-  char * a1 = strdup (tcp_address_to_string(NULL, session->addr, 
session->addrlen));
-  char * a2 = strdup (tcp_address_to_string(NULL, si_ctx->addr, 
si_ctx->addrlen));
-  LOG (GNUNET_ERROR_TYPE_DEBUG,
-       "Comparing: %s %u <-> %s %u\n",
-       a1,
-       session->addrlen,
-       a2,
-       si_ctx->addrlen);
-  GNUNET_free (a1);
-  GNUNET_free (a2);
-#endif
+
   if (session->addrlen != si_ctx->addrlen)
     return GNUNET_YES;
   if (0 != memcmp (session->addr, si_ctx->addr, si_ctx->addrlen))
     return GNUNET_YES;
-#if 0
-  a1 = strdup (tcp_address_to_string (NULL, session->addr, session->addrlen));
-  a2 = strdup (tcp_address_to_string (NULL, si_ctx->addr, si_ctx->addrlen));
-  LOG (GNUNET_ERROR_TYPE_DEBUG,
-       "Comparing: %s %u <-> %s %u , OK!\n",
-       a1,
-       session->addrlen,
-       a2,
-       si_ctx->addrlen);
-  GNUNET_free (a1);
-  GNUNET_free (a2);
-#endif
   /* Found existing session */
   si_ctx->result = session;
   return GNUNET_NO;
@@ -1418,15 +1402,16 @@
                           session);
 }
 
+
 static void
 tcp_plugin_update_session_timeout (void *cls,
                                   const struct GNUNET_PeerIdentity *peer,
                                   struct Session *session)
 {
   struct Plugin *plugin = cls;
+
   if (GNUNET_SYSERR == find_session (plugin, session))
     return;
-
   reschedule_session_timeout (session);
 }
 
@@ -1606,7 +1591,7 @@
   /* create new outbound session */
   GNUNET_assert (plugin->cur_connections <= plugin->max_connections);
   sa = GNUNET_CONNECTION_create_from_sockaddr (af, sb, sbs);
-  if (sa == NULL)
+  if (NULL == sa)
   {
     LOG (GNUNET_ERROR_TYPE_DEBUG,
         "Failed to create connection to `%4s' at `%s'\n",
@@ -1764,17 +1749,8 @@
 ppc_cancel_task (void *cls,
                  const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
-  int count = 0;
   struct PrettyPrinterContext *ppc = cls;
-  struct PrettyPrinterContext *cur;
 
-  for (cur = ppc_dll_head; (NULL != cur); cur = cur->next)
-  {
-    if (cur != ppc)
-      count++;
-  }
-
-  // GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cancel request %p, %u pending\n", 
ppc, count);
   ppc->timeout_task = GNUNET_SCHEDULER_NO_TASK;
   if (NULL != ppc->resolver_handle)
   {
@@ -1798,40 +1774,40 @@
   struct PrettyPrinterContext *ppc = cls;
   struct PrettyPrinterContext *cur;
   char *ret;
-  int count = 0;
 
-  for (cur = ppc_dll_head; (NULL != cur); cur = cur->next)
+  if (NULL == hostname)
   {
-    if (cur != ppc)
-      count++;
-  }
-  //GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Callback request %p == %s, %u 
pending\n", ppc, hostname, count);
-  if (hostname == NULL)
-  {
     ppc->asc (ppc->asc_cls, NULL);
     GNUNET_CONTAINER_DLL_remove (ppc_dll_head, ppc_dll_tail, ppc);
     GNUNET_SCHEDULER_cancel (ppc->timeout_task);
     ppc->timeout_task = GNUNET_SCHEDULER_NO_TASK;
     ppc->resolver_handle = NULL;
-    //GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Done request %p, %u pending\n", 
ppc, count);
     GNUNET_free (ppc);
     return;
   }
   for (cur = ppc_dll_head; (NULL != cur); cur = cur->next)
-  {
-       if (cur == ppc)
-               break;
-  }
+    if (cur == ppc)
+      break;
   if (NULL == cur)
   {
-       GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Invalid callback for PPC %p \n", 
ppc);
-       return;
+    GNUNET_break (0);
+    return;
   }
 
   if (GNUNET_YES == ppc->ipv6)
-    GNUNET_asprintf (&ret, "%s.%u.[%s]:%d", PLUGIN_NAME, ppc->options, 
hostname, ppc->port);
+    GNUNET_asprintf (&ret,
+                     "%s.%u.[%s]:%d",
+                     PLUGIN_NAME,
+                     ppc->options,
+                     hostname,
+                     ppc->port);
   else
-    GNUNET_asprintf (&ret, "%s.%u.%s:%d", PLUGIN_NAME, ppc->options, hostname, 
ppc->port);
+    GNUNET_asprintf (&ret,
+                     "%s.%u.%s:%d",
+                     PLUGIN_NAME,
+                     ppc->options,
+                     hostname,
+                     ppc->port);
   ppc->asc (ppc->asc_cls, ret);
   GNUNET_free (ret);
 }
@@ -1977,9 +1953,8 @@
   if ((addrlen != sizeof (struct IPv4TcpAddress)) &&
       (addrlen != sizeof (struct IPv6TcpAddress)))
   {
-
-
-       return GNUNET_SYSERR;
+    GNUNET_break_op (0);
+    return GNUNET_SYSERR;
   }
 
   if (addrlen == sizeof (struct IPv4TcpAddress))
@@ -1987,8 +1962,8 @@
     v4 = (struct IPv4TcpAddress *) addr;
     if (0 != memcmp (&v4->options, &myoptions, sizeof (myoptions)))
     {
-       GNUNET_break (0);
-       return GNUNET_SYSERR;
+      GNUNET_break (0);
+      return GNUNET_SYSERR;
     }
     if (GNUNET_OK != check_port (plugin, ntohs (v4->t4_port)))
       return GNUNET_SYSERR;
@@ -2196,9 +2171,10 @@
                             gettext_noop ("# TCP WELCOME messages received"), 
1,
                             GNUNET_NO);
   session = lookup_session_by_client (plugin, client);
-  if (session != NULL)
+  if (NULL != session)
   {
-    if (GNUNET_OK == GNUNET_SERVER_client_get_address (client, &vaddr, &alen))
+    if (GNUNET_OK ==
+        GNUNET_SERVER_client_get_address (client, &vaddr, &alen))
     {
       LOG (GNUNET_ERROR_TYPE_DEBUG,
           "Found existing session %p for peer `%s'\n",
@@ -2210,7 +2186,7 @@
   else
   {
     GNUNET_SERVER_client_keep (client);
-    if (plugin->service != NULL) /* Otherwise value is incremented in 
tcp_access_check */
+    if (NULL != plugin->service) /* Otherwise value is incremented in 
tcp_access_check */
        plugin->cur_connections++;
     if (plugin->cur_connections == plugin->max_connections)
        GNUNET_SERVER_suspend (plugin->server); /* Maximum number of 
connections rechead */
@@ -2274,14 +2250,14 @@
   /* Notify transport and ATS about new session */
   if (GNUNET_YES == session->inbound)
   {
-       plugin->env->session_start (NULL, &wm->clientIdentity, PLUGIN_NAME,
-               (GNUNET_YES == session->inbound) ? NULL : session->addr,
-                 (GNUNET_YES == session->inbound) ? 0 : session->addrlen,
-                 session, &ats, 1);
+    plugin->env->session_start (NULL,
+                                &wm->clientIdentity,
+                                PLUGIN_NAME,
+                                (GNUNET_YES == session->inbound) ? NULL : 
session->addr,
+                                (GNUNET_YES == session->inbound) ? 0 : 
session->addrlen,
+                                session, &ats, 1);
   }
-
   process_pending_messages (session);
-
   GNUNET_SERVER_client_set_timeout (client,
                                     GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT);
   GNUNET_SERVER_receive_done (client, GNUNET_OK);
@@ -2292,11 +2268,12 @@
  * Task to signal the server that we can continue
  * receiving from the TCP client now.
  *
- * @param cls the 'struct Session*'
+ * @param cls the `struct Session*`
  * @param tc task context (unused)
  */
 static void
-delayed_done (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+delayed_done (void *cls,
+              const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
   struct Session *session = cls;
 
@@ -2752,6 +2729,9 @@
 
 /**
  * Exit point from the plugin.
+ *
+ * @param cls the `struct GNUNET_TRANSPORT_PluginFunctions`
+ * @return NULL
  */
 void *
 libgnunet_plugin_transport_tcp_done (void *cls)




reply via email to

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