-only notify AFTER sending is really close to finished, not before
[oweals/gnunet.git] / src / mesh / test_mesh_single.c
index 2179b1f1d94efe693be670552c3ba5d2e2701700..ec91bf2245096bfee3ff6321b7d9218cc143e312 100644 (file)
@@ -28,7 +28,7 @@
 #include "gnunet_util_lib.h"
 #include "gnunet_dht_service.h"
 #include "gnunet_testing_lib.h"
-#include "gnunet_mesh_service_enc.h"
+#include "gnunet_mesh_service.h"
 
 #define REPETITIONS 5
 #define DATA_SIZE 35000
@@ -104,7 +104,7 @@ do_abort (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
  * @param channel connection to the other end
  * @param channel_ctx place to store local state associated with the channel
  * @param message the actual message
- * 
+ *
  * @return GNUNET_OK to keep the connection open,
  *         GNUNET_SYSERR to close it (signal serious error)
  */
@@ -113,8 +113,9 @@ data_callback (void *cls, struct GNUNET_MESH_Channel *channel,
                void **channel_ctx,
                const struct GNUNET_MessageHeader *message)
 {
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Data callback! Repetition %u\n", repetition);
-  printf ("rep %u\n", repetition);
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "Data callback! Repetition %u/%u\n",
+              repetition, REPETITIONS);
   repetition = repetition + 1;
   if (repetition < REPETITIONS)
   {
@@ -158,7 +159,7 @@ inbound_channel (void *cls, struct GNUNET_MESH_Channel *channel,
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "received incoming channel on port %u\n",
               port);
-    ch2 = channel;
+  ch2 = channel;
   return NULL;
 }
 
@@ -195,11 +196,11 @@ static struct GNUNET_MESH_MessageHandler handlers1[] = {
 
 /**
  * Data send callback: fillbuffer with test packet.
- * 
+ *
  * @param cls Closure (unused).
  * @param size Buffer size.
  * @param buf Buffer to fill.
- * 
+ *
  * @return size of test packet.
  */
 static size_t
@@ -222,7 +223,7 @@ do_send (void *cls, size_t size, void *buf)
 
 /**
  * Connect to other client and send data
- * 
+ *
  * @param cls Closue (unused).
  * @param tc TaskContext.
  */
@@ -233,7 +234,7 @@ do_connect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 
   GNUNET_TESTING_peer_get_identity (me, &id);
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "CONNECT BY PORT\n");
-    ch1 = GNUNET_MESH_channel_create (mesh, NULL, &id, 1, GNUNET_YES, GNUNET_NO);
+  ch1 = GNUNET_MESH_channel_create (mesh, NULL, &id, 1, GNUNET_YES, GNUNET_NO);
   GNUNET_MESH_notify_transmit_ready (ch1, GNUNET_NO,
                                      GNUNET_TIME_UNIT_FOREVER_REL,
                                      sizeof (struct GNUNET_MessageHeader) + DATA_SIZE,
@@ -243,13 +244,13 @@ do_connect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 
 /**
  * Initialize framework and start test
- * 
+ *
  * @param cls Closure (unused).
  * @param cfg Configuration handle.
  * @param peer Testing peer handle.
  */
 static void
-run (void *cls, 
+run (void *cls,
      const struct GNUNET_CONFIGURATION_Handle *cfg,
      struct GNUNET_TESTING_Peer *peer)
 {
@@ -289,7 +290,7 @@ main (int argc, char *argv[])
 {
   if (0 != GNUNET_TESTING_peer_run ("test-mesh-local",
                                     "test_mesh.conf",
-                                &run, NULL))
+                                    &run, NULL))
   {
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "run failed\n");
     return 2;