From 76259023a5566d42229a4a284616fa8bac93b6a5 Mon Sep 17 00:00:00 2001 From: "Nathan S. Evans" Date: Thu, 24 Jun 2010 11:03:11 +0000 Subject: [PATCH] misc bugfixes, especially core dumps for dv test case --- src/dv/dv.h | 14 ++++---- src/dv/dv_api.c | 56 ++++++++++++++++++------------ src/dv/gnunet-service-dv.c | 6 ++-- src/dv/plugin_transport_dv.c | 25 +++---------- src/dv/test_transport_api_dv.c | 17 +++++++-- src/dv/test_transport_dv_data.conf | 14 ++++---- 6 files changed, 70 insertions(+), 62 deletions(-) diff --git a/src/dv/dv.h b/src/dv/dv.h index 28a56031e..7b32d7d14 100644 --- a/src/dv/dv.h +++ b/src/dv/dv.h @@ -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 diff --git a/src/dv/dv_api.c b/src/dv/dv_api.c index 9ab15ea62..8b92a703f 100644 --- a/src/dv/dv_api.c +++ b/src/dv/dv_api.c @@ -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; diff --git a/src/dv/gnunet-service-dv.c b/src/dv/gnunet-service-dv.c index b89a0c1d9..20ce71952 100644 --- a/src/dv/gnunet-service-dv.c +++ b/src/dv/gnunet-service-dv.c @@ -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); diff --git a/src/dv/plugin_transport_dv.c b/src/dv/plugin_transport_dv.c index f4811bbe9..30e5b6ac1 100644 --- a/src/dv/plugin_transport_dv.c +++ b/src/dv/plugin_transport_dv.c @@ -22,30 +22,10 @@ * @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; diff --git a/src/dv/test_transport_api_dv.c b/src/dv/test_transport_api_dv.c index 3cfabe237..faf279066 100644 --- a/src/dv/test_transport_api_dv.c +++ b/src/dv/test_transport_api_dv.c @@ -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. diff --git a/src/dv/test_transport_dv_data.conf b/src/dv/test_transport_dv_data.conf index 73d7f6876..e3e3bf250 100644 --- a/src/dv/test_transport_dv_data.conf +++ b/src/dv/test_transport_dv_data.conf @@ -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 -- 2.25.1