gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r28781 - gnunet/src/integration-tests


From: gnunet
Subject: [GNUnet-SVN] r28781 - gnunet/src/integration-tests
Date: Thu, 22 Aug 2013 09:12:16 +0200

Author: grothoff
Date: 2013-08-22 09:12:16 +0200 (Thu, 22 Aug 2013)
New Revision: 28781

Modified:
   gnunet/src/integration-tests/connection_watchdog.c
Log:
-code cleanup


Modified: gnunet/src/integration-tests/connection_watchdog.c
===================================================================
--- gnunet/src/integration-tests/connection_watchdog.c  2013-08-22 07:04:40 UTC 
(rev 28780)
+++ gnunet/src/integration-tests/connection_watchdog.c  2013-08-22 07:12:16 UTC 
(rev 28781)
@@ -1,6 +1,6 @@
 /*
      This file is part of GNUnet.
-     (C) 2009, 2010 Christian Grothoff (and other contributing authors)
+     (C) 2009, 2010, 2013 Christian Grothoff (and other contributing authors)
 
      GNUnet is free software; you can redistribute it and/or modify
      it under the terms of the GNU General Public License as published
@@ -27,10 +27,7 @@
 #include "gnunet_constants.h"
 #include "gnunet_arm_service.h"
 #include "gnunet_core_service.h"
-#include "gnunet_getopt_lib.h"
-#include "gnunet_os_lib.h"
-#include "gnunet_program_lib.h"
-#include "gnunet_scheduler_lib.h"
+#include "gnunet_util_lib.h"
 #include "gnunet_transport_service.h"
 #include "gnunet_statistics_service.h"
 
@@ -70,7 +67,7 @@
 static uint64_t statistics_core_neighbour_entries;
 static uint64_t statistics_core_entries_session_map;
 
-int stat_check_running;
+static int stat_check_running;
 
 static struct GNUNET_CONTAINER_MultiHashMap *peers;
 
@@ -116,9 +113,11 @@
   int protocol;
 };
 
-struct TransportPlugin *phead;
-struct TransportPlugin *ptail;
 
+static struct TransportPlugin *phead;
+static struct TransportPlugin *ptail;
+
+
 static int 
 map_check_it (void *cls,
              const struct GNUNET_HashCode * key,
@@ -202,6 +201,7 @@
 static void
 stats_check (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc);
 
+
 static int
 check_lowlevel_connections (int port, int protocol)
 {
@@ -401,56 +401,59 @@
 static size_t 
 send_transport_ping_cb (void *cls, size_t size, void *buf)
 {
- struct PeerContainer * pc = cls;
- struct PING ping;
- size_t mlen = sizeof (struct PING);
-
- if (size < mlen)
- {
-   GNUNET_break (0);
-   return 0;
- }
-
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-      "Sending transport ping to `%s'\n", GNUNET_i2s  (&pc->id));
- ping.header.size = htons (mlen);
- ping.header.type = htons (1234);
- ping.src = htons (0);
-
- pc->th_ping = NULL;
-
- memcpy (buf, &ping, mlen);
- return mlen;
+  struct PeerContainer * pc = cls;
+  struct PING ping;
+  size_t mlen = sizeof (struct PING);
+  
+  if (size < mlen)
+    {
+      GNUNET_break (0);
+      return 0;
+    }
+  
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+             "Sending transport ping to `%s'\n", GNUNET_i2s  (&pc->id));
+  ping.header.size = htons (mlen);
+  ping.header.type = htons (1234);
+  ping.src = htons (0);
+  
+  pc->th_ping = NULL;
+  
+  memcpy (buf, &ping, mlen);
+  return mlen;
 }
 
-size_t send_core_ping_cb (void *cls, size_t size, void *buf)
-{
-struct PeerContainer * pc = cls;
-struct PING ping;
-size_t mlen = sizeof (struct PING);
 
-if (size < mlen)
+static size_t 
+send_core_ping_cb (void *cls, size_t size, void *buf)
 {
-  GNUNET_break (0);
-  return 0;
-}
+  struct PeerContainer * pc = cls;
+  struct PING ping;
+  size_t mlen = sizeof (struct PING);
 
-GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-     "Sending core ping to `%s'\n", GNUNET_i2s  (&pc->id));
-ping.header.size = htons (mlen);
-ping.header.type = htons (1234);
-ping.src = htons (1);
-
-pc->ch_ping = NULL;
-
-memcpy (buf, &ping, mlen);
-return mlen;
+  if (size < mlen)
+    {
+      GNUNET_break (0);
+      return 0;
+    }
+  
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+             "Sending core ping to `%s'\n", GNUNET_i2s  (&pc->id));
+  ping.header.size = htons (mlen);
+  ping.header.type = htons (1234);
+  ping.src = htons (1);
+  
+  pc->ch_ping = NULL;
+  
+  memcpy (buf, &ping, mlen);
+  return mlen;
 }
 
 
-int map_ping_it (void *cls,
-                  const struct GNUNET_HashCode * key,
-                  void *value)
+static int 
+map_ping_it (void *cls,
+            const struct GNUNET_HashCode * key,
+            void *value)
 {
   struct PeerContainer *pc = value;
 
@@ -505,8 +508,8 @@
 }
 
 
-
-size_t send_transport_pong_cb (void *cls, size_t size, void *buf)
+static size_t 
+send_transport_pong_cb (void *cls, size_t size, void *buf)
 {
  struct PeerContainer * pc = cls;
  struct PING ping;
@@ -530,32 +533,33 @@
  return mlen;
 }
 
+
 static size_t 
 send_core_pong_cb (void *cls, size_t size, void *buf)
 {
-struct PeerContainer * pc = cls;
-struct PING ping;
-size_t mlen = sizeof (struct PING);
-
-if (size < mlen)
-{
-  GNUNET_break (0);
-  return 0;
+  struct PeerContainer * pc = cls;
+  struct PING ping;
+  size_t mlen = sizeof (struct PING);
+  
+  if (size < mlen)
+    {
+      GNUNET_break (0);
+      return 0;
+    }
+  
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+             "Sending core pong to `%s'\n", GNUNET_i2s  (&pc->id));
+  ping.header.size = htons (mlen);
+  ping.header.type = htons (4321);
+  ping.src = htons (1);
+  
+  pc->ch_pong = NULL;
+  
+  memcpy (buf, &ping, mlen);
+  return mlen;
 }
 
-GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-     "Sending core pong to `%s'\n", GNUNET_i2s  (&pc->id));
-ping.header.size = htons (mlen);
-ping.header.type = htons (4321);
-ping.src = htons (1);
 
-pc->ch_pong = NULL;
-
-memcpy (buf, &ping, mlen);
-return mlen;
-}
-
-
 static void
 map_connect (const struct GNUNET_PeerIdentity *peer, void * source)
 {
@@ -737,11 +741,12 @@
 static void
 cleanup_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
-  struct TransportPlugin * cur = phead;
+  struct TransportPlugin *cur;
 
   if (NULL != th)
   {
-    GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Disconnecting from transport 
service\n");
+    GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+               "Disconnecting from transport service\n");
     GNUNET_TRANSPORT_disconnect (th);
     th = NULL;
   }
@@ -749,7 +754,8 @@
 
   if (NULL != ch)
   {
-    GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Disconnecting from core service\n");
+    GNUNET_log (GNUNET_ERROR_TYPE_INFO, 
+               "Disconnecting from core service\n");
     GNUNET_CORE_disconnect (ch);
     ch = NULL;
   }
@@ -766,7 +772,7 @@
     check_task = GNUNET_SCHEDULER_NO_TASK;
   }
 
-  for (cur = phead; cur != NULL; cur = phead)
+  for (cur = phead; NULL != cur; cur = phead)
   {
     GNUNET_CONTAINER_DLL_remove(phead, ptail, cur);
     GNUNET_free (cur->short_name);
@@ -776,16 +782,20 @@
   check_task = GNUNET_SCHEDULER_add_now (&map_check, &map_cleanup);
 }
 
+
 static void
 transport_notify_connect_cb (void *cls,
-                const struct GNUNET_PeerIdentity* peer)
+                            const struct GNUNET_PeerIdentity* peer)
 {
   transport_connections ++;
-  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "TRANSPORT connect for peer `%s' (%u 
total)\n",
-      GNUNET_i2s (peer), transport_connections);
+  GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+             "TRANSPORT connect for peer `%s' (%u total)\n",
+             GNUNET_i2s (peer),
+             transport_connections);
   map_connect (peer, th);
 }
 
+
 /**
  * Function called to notify transport users that another
  * peer disconnected from us.
@@ -795,17 +805,18 @@
  */
 static void
 transport_notify_disconnect_cb (void *cls,
-                               const struct
-                               GNUNET_PeerIdentity * peer)
+                               const struct GNUNET_PeerIdentity *peer)
 {
   GNUNET_assert (transport_connections > 0);
-  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "TRANSPORT disconnect for peer `%s' (%u 
total)\n",
-      GNUNET_i2s (peer), transport_connections) ;
+  GNUNET_log (GNUNET_ERROR_TYPE_INFO, 
+             "TRANSPORT disconnect for peer `%s' (%u total)\n",
+             GNUNET_i2s (peer), 
+             transport_connections);
   map_disconnect (peer, th);
   transport_connections --;
