gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r11922 - gnunet/src/dv


From: gnunet
Subject: [GNUnet-SVN] r11922 - gnunet/src/dv
Date: Thu, 24 Jun 2010 13:44:36 +0200

Author: nevans
Date: 2010-06-24 13:44:36 +0200 (Thu, 24 Jun 2010)
New Revision: 11922

Modified:
   gnunet/src/dv/plugin_transport_dv.c
   gnunet/src/dv/test_transport_api_dv.c
Log:
test case error handling

Modified: gnunet/src/dv/plugin_transport_dv.c
===================================================================
--- gnunet/src/dv/plugin_transport_dv.c 2010-06-24 11:34:31 UTC (rev 11921)
+++ gnunet/src/dv/plugin_transport_dv.c 2010-06-24 11:44:36 UTC (rev 11922)
@@ -383,8 +383,6 @@
 
   plugin = GNUNET_malloc (sizeof (struct Plugin));
   plugin->env = env;
-  //plugin->service = service;
-  //plugin->server = GNUNET_SERVICE_get_server (service);
 
   plugin->dv_handle = GNUNET_DV_connect(env->sched, env->cfg, 
&handle_dv_message_received, plugin);
 

Modified: gnunet/src/dv/test_transport_api_dv.c
===================================================================
--- gnunet/src/dv/test_transport_api_dv.c       2010-06-24 11:34:31 UTC (rev 
11921)
+++ gnunet/src/dv/test_transport_api_dv.c       2010-06-24 11:44:36 UTC (rev 
11922)
@@ -282,69 +282,6 @@
 }
 
 static void
-send_other_messages (void *cls, const struct GNUNET_SCHEDULER_TaskContext * 
tc);
-
-static int
-process_mtype (void *cls,
-               const struct GNUNET_PeerIdentity *peer,
-               const struct GNUNET_MessageHeader *message,
-               struct GNUNET_TIME_Relative latency,
-               uint32_t distance)
-{
-  struct TestMessageContext *pos = cls;
-  struct GNUNET_TestMessage *msg = (struct GNUNET_TestMessage *)message;
-  if (pos->uid != ntohl(msg->uid))
-    return GNUNET_OK;
-
-  GNUNET_assert(0 == memcmp(peer, &pos->peer1->id, sizeof(struct 
GNUNET_PeerIdentity)));
-  if (total_other_expected_messages == 0)
-    {
-      total_messages_received++;
-#if VERBOSE
-      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                  "Received message from `%4s', type %d, uid %u, distance 
%u.\n", GNUNET_i2s (peer), ntohs(message->type), ntohl(msg->uid), distance);
-      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                  "Total messages received %d, expected %d.\n", 
total_messages_received, expected_messages);
-#endif
-    }
-  else
-    {
-      total_other_messages++;
-#if VERBOSE
-      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                  "Received message from `%4s', type %d, uid %u, distance 
%u.\n", GNUNET_i2s (peer), ntohs(message->type), ntohl(msg->uid), distance);
-      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                  "Total messages received %d, expected %d.\n", 
total_other_messages, total_other_expected_messages);
-#endif
-    }
-
-  if ((total_messages_received == expected_messages) && (total_other_messages 
== 0))
-    {
-      GNUNET_SCHEDULER_cancel (sched, die_task);
-      /*
-      if ((num_peers == 3) && (total_other_expected_messages == 2))
-        {
-          GNUNET_SCHEDULER_add_now (sched, &send_other_messages, NULL);
-        }
-      else
-        {
-          GNUNET_SCHEDULER_add_delayed (sched, GNUNET_TIME_relative_multiply 
(GNUNET_TIME_UNIT_SECONDS, 20), &send_other_messages, NULL);
-        }*/
-    }
-  else if ((total_other_expected_messages > 0) && (total_other_messages == 
total_other_expected_messages))
-    {
-      GNUNET_SCHEDULER_cancel (sched, die_task);
-      GNUNET_SCHEDULER_add_now (sched, &finish_testing, NULL);
-    }
-  else
-    {
-      pos->disconnect_task = GNUNET_SCHEDULER_add_now(sched, 
&disconnect_cores, pos);
-    }
-
-  return GNUNET_OK;
-}
-
-static void
 end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc)
 {
   char *msg = cls;
@@ -421,6 +358,72 @@
     }
 }
 
+static void
+send_other_messages (void *cls, const struct GNUNET_SCHEDULER_TaskContext * 
tc);
+
+static int
+process_mtype (void *cls,
+               const struct GNUNET_PeerIdentity *peer,
+               const struct GNUNET_MessageHeader *message,
+               struct GNUNET_TIME_Relative latency,
+               uint32_t distance)
+{
+  struct TestMessageContext *pos = cls;
+  struct GNUNET_TestMessage *msg = (struct GNUNET_TestMessage *)message;
+  if (pos->uid != ntohl(msg->uid))
+    return GNUNET_OK;
+
+  GNUNET_assert(0 == memcmp(peer, &pos->peer1->id, sizeof(struct 
GNUNET_PeerIdentity)));
+  if (total_other_expected_messages == 0)
+    {
+      total_messages_received++;
+#if VERBOSE
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                  "Received message from `%4s', type %d, uid %u, distance 
%u.\n", GNUNET_i2s (peer), ntohs(message->type), ntohl(msg->uid), distance);
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                  "Total messages received %d, expected %d.\n", 
total_messages_received, expected_messages);
+#endif
+    }
+  else
+    {
+      total_other_messages++;
+#if VERBOSE
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                  "Received message from `%4s', type %d, uid %u, distance 
%u.\n", GNUNET_i2s (peer), ntohs(message->type), ntohl(msg->uid), distance);
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                  "Total messages received %d, expected %d.\n", 
total_other_messages, total_other_expected_messages);
+#endif
+    }
+
+  if ((total_messages_received == expected_messages) && (total_other_messages 
== 0))
+    {
+      GNUNET_SCHEDULER_cancel (sched, die_task);
+      die_task = GNUNET_SCHEDULER_add_delayed (sched,
+                                               TEST_TIMEOUT,
+                                               &end_badly, "waiting for DV 
peers to connect!");
+      /*
+      if ((num_peers == 3) && (total_other_expected_messages == 2))
+        {
+          GNUNET_SCHEDULER_add_now (sched, &send_other_messages, NULL);
+        }
+      else
+        {
+          GNUNET_SCHEDULER_add_delayed (sched, GNUNET_TIME_relative_multiply 
(GNUNET_TIME_UNIT_SECONDS, 20), &send_other_messages, NULL);
+        }*/
+    }
+  else if ((total_other_expected_messages > 0) && (total_other_messages == 
total_other_expected_messages))
+    {
+      GNUNET_SCHEDULER_cancel (sched, die_task);
+      GNUNET_SCHEDULER_add_now (sched, &finish_testing, NULL);
+    }
+  else
+    {
+      pos->disconnect_task = GNUNET_SCHEDULER_add_now(sched, 
&disconnect_cores, pos);
+    }
+
+  return GNUNET_OK;
+}
+
 static size_t
 transmit_ready (void *cls, size_t size, void *buf)
 {
@@ -639,6 +642,7 @@
 #endif
 
   GNUNET_SCHEDULER_add_now (sched, &send_test_messages, other_test_messages);
+  GNUNET_SCHEDULER_cancel(sched, die_task);
   die_task = GNUNET_SCHEDULER_add_delayed (sched, 
GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 250), &end_badly, 
"from send_other_messages");
 }
 




reply via email to

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