- minor changes: doxygen, log, code order, code legibility
authorBart Polot <bart.polot+gnunet@gmail.com>
Mon, 20 Feb 2017 18:19:26 +0000 (19:19 +0100)
committerBart Polot <bart.polot+gnunet@gmail.com>
Mon, 20 Feb 2017 18:19:26 +0000 (19:19 +0100)
src/cadet/test_cadet_local_mq.c

index d3917b94a349937b69332bd4e09be2b78613cc0d..785a8844f29da2f28e97b6c251740742c6e34647 100644 (file)
@@ -1,6 +1,6 @@
 /*
      This file is part of GNUnet.
-     Copyright (C) 2011 GNUnet e.V.
+     Copyright (C) 2017 GNUnet e.V.
 
      GNUnet is free software; you can redistribute it and/or modify
      it under the terms of the GNU General Public License as published
@@ -189,7 +189,7 @@ handle_data_received (void *cls,
 
   payload = GNUNET_ntohll (msg->payload);
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-             "Data callback payload %llu with cls: %p! Shutting down.\n",
+              "Data callback payload %llu with cls: %p! Shutting down.\n",
               (unsigned long long) payload,
               cls);
   GNUNET_assert (42 == payload);
@@ -266,15 +266,22 @@ run (void *cls,
      const struct GNUNET_CONFIGURATION_Handle *cfg,
      struct GNUNET_TESTING_Peer *peer)
 {
-  struct GNUNET_TIME_Relative start_delay;
+  struct GNUNET_MQ_MessageHandler handlers[] = {
+    GNUNET_MQ_hd_fixed_size (data_received,
+                             TEST_MESSAGE_TYPE,
+                             struct GNUNET_CADET_TestMsg,
+                             cadet_peer_2),
+    GNUNET_MQ_handler_end ()
+  };
+  struct GNUNET_TIME_Relative delay;
+
   me = peer;
   GNUNET_SCHEDULER_add_shutdown (&do_shutdown,
                                  NULL);
-  abort_task =
-      GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
-                                    (GNUNET_TIME_UNIT_SECONDS, 15),
-                                   &do_abort,
-                                    (void *) (long) __LINE__);
+  delay = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 15);
+  abort_task = GNUNET_SCHEDULER_add_delayed (delay,
+                                             &do_abort,
+                                             (void *) (long) __LINE__);
   cadet_peer_1 = GNUNET_CADET_connecT (cfg);
   cadet_peer_2 = GNUNET_CADET_connecT (cfg);
 
@@ -282,20 +289,13 @@ run (void *cls,
        (NULL == cadet_peer_2) )
   {
     GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-               "Couldn't connect to cadet\n");
+                "Couldn't connect to cadet\n");
     result = GNUNET_SYSERR;
     GNUNET_SCHEDULER_shutdown ();
     return;
   }
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "CADET 1: %p\n", cadet_peer_1);
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "CADET 2: %p\n", cadet_peer_2);
-  struct GNUNET_MQ_MessageHandler handlers[] = {
-    GNUNET_MQ_hd_fixed_size (data_received,
-                             TEST_MESSAGE_TYPE,
-                             struct GNUNET_CADET_TestMsg,
-                             cadet_peer_2),
-    GNUNET_MQ_handler_end ()
-  };
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "handlers 2: %p\n", handlers);
   GNUNET_CADET_open_porT (cadet_peer_2,          /* cadet handle */
                           GC_u2h (TEST_PORT_ID), /* port id */
@@ -304,9 +304,9 @@ run (void *cls,
                           NULL,                  /* window size handler */
                           &disconnected,         /* disconnect handler */
                           handlers);             /* traffic handlers */
-  start_delay = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 2);
+  delay = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 2);
   if (NULL == connect_task)
-    connect_task = GNUNET_SCHEDULER_add_delayed (start_delay,
+    connect_task = GNUNET_SCHEDULER_add_delayed (delay,
                                                  &do_connect,
                                                  NULL);
 }