[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r19752 - gnunet/src/fs
From: |
gnunet |
Subject: |
[GNUnet-SVN] r19752 - gnunet/src/fs |
Date: |
Sun, 12 Feb 2012 00:26:54 +0100 |
Author: grothoff
Date: 2012-02-12 00:26:54 +0100 (Sun, 12 Feb 2012)
New Revision: 19752
Modified:
gnunet/src/fs/fs_download.c
Log:
-unschedule found block request on resume to fix #2133
Modified: gnunet/src/fs/fs_download.c
===================================================================
--- gnunet/src/fs/fs_download.c 2012-02-11 20:18:39 UTC (rev 19751)
+++ gnunet/src/fs/fs_download.c 2012-02-11 23:26:54 UTC (rev 19752)
@@ -982,7 +982,6 @@
dr->is_pending = GNUNET_NO;
}
-
GNUNET_CRYPTO_hash_to_aes_key (&dr->chk.key, &skey, &iv);
if (-1 == GNUNET_CRYPTO_aes_decrypt (prc->data, prc->size, &skey, &iv, pt))
{
@@ -1069,6 +1068,7 @@
&trigger_recursive_download, dc);
}
+ GNUNET_assert (dc->completed <= dc->length);
dr->state = BRS_DOWNLOAD_DOWN;
pi.status = GNUNET_FS_STATUS_DOWNLOAD_PROGRESS;
pi.value.download.specifics.progress.data = pt;
@@ -1083,7 +1083,6 @@
pi.value.download.specifics.progress.block_download_duration.rel_value =
GNUNET_TIME_UNIT_FOREVER_REL.rel_value;
GNUNET_FS_download_make_status_ (&pi, dc);
- GNUNET_assert (dc->completed <= dc->length);
if (dr->depth == 0)
propagate_up (dr);
@@ -1662,6 +1661,8 @@
GNUNET_assert (chld < dr->num_children);
dr = dr->children[chld];
}
+ /* FIXME: this code needs more testing and might
+ need to handle more states... */
switch (dr->state)
{
case BRS_INIT:
@@ -1678,6 +1679,13 @@
/* block matches, hence tree below matches;
* this request is done! */
dr->state = BRS_DOWNLOAD_UP;
+ GNUNET_assert (GNUNET_YES ==
+ GNUNET_CONTAINER_multihashmap_remove (dc->active,
&dr->chk.query, dr));
+ if (GNUNET_YES == dr->is_pending)
+ {
+ GNUNET_CONTAINER_DLL_remove (dc->pending_head, dc->pending_tail, dr);
+ dr->is_pending = GNUNET_NO;
+ }
/* calculate how many bytes of payload this block
* corresponds to */
blen = GNUNET_FS_tree_compute_tree_size (dr->depth);
@@ -1692,10 +1700,27 @@
pi.value.download.specifics.progress.depth = 0;
pi.value.download.specifics.progress.trust_offered = 0;
GNUNET_FS_download_make_status_ (&pi, dc);
+ /* FIXME: duplicated code from 'process_result_with_request - refactor */
+ if (dc->completed == dc->length)
+ {
+ /* download completed, signal */
+#if DEBUG_DOWNLOAD
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Download completed, truncating file to desired length
%llu\n",
+ (unsigned long long) GNUNET_ntohll (dc->uri->data.
+ chk.file_length));
+#endif
+ /* truncate file to size (since we store IBlocks at the end) */
+ if (dc->filename != NULL)
+ {
+ if (0 !=
+ truncate (dc->filename,
+ GNUNET_ntohll (dc->uri->data.chk.file_length)))
+ GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "truncate",
+ dc->filename);
+ }
+ }
}
- else
- {
- }
break;
case BRS_DOWNLOAD_DOWN:
break;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r19752 - gnunet/src/fs,
gnunet <=