diff options
author | Christian Grothoff <christian@grothoff.org> | 2012-02-11 23:26:54 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2012-02-11 23:26:54 +0000 |
commit | f1f99ff0bcb5fc9865ab50765bfdba42bb9c38f9 (patch) | |
tree | 03b833d787ebb1080452e3458c3adff49d4dec1c /src/fs/fs_download.c | |
parent | 9845b58e87366bf7e059fdeb6cdd9d98fc36561f (diff) | |
download | gnunet-f1f99ff0bcb5fc9865ab50765bfdba42bb9c38f9.tar.gz gnunet-f1f99ff0bcb5fc9865ab50765bfdba42bb9c38f9.zip |
-unschedule found block request on resume to fix #2133
Diffstat (limited to 'src/fs/fs_download.c')
-rw-r--r-- | src/fs/fs_download.c | 35 |
1 files changed, 30 insertions, 5 deletions
diff --git a/src/fs/fs_download.c b/src/fs/fs_download.c index f9e654928..4fd2b78a1 100644 --- a/src/fs/fs_download.c +++ b/src/fs/fs_download.c | |||
@@ -982,7 +982,6 @@ process_result_with_request (void *cls, const GNUNET_HashCode * key, | |||
982 | dr->is_pending = GNUNET_NO; | 982 | dr->is_pending = GNUNET_NO; |
983 | } | 983 | } |
984 | 984 | ||
985 | |||
986 | GNUNET_CRYPTO_hash_to_aes_key (&dr->chk.key, &skey, &iv); | 985 | GNUNET_CRYPTO_hash_to_aes_key (&dr->chk.key, &skey, &iv); |
987 | if (-1 == GNUNET_CRYPTO_aes_decrypt (prc->data, prc->size, &skey, &iv, pt)) | 986 | if (-1 == GNUNET_CRYPTO_aes_decrypt (prc->data, prc->size, &skey, &iv, pt)) |
988 | { | 987 | { |
@@ -1069,6 +1068,7 @@ process_result_with_request (void *cls, const GNUNET_HashCode * key, | |||
1069 | &trigger_recursive_download, dc); | 1068 | &trigger_recursive_download, dc); |
1070 | 1069 | ||
1071 | } | 1070 | } |
1071 | GNUNET_assert (dc->completed <= dc->length); | ||
1072 | dr->state = BRS_DOWNLOAD_DOWN; | 1072 | dr->state = BRS_DOWNLOAD_DOWN; |
1073 | pi.status = GNUNET_FS_STATUS_DOWNLOAD_PROGRESS; | 1073 | pi.status = GNUNET_FS_STATUS_DOWNLOAD_PROGRESS; |
1074 | pi.value.download.specifics.progress.data = pt; | 1074 | pi.value.download.specifics.progress.data = pt; |
@@ -1083,7 +1083,6 @@ process_result_with_request (void *cls, const GNUNET_HashCode * key, | |||
1083 | pi.value.download.specifics.progress.block_download_duration.rel_value = | 1083 | pi.value.download.specifics.progress.block_download_duration.rel_value = |
1084 | GNUNET_TIME_UNIT_FOREVER_REL.rel_value; | 1084 | GNUNET_TIME_UNIT_FOREVER_REL.rel_value; |
1085 | GNUNET_FS_download_make_status_ (&pi, dc); | 1085 | GNUNET_FS_download_make_status_ (&pi, dc); |
1086 | GNUNET_assert (dc->completed <= dc->length); | ||
1087 | if (dr->depth == 0) | 1086 | if (dr->depth == 0) |
1088 | propagate_up (dr); | 1087 | propagate_up (dr); |
1089 | 1088 | ||
@@ -1662,6 +1661,8 @@ reconstruct_cb (void *cls, const struct ContentHashKey *chk, uint64_t offset, | |||
1662 | GNUNET_assert (chld < dr->num_children); | 1661 | GNUNET_assert (chld < dr->num_children); |
1663 | dr = dr->children[chld]; | 1662 | dr = dr->children[chld]; |
1664 | } | 1663 | } |
1664 | /* FIXME: this code needs more testing and might | ||
1665 | need to handle more states... */ | ||
1665 | switch (dr->state) | 1666 | switch (dr->state) |
1666 | { | 1667 | { |
1667 | case BRS_INIT: | 1668 | case BRS_INIT: |
@@ -1678,6 +1679,13 @@ reconstruct_cb (void *cls, const struct ContentHashKey *chk, uint64_t offset, | |||
1678 | /* block matches, hence tree below matches; | 1679 | /* block matches, hence tree below matches; |
1679 | * this request is done! */ | 1680 | * this request is done! */ |
1680 | dr->state = BRS_DOWNLOAD_UP; | 1681 | dr->state = BRS_DOWNLOAD_UP; |
1682 | GNUNET_assert (GNUNET_YES == | ||
1683 | GNUNET_CONTAINER_multihashmap_remove (dc->active, &dr->chk.query, dr)); | ||
1684 | if (GNUNET_YES == dr->is_pending) | ||
1685 | { | ||
1686 | GNUNET_CONTAINER_DLL_remove (dc->pending_head, dc->pending_tail, dr); | ||
1687 | dr->is_pending = GNUNET_NO; | ||
1688 | } | ||
1681 | /* calculate how many bytes of payload this block | 1689 | /* calculate how many bytes of payload this block |
1682 | * corresponds to */ | 1690 | * corresponds to */ |
1683 | blen = GNUNET_FS_tree_compute_tree_size (dr->depth); | 1691 | blen = GNUNET_FS_tree_compute_tree_size (dr->depth); |
@@ -1692,9 +1700,26 @@ reconstruct_cb (void *cls, const struct ContentHashKey *chk, uint64_t offset, | |||
1692 | pi.value.download.specifics.progress.depth = 0; | 1700 | pi.value.download.specifics.progress.depth = 0; |
1693 | pi.value.download.specifics.progress.trust_offered = 0; | 1701 | pi.value.download.specifics.progress.trust_offered = 0; |
1694 | GNUNET_FS_download_make_status_ (&pi, dc); | 1702 | GNUNET_FS_download_make_status_ (&pi, dc); |
1695 | } | 1703 | /* FIXME: duplicated code from 'process_result_with_request - refactor */ |
1696 | else | 1704 | if (dc->completed == dc->length) |
1697 | { | 1705 | { |
1706 | /* download completed, signal */ | ||
1707 | #if DEBUG_DOWNLOAD | ||
1708 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1709 | "Download completed, truncating file to desired length %llu\n", | ||
1710 | (unsigned long long) GNUNET_ntohll (dc->uri->data. | ||
1711 | chk.file_length)); | ||
1712 | #endif | ||
1713 | /* truncate file to size (since we store IBlocks at the end) */ | ||
1714 | if (dc->filename != NULL) | ||
1715 | { | ||
1716 | if (0 != | ||
1717 | truncate (dc->filename, | ||
1718 | GNUNET_ntohll (dc->uri->data.chk.file_length))) | ||
1719 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "truncate", | ||
1720 | dc->filename); | ||
1721 | } | ||
1722 | } | ||
1698 | } | 1723 | } |
1699 | break; | 1724 | break; |
1700 | case BRS_DOWNLOAD_DOWN: | 1725 | case BRS_DOWNLOAD_DOWN: |