From b6956204e275423100b333aeb25028118a682335 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Tue, 23 Feb 2010 14:59:29 +0000 Subject: [PATCH] bugfixes, extra assertions --- src/fs/fs_download.c | 4 ++++ src/fs/fs_test_lib_data.conf | 2 +- src/fs/gnunet-service-fs.c | 34 ++++++++++++++++++++++++++++++---- 3 files changed, 35 insertions(+), 5 deletions(-) diff --git a/src/fs/fs_download.c b/src/fs/fs_download.c index 1399cf8dd..aa78a9294 100644 --- a/src/fs/fs_download.c +++ b/src/fs/fs_download.c @@ -608,6 +608,10 @@ transmit_download_request (void *cls, memset (sm, 0, sizeof (struct SearchMessage)); sm->header.size = htons (sizeof (struct SearchMessage)); sm->header.type = htons (GNUNET_MESSAGE_TYPE_FS_START_SEARCH); + if (dc->pending->depth == dc->treedepth) + sm->type = htonl (GNUNET_DATASTORE_BLOCKTYPE_DBLOCK); + else + sm->type = htonl (GNUNET_DATASTORE_BLOCKTYPE_IBLOCK); sm->anonymity_level = htonl (dc->anonymity); sm->target = dc->target.hashPubKey; sm->query = dc->pending->chk.query; diff --git a/src/fs/fs_test_lib_data.conf b/src/fs/fs_test_lib_data.conf index d62ee8c98..7ca0166a1 100644 --- a/src/fs/fs_test_lib_data.conf +++ b/src/fs/fs_test_lib_data.conf @@ -46,7 +46,7 @@ DEBUG = YES PORT = 43471 HOSTNAME = localhost DEBUG = YES -#PREFIX = valgrind --tool=memcheck --leak-check=yes +PREFIX = valgrind --tool=memcheck --leak-check=yes #BINARY = /home/grothoff/bin/gnunet-service-fs #PREFIX = xterm -e gdb -x cmd --args diff --git a/src/fs/gnunet-service-fs.c b/src/fs/gnunet-service-fs.c index 7ae9aaafa..efade8521 100644 --- a/src/fs/gnunet-service-fs.c +++ b/src/fs/gnunet-service-fs.c @@ -2174,6 +2174,7 @@ handle_p2p_get (void *cls, uint32_t ttl_decrement; uint32_t type; double preference; + int have_ns; msize = ntohs(message->size); if (msize < sizeof (struct GetMessage)) @@ -2182,6 +2183,18 @@ handle_p2p_get (void *cls, return GNUNET_SYSERR; } gm = (const struct GetMessage*) message; + type = ntohl (gm->type); + switch (type) + { + case GNUNET_DATASTORE_BLOCKTYPE_DBLOCK: + case GNUNET_DATASTORE_BLOCKTYPE_IBLOCK: + case GNUNET_DATASTORE_BLOCKTYPE_KBLOCK: + case GNUNET_DATASTORE_BLOCKTYPE_SBLOCK: + break; + default: + GNUNET_break_op (0); + return GNUNET_SYSERR; + } bm = ntohl (gm->hash_bitmap); bits = 0; while (bm > 0) @@ -2249,11 +2262,12 @@ handle_p2p_get (void *cls, (unsigned int) ntohl (gm->type), GNUNET_i2s (other)); #endif + have_ns = (0 != (bm & GET_MESSAGE_BIT_SKS_NAMESPACE)); pr = GNUNET_malloc (sizeof (struct PendingRequest) + - (bm & GET_MESSAGE_BIT_SKS_NAMESPACE)?sizeof(GNUNET_HashCode):0); - if ((bm & GET_MESSAGE_BIT_SKS_NAMESPACE)) + (have_ns ? sizeof(GNUNET_HashCode) : 0)); + if (have_ns) pr->namespace = (GNUNET_HashCode*) &pr[1]; - pr->type = ntohl (gm->type); + pr->type = type; pr->mingle = ntohl (gm->filter_mutator); if (0 != (bm & GET_MESSAGE_BIT_SKS_NAMESPACE)) memcpy (&pr[1], &opt[bits++], sizeof (GNUNET_HashCode)); @@ -2354,7 +2368,6 @@ handle_p2p_get (void *cls, cps->inc_preference += preference; /* process locally */ - type = pr->type; if (type == GNUNET_DATASTORE_BLOCKTYPE_DBLOCK) type = GNUNET_DATASTORE_BLOCKTYPE_ANY; /* to get on-demand as well */ timeout = GNUNET_TIME_relative_multiply (BASIC_DATASTORE_REQUEST_DELAY, @@ -2438,6 +2451,19 @@ handle_start_search (void *cls, client_list = cl; } type = ntohl (sm->type); + switch (type) + { + case GNUNET_DATASTORE_BLOCKTYPE_DBLOCK: + case GNUNET_DATASTORE_BLOCKTYPE_IBLOCK: + case GNUNET_DATASTORE_BLOCKTYPE_KBLOCK: + case GNUNET_DATASTORE_BLOCKTYPE_SBLOCK: + break; + default: + GNUNET_break (0); + GNUNET_SERVER_receive_done (client, + GNUNET_SYSERR); + return GNUNET_SYSERR; + } #if DEBUG_FS GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received request for `%s' of type %u from local client\n", -- 2.25.1