From: Christian Grothoff Date: Fri, 19 Feb 2010 15:45:16 +0000 (+0000) Subject: debugging X-Git-Tag: initial-import-from-subversion-38251~22654 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=f06ca9dcef0d602baa3a7c6462baff0dd70b2e4a;p=oweals%2Fgnunet.git debugging --- diff --git a/src/fs/fs_download.c b/src/fs/fs_download.c index 289599471..1399cf8dd 100644 --- a/src/fs/fs_download.c +++ b/src/fs/fs_download.c @@ -36,7 +36,7 @@ #include "fs.h" #include "fs_tree.h" -#define DEBUG_DOWNLOAD GNUNET_NO +#define DEBUG_DOWNLOAD GNUNET_YES /** * We're storing the IBLOCKS after the @@ -65,9 +65,9 @@ compute_disk_offset (uint64_t fsize, unsigned int treedepth) { unsigned int i; - uint64_t lsize; /* what is the size of all IBlocks for level "i"? */ - uint64_t loff; /* where do IBlocks for level "i" start? */ - unsigned int ioff; /* which IBlock corresponds to "off" at level "i"? */ + uint64_t lsize; /* what is the size of all IBlocks for depth "i"? */ + uint64_t loff; /* where do IBlocks for depth "i" start? */ + unsigned int ioff; /* which IBlock corresponds to "off" at depth "i"? */ if (depth == treedepth) return off; @@ -113,7 +113,7 @@ compute_dblock_offset (uint64_t offset, { unsigned int i; uint64_t lsize; /* what is the size of the sum of all DBlocks - that a CHK at level i corresponds to? */ + that a CHK at depth i corresponds to? */ if (depth == treedepth) return offset; @@ -504,7 +504,7 @@ process_result (struct GNUNET_FS_DownloadContext *dc, } #if DEBUG_DOWNLOAD GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Triggering downloads of children (this block was at level %u and offset %llu)\n", + "Triggering downloads of children (this block was at depth %u and offset %llu)\n", sm->depth, (unsigned long long) sm->offset); #endif @@ -920,61 +920,4 @@ GNUNET_FS_download_stop (struct GNUNET_FS_DownloadContext *dc, GNUNET_free (dc); } - - -#if 0 - - -/** - * Check if self block is already present on the drive. If the block - * is a dblock and present, the ProgressModel is notified. If the - * block is present and it is an iblock, downloading the children is - * triggered. - * - * Also checks if the block is within the range of blocks - * that we are supposed to download. If not, the method - * returns as if the block is present but does NOT signal - * progress. - * - * @param node that is checked for presence - * @return GNUNET_YES if present, GNUNET_NO if not. - */ -static int -check_node_present (const struct Node *node) -{ - int res; - int ret; - char *data; - unsigned int size; - GNUNET_HashCode hc; - - size = get_node_size (node); - /* first check if node is within range. - For now, keeping it simple, we only do - this for level-0 nodes */ - if ((node->level == 0) && - ((node->offset + size < node->ctx->offset) || - (node->offset >= node->ctx->offset + node->ctx->length))) - return GNUNET_YES; - data = GNUNET_malloc (size); - ret = GNUNET_NO; - res = read_from_files (node->ctx, node->level, node->offset, data, size); - if (res == size) - { - GNUNET_hash (data, size, &hc); - if (0 == memcmp (&hc, &node->chk.key, sizeof (GNUNET_HashCode))) - { - notify_client_about_progress (node, data, size); - if (node->level > 0) - iblock_download_children (node, data, size); - ret = GNUNET_YES; - } - } - GNUNET_free (data); - return ret; -} - -#endif - - /* end of fs_download.c */ diff --git a/src/fs/fs_file_information.c b/src/fs/fs_file_information.c index 9c193f88b..08beff982 100644 --- a/src/fs/fs_file_information.c +++ b/src/fs/fs_file_information.c @@ -847,7 +847,8 @@ GNUNET_FS_file_information_destroy (struct GNUNET_FS_FileInformation *fi, GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "unlink", fi->serialization); - GNUNET_FS_uri_destroy (fi->keywords); + if (NULL != fi->keywords) + GNUNET_FS_uri_destroy (fi->keywords); GNUNET_CONTAINER_meta_data_destroy (fi->meta); GNUNET_free_non_null (fi->serialization); if (fi->te != NULL) diff --git a/src/fs/fs_publish.c b/src/fs/fs_publish.c index c99e598b1..b437fcf80 100644 --- a/src/fs/fs_publish.c +++ b/src/fs/fs_publish.c @@ -300,10 +300,8 @@ publish_sblock (struct GNUNET_FS_PublishContext *sc) /** - * We've finished publishing a KBlock - * as part of a larger upload. Check - * the result and continue the larger - * upload. + * We've finished publishing a KBlock as part of a larger upload. + * Check the result and continue the larger upload. * * @param cls the "struct GNUNET_FS_PublishContext*" * of the larger upload @@ -865,16 +863,25 @@ do_upload (void *cls, if (NULL != p->chk_uri) { /* upload of "p" complete, publish KBlocks! */ - GNUNET_FS_publish_ksk (sc->h, - p->keywords, - p->meta, - p->chk_uri, - p->expirationTime, - p->anonymity, - p->priority, - sc->options, - &publish_kblocks_cont, - sc); + if (p->keywords != NULL) + { + GNUNET_FS_publish_ksk (sc->h, + p->keywords, + p->meta, + p->chk_uri, + p->expirationTime, + p->anonymity, + p->priority, + sc->options, + &publish_kblocks_cont, + sc); + } + else + { + publish_kblocks_cont (sc, + p->chk_uri, + NULL); + } return; } if ( (!p->is_directory) && diff --git a/src/fs/gnunet-service-fs.c b/src/fs/gnunet-service-fs.c index 11ab41582..da7d6fb0a 100644 --- a/src/fs/gnunet-service-fs.c +++ b/src/fs/gnunet-service-fs.c @@ -43,7 +43,7 @@ #include "gnunet-service-fs_indexing.h" #include "fs.h" -#define DEBUG_FS GNUNET_NO +#define DEBUG_FS GNUNET_YES /** * Maximum number of outgoing messages we queue per peer. diff --git a/src/fs/test_fs_lib_data.conf b/src/fs/test_fs_lib_data.conf index b9d11c371..43fea398e 100644 --- a/src/fs/test_fs_lib_data.conf +++ b/src/fs/test_fs_lib_data.conf @@ -12,11 +12,12 @@ HOSTNAME = localhost [transport] PORT = 43465 PLUGINS = tcp +#DEBUG = YES [arm] PORT = 43466 HOSTNAME = localhost -DEFAULTSERVICES = resolver datastore transport core fs +DEFAULTSERVICES = resolver datastore transport core fs peerinfo [datastore] #DEBUG = YES @@ -28,7 +29,7 @@ HOSTNAME = localhost [transport-tcp] ALLOW_SHUTDOWN = NO TIMEOUT = 300000 -PORT = 43468 +#PORT = 43468 [peerinfo] PORT = 43469 @@ -37,12 +38,13 @@ HOSTNAME = localhost [core] PORT = 43470 HOSTNAME = localhost +#DEBUG = YES [fs] PORT = 43471 HOSTNAME = localhost -#DEBUG = YES -#PREFIX = valgrind --tool=memcheck --leak-check=yes +DEBUG = YES +PREFIX = valgrind --tool=memcheck --leak-check=yes #BINARY = /home/grothoff/bin/gnunet-service-fs [testing] diff --git a/src/fs/test_gnunet_service_fs_p2p.c b/src/fs/test_gnunet_service_fs_p2p.c index e31e7a691..6b95221d1 100644 --- a/src/fs/test_gnunet_service_fs_p2p.c +++ b/src/fs/test_gnunet_service_fs_p2p.c @@ -26,7 +26,7 @@ #include "platform.h" #include "test_fs_lib.h" -#define VERBOSE GNUNET_NO +#define VERBOSE GNUNET_YES /** * File-size we use for testing. @@ -70,7 +70,7 @@ do_download (void *cls, "Downloading %llu bytes\n", (unsigned long long) FILESIZE); GNUNET_FS_TEST_download (sched, - daemons[1], + daemons[0], TIMEOUT, 1, SEED, uri, VERBOSE, @@ -87,7 +87,7 @@ do_publish (void *cls, "Publishing %llu bytes\n", (unsigned long long) FILESIZE); GNUNET_FS_TEST_publish (sched, - daemons[1], + daemons[0], TIMEOUT, 1, GNUNET_NO, FILESIZE, SEED, VERBOSE, @@ -100,6 +100,8 @@ do_connect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { GNUNET_assert (0 != (tc->reason & GNUNET_SCHEDULER_REASON_PREREQ_DONE)); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Daemons started, will now try to connect them\n"); GNUNET_FS_TEST_daemons_connect (sched, daemons[0], daemons[1], @@ -142,6 +144,7 @@ main (int argc, char *argv[]) GNUNET_GETOPT_OPTION_END }; + GNUNET_DISK_directory_remove ("/tmp/gnunet-test-fs-lib/"); GNUNET_log_setup ("test_gnunet_service_fs_p2p", #if VERBOSE "DEBUG", @@ -152,6 +155,7 @@ main (int argc, char *argv[]) GNUNET_PROGRAM_run ((sizeof (argvx) / sizeof (char *)) - 1, argvx, "test-gnunet-service-fs-p2p", "nohelp", options, &run, NULL); + GNUNET_DISK_directory_remove ("/tmp/gnunet-test-fs-lib/"); return 0; } diff --git a/src/testing/testing.c b/src/testing/testing.c index d1d0b95c9..3dd4af367 100644 --- a/src/testing/testing.c +++ b/src/testing/testing.c @@ -40,7 +40,7 @@ #include "gnunet_testing_lib.h" #include "gnunet_transport_service.h" -#define DEBUG_TESTING GNUNET_YES +#define DEBUG_TESTING GNUNET_NO /** * How long do we wait after starting gnunet-service-arm @@ -828,10 +828,13 @@ send_hello(void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) if (ctx->hello != NULL) { GNUNET_TRANSPORT_offer_hello (ctx->d2th, ctx->hello); - ctx->timeout_hello = GNUNET_TIME_relative_add(ctx->timeout_hello, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 200)); + ctx->timeout_hello = GNUNET_TIME_relative_add(ctx->timeout_hello, + GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, + 200)); } - - ctx->hello_send_task = GNUNET_SCHEDULER_add_delayed(ctx->d1->sched, ctx->timeout_hello, &send_hello, ctx); + ctx->hello_send_task = GNUNET_SCHEDULER_add_delayed(ctx->d1->sched, + ctx->timeout_hello, + &send_hello, ctx); } @@ -974,7 +977,8 @@ GNUNET_TESTING_daemons_connect (struct GNUNET_TESTING_Daemon *d1, ¬ify_connect_result, ctx); GNUNET_TRANSPORT_get_hello (ctx->d1th, &process_hello, ctx); - ctx->hello_send_task = GNUNET_SCHEDULER_add_delayed(ctx->d1->sched, ctx->timeout_hello, &send_hello, ctx); + ctx->hello_send_task = GNUNET_SCHEDULER_add_delayed(ctx->d1->sched, ctx->timeout_hello, + &send_hello, ctx); } diff --git a/src/transport/gnunet-service-transport.c b/src/transport/gnunet-service-transport.c index e206da43e..370000cf1 100644 --- a/src/transport/gnunet-service-transport.c +++ b/src/transport/gnunet-service-transport.c @@ -2750,10 +2750,6 @@ handle_hello (void *cls, { int ret; -#if DEBUG_TRANSPORT - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Received `%s' request from client\n", "HELLO"); -#endif ret = process_hello (NULL, message); GNUNET_SERVER_receive_done (client, ret); } diff --git a/src/util/peer.c b/src/util/peer.c index 2ad4b3d67..5c00d5580 100644 --- a/src/util/peer.c +++ b/src/util/peer.c @@ -31,21 +31,18 @@ struct PeerEntry { /** - * the identifier itself + * The identifier itself */ struct GNUNET_PeerIdentity id; /** - * Short version of the identifier; - * if the RC==0, then index of next - * free slot in table, otherwise - * equal to this slot in the table. + * Short version of the identifier; if the RC==0, then index of next + * free slot in table, otherwise equal to this slot in the table. */ GNUNET_PEER_Id pid; /** - * Reference counter, 0 if this slot - * is not used. + * Reference counter, 0 if this slot is not used. */ unsigned int rc; }; @@ -144,6 +141,8 @@ GNUNET_PEER_decrement_rcs (const GNUNET_PEER_Id * ids, unsigned int count) for (i = count - 1; i >= 0; i--) { id = ids[i]; + if (id == 0) + continue; GNUNET_assert (id < size); GNUNET_assert (table[id].rc > 0); table[id].rc--;