-
 }
 
+
 static void
 transport_notify_receive_cb (void *cls,
                             const struct
@@ -814,24 +825,23 @@
                             GNUNET_MessageHeader *
                             message)
 {
+  struct PeerContainer *pc;
 
-
-  struct PeerContainer *pc = NULL;
-
-  pc = GNUNET_CONTAINER_multihashmap_get(peers, &peer->hashPubKey);
-
+  pc = GNUNET_CONTAINER_multihashmap_get (peers, &peer->hashPubKey);
   if (NULL == pc)
   {
     GNUNET_break (0);
     return;
   }
 
-  if ((message->size == ntohs (sizeof (struct PING))) && (message->type == 
ntohs (1234)))
+  if ((message->size == ntohs (sizeof (struct PING))) &&
+      (message->type == ntohs (1234)))
   {
-    GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Received %s %s from peer `%s'\n",
-        "TRANSPORT",
-        "PING",
-        GNUNET_i2s (peer)) ;
+    GNUNET_log (GNUNET_ERROR_TYPE_INFO, 
+               "Received %s %s from peer `%s'\n",
+               "TRANSPORT",
+               "PING",
+               GNUNET_i2s (peer)) ;
     if (GNUNET_YES == ping)
     {
       if (NULL == pc->th_pong)
@@ -942,9 +952,9 @@
     GNUNET_log (GNUNET_ERROR_TYPE_INFO, "CORE      disconnect for myself `%s' 
(%u total)\n",
       GNUNET_i2s (peer), core_connections);
   }
-
 }
 
+
 static void
 core_init_cb (void *cls, 
              const struct GNUNET_PeerIdentity *my_identity)
@@ -1024,6 +1034,7 @@
   GNUNET_free (plugs);
 }
 
+
 /**
  * Main function that will be run by the scheduler.
  *




reply via email to

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