misc bugfixes, especially core dumps for dv test case
authorNathan S. Evans <evans@in.tum.de>
Thu, 24 Jun 2010 11:03:11 +0000 (11:03 +0000)
committerNathan S. Evans <evans@in.tum.de>
Thu, 24 Jun 2010 11:03:11 +0000 (11:03 +0000)
src/dv/dv.h
src/dv/dv_api.c
src/dv/gnunet-service-dv.c
src/dv/plugin_transport_dv.c
src/dv/test_transport_api_dv.c
src/dv/test_transport_dv_data.conf

index 28a56031ef204a1257b9b36000909b8b2a4153ac..7b32d7d14991626ddbff90596a2feb8373332f7d 100644 (file)
@@ -31,7 +31,7 @@
 #define DEBUG_DV_GOSSIP GNUNET_NO
 #define DEBUG_DV_GOSSIP_SEND GNUNET_NO
 #define DEBUG_DV_GOSSIP_RECEIPT GNUNET_NO
-#define DEBUG_DV_MESSAGES GNUNET_YES
+#define DEBUG_DV_MESSAGES GNUNET_NO
 #define DEBUG_DV GNUNET_NO
 #define DEBUG_DV_PEER_NUMBERS GNUNET_NO
 #define DEBUG_MESSAGE_DROP GNUNET_NO
@@ -155,11 +155,6 @@ struct GNUNET_DV_SendMessage
    */
   struct GNUNET_PeerIdentity target;
 
-  /**
-   * The size of the msgbuf
-   */
-  uint32_t msgbuf_size;
-
   /**
    * Message priority
    */
@@ -273,4 +268,11 @@ GNUNET_DV_connect (struct GNUNET_SCHEDULER_Handle *sched,
                   GNUNET_DV_MessageReceivedHandler receive_handler,
                   void *receive_handler_cls);
 
+/**
+ * Disconnect from the DV service
+ *
+ * @param handle the current handle to the service to disconnect
+ */
+void GNUNET_DV_disconnect(struct GNUNET_DV_Handle *handle);
+
 #endif
index 9ab15ea627a595159b03b0d83b2caaa326e96de3..8b92a703f47f35975cf376b8a00afda1e6bdc92f 100644 (file)
@@ -38,7 +38,9 @@
 #include "dv.h"
 #include "../transport/plugin_transport.h"
 
