diff options
author | Christian Grothoff <christian@grothoff.org> | 2009-10-19 15:34:53 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2009-10-19 15:34:53 +0000 |
commit | d7d47265d3680eee277723f420db1baa455ccbb8 (patch) | |
tree | 1c795b3ea9a3628a7980539753149db8c7c20703 | |
parent | 11ce3736a27e5f9082411eea577c05c58ad2793b (diff) | |
download | gnunet-d7d47265d3680eee277723f420db1baa455ccbb8.tar.gz gnunet-d7d47265d3680eee277723f420db1baa455ccbb8.zip |
debug code and fixes
-rw-r--r-- | src/fs/fs_download.c | 42 | ||||
-rw-r--r-- | src/fs/gnunet-service-fs.c | 44 | ||||
-rw-r--r-- | src/fs/test_fs_download_data.conf | 1 |
3 files changed, 83 insertions, 4 deletions
diff --git a/src/fs/fs_download.c b/src/fs/fs_download.c index 6d3886c70..e6342a067 100644 --- a/src/fs/fs_download.c +++ b/src/fs/fs_download.c | |||
@@ -302,8 +302,15 @@ process_result (struct GNUNET_FS_DownloadContext *dc, | |||
302 | struct ContentHashKey *chk; | 302 | struct ContentHashKey *chk; |
303 | char *emsg; | 303 | char *emsg; |
304 | 304 | ||
305 | |||
305 | GNUNET_CRYPTO_hash (data, size, &query); | 306 | GNUNET_CRYPTO_hash (data, size, &query); |
306 | sm = GNUNET_CONTAINER_multihashmap_get (dc->active, | 307 | #if DEBUG_DOWNLOAD |
308 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
309 | "Received result for query `%s' from `%s'-service\n", | ||
310 | GNUNET_h2s (&query), | ||
311 | "FS"); | ||
312 | #endif | ||
313 | sm = GNUNET_CONTAINER_multihashmap_get (dc->active, | ||
307 | &query); | 314 | &query); |
308 | if (NULL == sm) | 315 | if (NULL == sm) |
309 | { | 316 | { |
@@ -315,6 +322,10 @@ process_result (struct GNUNET_FS_DownloadContext *dc, | |||
315 | sm->offset, | 322 | sm->offset, |
316 | sm->depth)) | 323 | sm->depth)) |
317 | { | 324 | { |
325 | #if DEBUG_DOWNLOAD | ||
326 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
327 | "Internal error or bogus download URI\n"); | ||
328 | #endif | ||
318 | dc->emsg = GNUNET_strdup ("Internal error or bogus download URI"); | 329 | dc->emsg = GNUNET_strdup ("Internal error or bogus download URI"); |
319 | /* signal error */ | 330 | /* signal error */ |
320 | pi.status = GNUNET_FS_STATUS_DOWNLOAD_ERROR; | 331 | pi.status = GNUNET_FS_STATUS_DOWNLOAD_ERROR; |
@@ -347,6 +358,11 @@ process_result (struct GNUNET_FS_DownloadContext *dc, | |||
347 | sm->depth, | 358 | sm->depth, |
348 | dc->treedepth); | 359 | dc->treedepth); |
349 | emsg = NULL; | 360 | emsg = NULL; |
361 | #if DEBUG_DOWNLOAD | ||
362 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
363 | "Saving decrypted block to disk at offset %llu\n", | ||
364 | (unsigned long long) off); | ||
365 | #endif | ||
350 | if ( (off != | 366 | if ( (off != |
351 | GNUNET_DISK_file_seek (dc->handle, | 367 | GNUNET_DISK_file_seek (dc->handle, |
352 | off, | 368 | off, |
@@ -415,6 +431,11 @@ process_result (struct GNUNET_FS_DownloadContext *dc, | |||
415 | GNUNET_assert (dc->completed <= dc->length); | 431 | GNUNET_assert (dc->completed <= dc->length); |
416 | if (dc->completed == dc->length) | 432 | if (dc->completed == dc->length) |
417 | { | 433 | { |
434 | #if DEBUG_DOWNLOAD | ||
435 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
436 | "Download completed, truncating file to desired length %llu\n", | ||
437 | (unsigned long long) GNUNET_ntohll (dc->uri->data.chk.file_length)); | ||
438 | #endif | ||
418 | /* truncate file to size (since we store IBlocks at the end) */ | 439 | /* truncate file to size (since we store IBlocks at the end) */ |
419 | if (dc->handle != NULL) | 440 | if (dc->handle != NULL) |
420 | { | 441 | { |
@@ -436,6 +457,11 @@ process_result (struct GNUNET_FS_DownloadContext *dc, | |||
436 | // FIXME: make persistent | 457 | // FIXME: make persistent |
437 | if (sm->depth == dc->treedepth) | 458 | if (sm->depth == dc->treedepth) |
438 | return; | 459 | return; |
460 | #if DEBUG_DOWNLOAD | ||
461 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
462 | "Triggering downloads of children (this block was at level %u)\n", | ||
463 | dc->treedepth); | ||
464 | #endif | ||
439 | GNUNET_assert (0 == (size % sizeof(struct ContentHashKey))); | 465 | GNUNET_assert (0 == (size % sizeof(struct ContentHashKey))); |
440 | chk = (struct ContentHashKey*) pt; | 466 | chk = (struct ContentHashKey*) pt; |
441 | for (i=0;i<(size / sizeof(struct ContentHashKey));i++) | 467 | for (i=0;i<(size / sizeof(struct ContentHashKey));i++) |
@@ -519,9 +545,15 @@ transmit_download_request (void *cls, | |||
519 | GNUNET_assert (size >= sizeof (struct SearchMessage)); | 545 | GNUNET_assert (size >= sizeof (struct SearchMessage)); |
520 | msize = 0; | 546 | msize = 0; |
521 | sm = buf; | 547 | sm = buf; |
522 | while ( (dc->pending == NULL) && | 548 | while ( (dc->pending != NULL) && |
523 | (size > msize + sizeof (struct SearchMessage)) ) | 549 | (size > msize + sizeof (struct SearchMessage)) ) |
524 | { | 550 | { |
551 | #if DEBUG_DOWNLOAD | ||
552 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
553 | "Transmitting download request for `%s' to `%s'-service\n", | ||
554 | GNUNET_h2s (&dc->pending->chk.query), | ||
555 | "FS"); | ||
556 | #endif | ||
525 | memset (sm, 0, sizeof (struct SearchMessage)); | 557 | memset (sm, 0, sizeof (struct SearchMessage)); |
526 | sm->header.size = htons (sizeof (struct SearchMessage)); | 558 | sm->header.size = htons (sizeof (struct SearchMessage)); |
527 | sm->header.type = htons (GNUNET_MESSAGE_TYPE_FS_START_SEARCH); | 559 | sm->header.type = htons (GNUNET_MESSAGE_TYPE_FS_START_SEARCH); |
@@ -557,6 +589,9 @@ do_reconnect (void *cls, | |||
557 | dc->h->cfg); | 589 | dc->h->cfg); |
558 | if (NULL == client) | 590 | if (NULL == client) |
559 | { | 591 | { |
592 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
593 | "Connecting to `%s'-service failed, will try again.\n", | ||
594 | "FS"); | ||
560 | try_reconnect (dc); | 595 | try_reconnect (dc); |
561 | return; | 596 | return; |
562 | } | 597 | } |
@@ -574,8 +609,7 @@ do_reconnect (void *cls, | |||
574 | 609 | ||
575 | 610 | ||
576 | /** | 611 | /** |
577 | * Add entries that are not yet pending back to | 612 | * Add entries that are not yet pending back to the pending list. |
578 | * the pending list. | ||
579 | * | 613 | * |
580 | * @param cls our download context | 614 | * @param cls our download context |
581 | * @param key unused | 615 | * @param key unused |
diff --git a/src/fs/gnunet-service-fs.c b/src/fs/gnunet-service-fs.c index b01a4f29e..ac2f9f408 100644 --- a/src/fs/gnunet-service-fs.c +++ b/src/fs/gnunet-service-fs.c | |||
@@ -1312,6 +1312,10 @@ transmit_local_result (void *cls, | |||
1312 | 1312 | ||
1313 | if (NULL == buf) | 1313 | if (NULL == buf) |
1314 | { | 1314 | { |
1315 | #if DEBUG_FS | ||
1316 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1317 | "Failed to transmit result to local client, aborting datastore iteration.\n"); | ||
1318 | #endif | ||
1315 | /* error, abort! */ | 1319 | /* error, abort! */ |
1316 | GNUNET_free (lgc->result); | 1320 | GNUNET_free (lgc->result); |
1317 | lgc->result = NULL; | 1321 | lgc->result = NULL; |
@@ -1319,6 +1323,11 @@ transmit_local_result (void *cls, | |||
1319 | return 0; | 1323 | return 0; |
1320 | } | 1324 | } |
1321 | msize = ntohs (lgc->result->header.size); | 1325 | msize = ntohs (lgc->result->header.size); |
1326 | #if DEBUG_FS | ||
1327 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1328 | "Transmitting %u bytes of result to local client.\n", | ||
1329 | msize); | ||
1330 | #endif | ||
1322 | GNUNET_assert (max >= msize); | 1331 | GNUNET_assert (max >= msize); |
1323 | memcpy (buf, lgc->result, msize); | 1332 | memcpy (buf, lgc->result, msize); |
1324 | GNUNET_free (lgc->result); | 1333 | GNUNET_free (lgc->result); |
@@ -1895,6 +1904,11 @@ process_local_get_result (void *cls, | |||
1895 | 1904 | ||
1896 | if (key == NULL) | 1905 | if (key == NULL) |
1897 | { | 1906 | { |
1907 | #if DEBUG_FS | ||
1908 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1909 | "Received last result for `%s' from local datastore, deciding what to do next.\n", | ||
1910 | GNUNET_h2s (&lgc->query)); | ||
1911 | #endif | ||
1898 | /* no further results from datastore; continue | 1912 | /* no further results from datastore; continue |
1899 | processing further requests from the client and | 1913 | processing further requests from the client and |
1900 | allow the next task to use the datastore; also, | 1914 | allow the next task to use the datastore; also, |
@@ -1907,6 +1921,11 @@ process_local_get_result (void *cls, | |||
1907 | (lgc->type == GNUNET_DATASTORE_BLOCKTYPE_SBLOCK) || | 1921 | (lgc->type == GNUNET_DATASTORE_BLOCKTYPE_SBLOCK) || |
1908 | (lgc->type == GNUNET_DATASTORE_BLOCKTYPE_SKBLOCK) ) | 1922 | (lgc->type == GNUNET_DATASTORE_BLOCKTYPE_SKBLOCK) ) |
1909 | { | 1923 | { |
1924 | #if DEBUG_FS | ||
1925 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1926 | "Forwarding query for `%s' to network.\n", | ||
1927 | GNUNET_h2s (&lgc->query)); | ||
1928 | #endif | ||
1910 | cl = clients; | 1929 | cl = clients; |
1911 | while ( (NULL != cl) && | 1930 | while ( (NULL != cl) && |
1912 | (cl->client != lgc->client) ) | 1931 | (cl->client != lgc->client) ) |
@@ -1960,11 +1979,21 @@ process_local_get_result (void *cls, | |||
1960 | return; | 1979 | return; |
1961 | } | 1980 | } |
1962 | /* got all possible results, clean up! */ | 1981 | /* got all possible results, clean up! */ |
1982 | #if DEBUG_FS | ||
1983 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1984 | "Found all possible results for query for `%s', done!\n", | ||
1985 | GNUNET_h2s (&lgc->query)); | ||
1986 | #endif | ||
1963 | local_get_context_free (lgc); | 1987 | local_get_context_free (lgc); |
1964 | return; | 1988 | return; |
1965 | } | 1989 | } |
1966 | if (type == GNUNET_DATASTORE_BLOCKTYPE_ONDEMAND) | 1990 | if (type == GNUNET_DATASTORE_BLOCKTYPE_ONDEMAND) |
1967 | { | 1991 | { |
1992 | #if DEBUG_FS | ||
1993 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1994 | "Received on-demand block for `%s' from local datastore, fetching data.\n", | ||
1995 | GNUNET_h2s (&lgc->query)); | ||
1996 | #endif | ||
1968 | handle_on_demand_block (key, size, data, type, priority, | 1997 | handle_on_demand_block (key, size, data, type, priority, |
1969 | anonymity, expiration, uid, | 1998 | anonymity, expiration, uid, |
1970 | &process_local_get_result, | 1999 | &process_local_get_result, |
@@ -1977,6 +2006,11 @@ process_local_get_result (void *cls, | |||
1977 | query hash being identical to KBLOCK/SBLOCK query hash); | 2006 | query hash being identical to KBLOCK/SBLOCK query hash); |
1978 | nevertheless, if it happens, the correct thing is to | 2007 | nevertheless, if it happens, the correct thing is to |
1979 | simply skip the result. */ | 2008 | simply skip the result. */ |
2009 | #if DEBUG_FS | ||
2010 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
2011 | "Received block of unexpected type for `%s' from local datastore, ignoring.\n", | ||
2012 | GNUNET_h2s (&lgc->query)); | ||
2013 | #endif | ||
1980 | GNUNET_DATASTORE_get_next (dsh, GNUNET_YES); | 2014 | GNUNET_DATASTORE_get_next (dsh, GNUNET_YES); |
1981 | return; | 2015 | return; |
1982 | } | 2016 | } |
@@ -1987,6 +2021,11 @@ process_local_get_result (void *cls, | |||
1987 | &lgc->results[i], | 2021 | &lgc->results[i], |
1988 | sizeof (GNUNET_HashCode))) | 2022 | sizeof (GNUNET_HashCode))) |
1989 | { | 2023 | { |
2024 | #if DEBUG_FS | ||
2025 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
2026 | "Received duplicate result for `%s' from local datastore, ignoring.\n", | ||
2027 | GNUNET_h2s (&lgc->query)); | ||
2028 | #endif | ||
1990 | GNUNET_DATASTORE_get_next (dsh, GNUNET_YES); | 2029 | GNUNET_DATASTORE_get_next (dsh, GNUNET_YES); |
1991 | return; | 2030 | return; |
1992 | } | 2031 | } |
@@ -2007,6 +2046,11 @@ process_local_get_result (void *cls, | |||
2007 | memcpy (&lgc->result[1], | 2046 | memcpy (&lgc->result[1], |
2008 | data, | 2047 | data, |
2009 | size); | 2048 | size); |
2049 | #if DEBUG_FS | ||
2050 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
2051 | "Received new result for `%s' from local datastore, passing to client.\n", | ||
2052 | GNUNET_h2s (&lgc->query)); | ||
2053 | #endif | ||
2010 | GNUNET_SERVER_notify_transmit_ready (lgc->client, | 2054 | GNUNET_SERVER_notify_transmit_ready (lgc->client, |
2011 | msize, | 2055 | msize, |
2012 | GNUNET_TIME_UNIT_FOREVER_REL, | 2056 | GNUNET_TIME_UNIT_FOREVER_REL, |
diff --git a/src/fs/test_fs_download_data.conf b/src/fs/test_fs_download_data.conf index 312c33d22..41678142c 100644 --- a/src/fs/test_fs_download_data.conf +++ b/src/fs/test_fs_download_data.conf | |||
@@ -36,6 +36,7 @@ HOSTNAME = localhost | |||
36 | [fs] | 36 | [fs] |
37 | PORT = 42471 | 37 | PORT = 42471 |
38 | HOSTNAME = localhost | 38 | HOSTNAME = localhost |
39 | DEBUG = YES | ||
39 | 40 | ||
40 | [testing] | 41 | [testing] |
41 | WEAKRANDOM = YES | 42 | WEAKRANDOM = YES |