diff options
Diffstat (limited to 'src/fs/fs_download.c')
-rw-r--r-- | src/fs/fs_download.c | 42 |
1 files changed, 38 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 |