-
+/**
+ * Store ready to send messages
+ */
 struct PendingMessages
 {
   /**
@@ -58,8 +60,6 @@ struct PendingMessages
 
 };
 
-
-
 /**
  * Handle for the service.
  */
@@ -95,11 +95,6 @@ struct GNUNET_DV_Handle
    */
   struct PendingMessages *current;
 
-  /**
-   * Kill off the connection and any pending messages.
-   */
-  int do_destroy;
-
   /**
    * Handler for messages we receive from the DV service
    */
@@ -171,6 +166,8 @@ hash_from_uid (uint32_t uid,
 /**
  * Try to (re)connect to the dv service.
  *
+ * @param ret handle to the (disconnected) dv service
+ *
  * @return GNUNET_YES on success, GNUNET_NO on failure.
  */
 static int
@@ -192,6 +189,9 @@ static void process_pending_message(struct GNUNET_DV_Handle *handle);
 
 /**
  * Send complete, schedule next
+ *
+ * @param handle handle to the dv service
+ * @param code return code for send (unused)
  */
 static void
 finish (struct GNUNET_DV_Handle *handle, int code)
@@ -204,7 +204,15 @@ finish (struct GNUNET_DV_Handle *handle, int code)
   GNUNET_free (pos);
 }
 
-
+/**
+ * Notification that we can send data
+ *
+ * @param cls handle to the dv service (struct GNUNET_DV_Handle)
+ * @param size how many bytes can we send
+ * @buf where to copy the message to send
+ *
+ * @return how many bytes we copied to buf
+ */
 static size_t
 transmit_pending (void *cls, size_t size, void *buf)
 {
@@ -249,6 +257,8 @@ transmit_pending (void *cls, size_t size, void *buf)
 
 /**
  * Try to send messages from list of messages to send
+ *
+ * @param handle handle to the distance vector service
  */
 static void process_pending_message(struct GNUNET_DV_Handle *handle)
 {
@@ -265,11 +275,6 @@ static void process_pending_message(struct GNUNET_DV_Handle *handle)
   handle->current = handle->pending_list;
   if (NULL == handle->current)
     {
-      if (handle->do_destroy)
-        {
-          handle->do_destroy = GNUNET_NO;
-          //GNUNET_DV_disconnect (handle); /* FIXME: replace with proper disconnect stuffs */
-        }
       return;
     }
   handle->pending_list = handle->pending_list->next;
@@ -277,10 +282,10 @@ static void process_pending_message(struct GNUNET_DV_Handle *handle)
 
   if (NULL ==
       (handle->th = GNUNET_CLIENT_notify_transmit_ready (handle->client,
-                                                    ntohl(handle->current->msg->msgbuf_size),
-                                                    handle->current->msg->timeout,
-                                                    GNUNET_YES,
-                                                    &transmit_pending, handle)))
+                                                         ntohs(handle->current->msg->header.size),
+                                                         handle->current->msg->timeout,
+                                                         GNUNET_YES,
+                                                         &transmit_pending, handle)))
     {
 #if DEBUG_DV
       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -456,7 +461,6 @@ int GNUNET_DV_send (struct GNUNET_DV_Handle *dv_handle,
   msg->header.size = htons(msize);
   msg->header.type = htons(GNUNET_MESSAGE_TYPE_TRANSPORT_DV_SEND);
   memcpy(&msg->target, target, sizeof(struct GNUNET_PeerIdentity));
-  msg->msgbuf_size = htonl(msgbuf_size);
   msg->priority = htonl(priority);
   msg->timeout = timeout;
   msg->addrlen = htonl(addrlen);
@@ -476,9 +480,16 @@ int GNUNET_DV_send (struct GNUNET_DV_Handle *dv_handle,
   return GNUNET_OK;
 }
 
-/* Forward declaration */
-void GNUNET_DV_disconnect(struct GNUNET_DV_Handle *handle);
-
+/**
+ * Callback to transmit a start message to
+ * the DV service, once we can send
+ *
+ * @param cls struct StartContext
+ * @param size how much can we send
+ * @param buf where to copy the message
+ *
+ * @return number of bytes copied to buf
+ */
 static size_t
 transmit_start (void *cls, size_t size, void *buf)
 {
@@ -531,7 +542,6 @@ GNUNET_DV_connect (struct GNUNET_SCHEDULER_Handle *sched,
   handle->sched = sched;
   handle->pending_list = NULL;
   handle->current = NULL;
-  handle->do_destroy = GNUNET_NO;
   handle->th = NULL;
   handle->client = GNUNET_CLIENT_connect(sched, "dv", cfg);
   handle->receive_handler = receive_handler;
index b89a0c1d9ebf0449c19c13d18c149262a5661c78..20ce71952034e190ceffab3829f50cba34a873bc 100644 (file)
@@ -503,7 +503,7 @@ static struct GNUNET_CORE_Handle *coreAPI;
 /**
  * Stream tokenizer to handle messages coming in from core.
  */
-struct GNUNET_SERVER_MessageStreamTokenizer *coreMST;
+static struct GNUNET_SERVER_MessageStreamTokenizer *coreMST;
 
 /**
  * The identity of our peer.
@@ -1709,9 +1709,7 @@ void handle_dv_send_message (void *cls,
 
   address_len = ntohl(send_msg->addrlen);
   GNUNET_assert(address_len == sizeof(struct GNUNET_PeerIdentity) * 2);
-  message_size = ntohl(send_msg->msgbuf_size);
-
-  GNUNET_assert(ntohs(message->size) == sizeof(struct GNUNET_DV_SendMessage) + address_len + message_size);
+  message_size = ntohs(message->size) - sizeof(struct GNUNET_DV_SendMessage) - address_len;
   destination = GNUNET_malloc(sizeof(struct GNUNET_PeerIdentity));
   direct = GNUNET_malloc(sizeof(struct GNUNET_PeerIdentity));
   message_buf = GNUNET_malloc(message_size);
index f4811bbe94eb8cdaf38e094e3c01800df76d6f7c..30e5b6ac1278aa7ab6bde9900e5c5cfabf4d8068 100644 (file)
  * @file dv/plugin_transport_dv.c
  * @brief DV transport service, takes incoming DV requests and deals with
  * the DV service
+ * @author Nathan Evans
  * @author Christian Grothoff
  */
 
-/**
- * TODO:
- *
- * As a start, the dv plugin needs to listen for information from the dv
- * service.  The plugin (?) will be notified by core (?) when a tcp/udp/whatever
- * message comes in that should be for dv.  The plugin will then hand off the message
- * to the dv service which will decrypt/validate the message (?) and then send the
- * result back to us (the transport) which will then send the message to the transport
- * service (yikes).
- *
- * Or, core will notify the dv service directly which will validate,
- * etc. and then just send a message to us.
- *
- * For starters, this plugin needs to have a client which will listen for messages from
- * the dv service that need to be sent up to the gnunet-transport-service.
- *
- * Messages sent from the dv transport get passed to the dv service which deals
- * with the actual sending (how much state does this transport need? should it know
- * which peers it is currently connected to and their distances, or just assume that
- * anything should be passed along to the dv service?).
- */
 #include "platform.h"
 #include "gnunet_protocols.h"
 #include "gnunet_connection_lib.h"
@@ -434,6 +414,9 @@ libgnunet_plugin_transport_dv_done (void *cls)
   struct GNUNET_TRANSPORT_PluginFunctions *api = cls;
   struct Plugin *plugin = api->cls;
 
+  if (plugin->dv_handle != NULL)
+    GNUNET_DV_disconnect(plugin->dv_handle);
+
   GNUNET_free (plugin);
   GNUNET_free (api);
   return NULL;
index 3cfabe2379f8995ce2f4e537bad4f14356eaaf61..faf279066eb0ef4e7e663de70a3f2d8a66745475 100644 (file)
@@ -321,7 +321,15 @@ process_mtype (void *cls,
   if ((total_messages_received == expected_messages) && (total_other_messages == 0))
     {
       GNUNET_SCHEDULER_cancel (sched, die_task);
-      GNUNET_SCHEDULER_add_delayed (sched, GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 420), &send_other_messages, NULL);
+      /*
+      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))
     {
@@ -827,6 +835,12 @@ static void all_connect_handler (void *cls,
         fprintf(dotOutFile, "\tn%s -- n%s [color=brown];\n", d->shortname, second_shortname);
     }
   GNUNET_free(second_shortname);
+
+  if ((num_peers == 3) && (temp_total_other_messages == 2))
+    {
+      /*GNUNET_SCHEDULER_add_delayed (sched, GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30), &send_other_messages, NULL);*/
+      GNUNET_SCHEDULER_add_now (sched, &send_other_messages, NULL);
+    }
 }
 
 static void
@@ -1064,7 +1078,6 @@ main (int argc, char *argv[])
 #endif
                     NULL);
   ret = check ();
-
   /**
    * Need to remove base directory, subdirectories taken care
    * of by the testing framework.
index 73d7f687685d9a9d5bfed98b7fdd91fc4775b345..e3e3bf250091126224f16f1dcca9d94f3c54f013 100644 (file)
@@ -10,14 +10,16 @@ DEBUG = NO
 PORT = 2565
 PLUGINS = tcp dv
 BLACKLIST_FILE = $SERVICEHOME/blacklist
-#PREFIX = xterm -e xterm -T transport -e gdb --args
-#BINARY = /home/mrwiggles/documents/research/gnunet/gnunet-ng/src/transport/.libs/gnunet-service-transport
-#PREFIX = valgrind --tool=memcheck --log-file=logs%p
+#PREFIX = xterm -hold -T transport -e gdb --args
+#PREFIX = gdb --args
+BINARY = /home/mrwiggles/documents/research/gnunet/gnunet-ng/src/transport/.libs/gnunet-service-transport
+#BINARY = gnunet-service-transport
+PREFIX = valgrind --tool=memcheck --log-file=logs%p --track-origins=yes
 #DEBUG = YES
 
 [arm]
 PORT = 2566
-DEFAULTSERVICES = 
+DEFAULTSERVICES = transport
 
 [statistics]
 PORT = 2567
@@ -43,7 +45,7 @@ PORT = 2570
 
 [dv]
 AUTOSTART = YES
-DEBUG = YES
+DEBUG = NO
 ACCEPT_FROM6 = ::1;
 ACCEPT_FROM = 127.0.0.1;
 BINARY = gnunet-service-dv
@@ -58,7 +60,7 @@ PORT = 2571
 
 [testing]
 NUM_PEERS = 3
-DEBUG = YES
+DEBUG = NO
 WEAKRANDOM = YES
 TOPOLOGY = CLIQUE
 CONNECT_TOPOLOGY = LINE