[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r32426 - gnunet/src/fs
From: |
gnunet |
Subject: |
[GNUnet-SVN] r32426 - gnunet/src/fs |
Date: |
Wed, 19 Feb 2014 14:52:25 +0100 |
Author: grothoff
Date: 2014-02-19 14:52:24 +0100 (Wed, 19 Feb 2014)
New Revision: 32426
Modified:
gnunet/src/fs/fs_api.c
gnunet/src/fs/fs_download.c
gnunet/src/fs/fs_search.c
Log:
handle case where partial download prevents proper bottom-up reconstruction as
not all child-nodes are even attempted; handle case where probe returns results
immediately while being created (do not break on that)
Modified: gnunet/src/fs/fs_api.c
===================================================================
--- gnunet/src/fs/fs_api.c 2014-02-19 13:51:25 UTC (rev 32425)
+++ gnunet/src/fs/fs_api.c 2014-02-19 13:52:24 UTC (rev 32426)
@@ -687,7 +687,8 @@
* @param ent entity identifier
*/
void
-GNUNET_FS_remove_sync_file_ (struct GNUNET_FS_Handle *h, const char *ext,
+GNUNET_FS_remove_sync_file_ (struct GNUNET_FS_Handle *h,
+ const char *ext,
const char *ent)
{
char *filename;
@@ -700,7 +701,8 @@
filename = get_serialization_file_name (h, ext, ent);
if (NULL != filename)
{
- if (0 != UNLINK (filename))
+ if ( (0 != UNLINK (filename)) &&
+ (ENOENT != errno) )
GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "unlink", filename);
GNUNET_free (filename);
}
Modified: gnunet/src/fs/fs_download.c
===================================================================
--- gnunet/src/fs/fs_download.c 2014-02-19 13:51:25 UTC (rev 32425)
+++ gnunet/src/fs/fs_download.c 2014-02-19 13:52:24 UTC (rev 32426)
@@ -450,6 +450,18 @@
return;
if (dr->depth > 0)
{
+ if ( (dc->offset > 0) ||
+ (dc->length < GNUNET_ntohll (dc->uri->data.chk.file_length)) )
+ {
+ /* NOTE: this test is not tight, but should suffice; the issue
+ here is that 'dr->num_children' may inherently only specify a
+ smaller range than what is in the original file;
+ thus, reconstruction of (some) inner blocks will fail.
+ FIXME: we might eventually want to write a tighter test to
+ maximize the circumstances under which we do succeed with
+ IBlock reconstruction. (need good tests though). */
+ return;
+ }
complete = GNUNET_YES;
for (i = 0; i < dr->num_children; i++)
{
@@ -494,39 +506,43 @@
}
/* write block to disk */
fn = (NULL != dc->filename) ? dc->filename : dc->temp_filename;
- fh = GNUNET_DISK_file_open (fn,
- GNUNET_DISK_OPEN_READWRITE |
- GNUNET_DISK_OPEN_CREATE |
- GNUNET_DISK_OPEN_TRUNCATE,
- GNUNET_DISK_PERM_USER_READ |
- GNUNET_DISK_PERM_USER_WRITE |
- GNUNET_DISK_PERM_GROUP_READ |
- GNUNET_DISK_PERM_OTHER_READ);
- if (NULL == fh)
+ if (NULL != fn)
{
- GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "open", fn);
- GNUNET_asprintf (&dc->emsg, _("Failed to open file `%s' for writing"),
- fn);
+ fh = GNUNET_DISK_file_open (fn,
+ GNUNET_DISK_OPEN_READWRITE |
+ GNUNET_DISK_OPEN_CREATE |
+ GNUNET_DISK_OPEN_TRUNCATE,
+ GNUNET_DISK_PERM_USER_READ |
+ GNUNET_DISK_PERM_USER_WRITE |
+ GNUNET_DISK_PERM_GROUP_READ |
+ GNUNET_DISK_PERM_OTHER_READ);
+ if (NULL == fh)
+ {
+ GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "open", fn);
+ GNUNET_asprintf (&dc->emsg,
+ _("Failed to open file `%s' for writing"),
+ fn);
+ GNUNET_DISK_file_close (fh);
+ dr->state = BRS_ERROR;
+ pi.status = GNUNET_FS_STATUS_DOWNLOAD_ERROR;
+ pi.value.download.specifics.error.message = dc->emsg;
+ GNUNET_FS_download_make_status_ (&pi, dc);
+ return;
+ }
+ if (data_len != GNUNET_DISK_file_write (fh, odata, odata_len))
+ {
+ GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "write", fn);
+ GNUNET_asprintf (&dc->emsg, _("Failed to open file `%s' for writing"),
+ fn);
+ GNUNET_DISK_file_close (fh);
+ dr->state = BRS_ERROR;
+ pi.status = GNUNET_FS_STATUS_DOWNLOAD_ERROR;
+ pi.value.download.specifics.error.message = dc->emsg;
+ GNUNET_FS_download_make_status_ (&pi, dc);
+ return;
+ }
GNUNET_DISK_file_close (fh);
- dr->state = BRS_ERROR;
- pi.status = GNUNET_FS_STATUS_DOWNLOAD_ERROR;
- pi.value.download.specifics.error.message = dc->emsg;
- GNUNET_FS_download_make_status_ (&pi, dc);
- return;
}
- if (data_len != GNUNET_DISK_file_write (fh, odata, odata_len))
- {
- GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "write", fn);
- GNUNET_asprintf (&dc->emsg, _("Failed to open file `%s' for writing"),
- fn);
- GNUNET_DISK_file_close (fh);
- dr->state = BRS_ERROR;
- pi.status = GNUNET_FS_STATUS_DOWNLOAD_ERROR;
- pi.value.download.specifics.error.message = dc->emsg;
- GNUNET_FS_download_make_status_ (&pi, dc);
- return;
- }
- GNUNET_DISK_file_close (fh);
/* signal success */
dr->state = BRS_DOWNLOAD_UP;
dc->completed = dc->length;
Modified: gnunet/src/fs/fs_search.c
===================================================================
--- gnunet/src/fs/fs_search.c 2014-02-19 13:51:25 UTC (rev 32425)
+++ gnunet/src/fs/fs_search.c 2014-02-19 13:52:24 UTC (rev 32426)
@@ -341,12 +341,6 @@
GNUNET_SCHEDULER_add_delayed (sr->remaining_probe_time,
&probe_failure_handler, sr);
}
- else
- {
- /* should only happen if the cancel task was already
- created on 'DOWNLOAD_INACTIVE' as we were out of time */
- GNUNET_break (0 == sr->remaining_probe_time.rel_value_us);
- }
break;
case GNUNET_FS_STATUS_DOWNLOAD_INACTIVE:
if (GNUNET_SCHEDULER_NO_TASK != sr->probe_cancel_task)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r32426 - gnunet/src/fs,
gnunet <=