[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r11221 - gnunet/src/fs
From: |
gnunet |
Subject: |
[GNUnet-SVN] r11221 - gnunet/src/fs |
Date: |
Thu, 6 May 2010 15:02:14 +0200 |
Author: grothoff
Date: 2010-05-06 15:02:14 +0200 (Thu, 06 May 2010)
New Revision: 11221
Modified:
gnunet/src/fs/fs.c
gnunet/src/fs/fs_download.c
gnunet/src/fs/fs_publish.c
gnunet/src/fs/test_fs_download_persistence.c
Log:
bugfixes
Modified: gnunet/src/fs/fs.c
===================================================================
--- gnunet/src/fs/fs.c 2010-05-06 12:30:54 UTC (rev 11220)
+++ gnunet/src/fs/fs.c 2010-05-06 13:02:14 UTC (rev 11221)
@@ -529,9 +529,7 @@
}
ret = GNUNET_BIO_write_open (fn);
if (ret == NULL)
- fprintf (stderr,
- "Failed to create write handle for `%s' from `%s/%s'\n",
- fn, ext, ent);
+ GNUNET_break (0);
GNUNET_free (fn);
return ret;
}
@@ -1671,11 +1669,13 @@
*
* @param dc download context to compute for
* @param uni unique filename to use, use "" for the directory name
+ * @param ext extension to use, use ".dir" for our own subdirectory
* @return the expanded file name, NULL for none
*/
static char *
get_download_sync_filename (struct GNUNET_FS_DownloadContext *dc,
- const char *uni)
+ const char *uni,
+ const char *ext)
{
char *par;
char *epar;
@@ -1688,14 +1688,15 @@
uni);
if (dc->parent->serialization == NULL)
return NULL;
- par = get_download_sync_filename (dc->parent, dc->parent->serialization);
+ par = get_download_sync_filename (dc->parent, dc->parent->serialization, "");
if (par == NULL)
return NULL;
GNUNET_asprintf (&epar,
- "%s.dir%s%s",
+ "%s.dir%s%s%s",
par,
DIR_SEPARATOR_STR,
- uni);
+ uni,
+ ext);
GNUNET_free (par);
return epar;
}
@@ -1720,7 +1721,7 @@
if (NULL == dc->serialization)
{
- dir = get_download_sync_filename (dc, "");
+ dir = get_download_sync_filename (dc, "", "");
if (dir == NULL)
return;
if (GNUNET_OK !=
@@ -1735,7 +1736,7 @@
}
else
{
- fn = get_download_sync_filename (dc, dc->serialization);
+ fn = get_download_sync_filename (dc, dc->serialization, "");
}
wh = GNUNET_BIO_write_open (fn);
if (wh == NULL)
@@ -2440,6 +2441,15 @@
ser = get_serialization_short_name (filename);
rh = GNUNET_BIO_read_open (filename);
+ if (rh == NULL)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ _("Failed to resume sub-download `%s': could not open file
`%s'\n"),
+ ser,
+ filename);
+ GNUNET_free (ser);
+ return GNUNET_OK;
+ }
deserialize_download (parent->h,
rh,
parent,
@@ -2591,9 +2601,14 @@
dr->is_pending = GNUNET_YES;
dr->next = dc->pending;
dc->pending = dr;
+ GNUNET_CONTAINER_multihashmap_put (dc->active,
+ &dr->chk.query,
+ dr,
+
GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
+
dr = NULL;
}
- dn = get_download_sync_filename (dc, "");
+ dn = get_download_sync_filename (dc, dc->serialization, ".dir");
if (dn != NULL)
{
if (GNUNET_YES ==
@@ -2602,20 +2617,25 @@
GNUNET_free (dn);
}
if (parent != NULL)
- GNUNET_CONTAINER_DLL_insert (parent->child_head,
- parent->child_tail,
- dc);
+ {
+ abort (); // for debugging for now
+ GNUNET_CONTAINER_DLL_insert (parent->child_head,
+ parent->child_tail,
+ dc);
+ }
if (search != NULL)
{
dc->search = search;
search->download = dc;
}
- if ( (parent == NULL) ||
+ if ( (parent == NULL) &&
(search == NULL) )
- dc->top = GNUNET_FS_make_top (dc->h,
- &GNUNET_FS_download_signal_suspend_,
- dc);
- signal_download_resume (dc);
+ {
+ dc->top = GNUNET_FS_make_top (dc->h,
+ &GNUNET_FS_download_signal_suspend_,
+ dc);
+ signal_download_resume (dc);
+ }
GNUNET_free (uris);
return;
cleanup:
Modified: gnunet/src/fs/fs_download.c
===================================================================
--- gnunet/src/fs/fs_download.c 2010-05-06 12:30:54 UTC (rev 11220)
+++ gnunet/src/fs/fs_download.c 2010-05-06 13:02:14 UTC (rev 11221)
@@ -1359,6 +1359,8 @@
struct GNUNET_FS_ProgressInfo pi;
GNUNET_assert (NULL != client);
+ GNUNET_assert (dc->client == NULL);
+ GNUNET_assert (dc->th == NULL);
dc->client = client;
GNUNET_CLIENT_receive (client,
&receive_results,
@@ -1369,14 +1371,12 @@
GNUNET_CONTAINER_multihashmap_iterate (dc->active,
&retry_entry,
dc);
- if ( (dc->th == NULL) &&
- (dc->client != NULL) )
- dc->th = GNUNET_CLIENT_notify_transmit_ready (dc->client,
- sizeof (struct SearchMessage),
-
GNUNET_CONSTANTS_SERVICE_TIMEOUT,
- GNUNET_NO,
- &transmit_download_request,
- dc);
+ dc->th = GNUNET_CLIENT_notify_transmit_ready (dc->client,
+ sizeof (struct SearchMessage),
+
GNUNET_CONSTANTS_SERVICE_TIMEOUT,
+ GNUNET_NO,
+ &transmit_download_request,
+ dc);
}
@@ -1559,9 +1559,11 @@
dc->treedepth);
#endif
if (parent == NULL)
- dc->top = GNUNET_FS_make_top (dc->h,
- &GNUNET_FS_download_signal_suspend_,
- dc);
+ {
+ dc->top = GNUNET_FS_make_top (dc->h,
+ &GNUNET_FS_download_signal_suspend_,
+ dc);
+ }
pi.status = GNUNET_FS_STATUS_DOWNLOAD_START;
pi.value.download.specifics.start.meta = meta;
GNUNET_FS_download_make_status_ (&pi, dc);
@@ -1707,6 +1709,7 @@
void
GNUNET_FS_download_start_downloading_ (struct GNUNET_FS_DownloadContext *dc)
{
+ GNUNET_assert (dc->job_queue == NULL);
dc->job_queue = GNUNET_FS_queue_ (dc->h,
&activate_fs_download,
&deactivate_fs_download,
Modified: gnunet/src/fs/fs_publish.c
===================================================================
--- gnunet/src/fs/fs_publish.c 2010-05-06 12:30:54 UTC (rev 11220)
+++ gnunet/src/fs/fs_publish.c 2010-05-06 13:02:14 UTC (rev 11221)
@@ -1115,12 +1115,9 @@
if (fi->serialization != NULL)
{
- if (0 != UNLINK (fi->serialization))
- {
- GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR,
- "unlink",
- fi->serialization);
- }
+ GNUNET_FS_remove_sync_file_ (sc->h,
+ GNUNET_FS_SYNC_PATH_FILE_INFO,
+ fi->serialization);
GNUNET_free (fi->serialization);
fi->serialization = NULL;
}
Modified: gnunet/src/fs/test_fs_download_persistence.c
===================================================================
--- gnunet/src/fs/test_fs_download_persistence.c 2010-05-06 12:30:54 UTC
(rev 11220)
+++ gnunet/src/fs/test_fs_download_persistence.c 2010-05-06 13:02:14 UTC
(rev 11221)
@@ -175,7 +175,6 @@
progress_cb (void *cls,
const struct GNUNET_FS_ProgressInfo *event)
{
-
switch (event->status)
{
case GNUNET_FS_STATUS_PUBLISH_PROGRESS:
@@ -192,17 +191,17 @@
(unsigned long long) (FILESIZE * 1000LL /
(1+GNUNET_TIME_absolute_get_duration (start).value) / 1024LL));
fn = GNUNET_DISK_mktemp ("gnunet-download-test-dst");
start = GNUNET_TIME_absolute_get ();
- download = GNUNET_FS_download_start (fs,
-
event->value.publish.specifics.completed.chk_uri,
- NULL,
- fn, NULL,
- 0,
- FILESIZE,
- 1,
- GNUNET_FS_DOWNLOAD_OPTION_NONE,
- "download",
- NULL);
- GNUNET_assert (download != NULL);
+ GNUNET_assert (download == NULL);
+ GNUNET_FS_download_start (fs,
+
event->value.publish.specifics.completed.chk_uri,
+ NULL,
+ fn, NULL,
+ 0,
+ FILESIZE,
+ 1,
+ GNUNET_FS_DOWNLOAD_OPTION_NONE,
+ "download",
+ NULL);
break;
case GNUNET_FS_STATUS_DOWNLOAD_COMPLETED:
consider_restart (event->status);
@@ -241,6 +240,22 @@
&abort_download_task,
NULL);
break;
+ case GNUNET_FS_STATUS_PUBLISH_SUSPEND:
+ GNUNET_assert (event->value.publish.sc == publish);
+ publish = NULL;
+ break;
+ case GNUNET_FS_STATUS_PUBLISH_RESUME:
+ GNUNET_assert (NULL == publish);
+ publish = event->value.publish.sc;
+ break;
+ case GNUNET_FS_STATUS_DOWNLOAD_SUSPEND:
+ GNUNET_assert (event->value.download.dc == download);
+ download = NULL;
+ break;
+ case GNUNET_FS_STATUS_DOWNLOAD_RESUME:
+ GNUNET_assert (NULL == download);
+ download = event->value.download.dc;
+ break;
case GNUNET_FS_STATUS_DOWNLOAD_ACTIVE:
consider_restart (event->status);
break;
@@ -264,6 +279,7 @@
case GNUNET_FS_STATUS_DOWNLOAD_START:
consider_restart (event->status);
GNUNET_assert (download == NULL);
+ download = event->value.download.dc;
GNUNET_assert (0 == strcmp ("download", event->value.download.cctx));
GNUNET_assert (NULL == event->value.download.pctx);
GNUNET_assert (NULL != event->value.download.uri);
@@ -273,12 +289,12 @@
GNUNET_assert (1 == event->value.download.anonymity);
break;
case GNUNET_FS_STATUS_DOWNLOAD_STOPPED:
- consider_restart (event->status);
GNUNET_assert (download == event->value.download.dc);
GNUNET_SCHEDULER_add_continuation (sched,
&abort_publish_task,
NULL,
GNUNET_SCHEDULER_REASON_PREREQ_DONE);
+ download = NULL;
break;
default:
printf ("Unexpected event: %d\n",
@@ -394,7 +410,6 @@
struct GNUNET_GETOPT_CommandLineOption options[] = {
GNUNET_GETOPT_OPTION_END
};
-
GNUNET_log_setup ("test_fs_download_persistence",
#if VERBOSE
"DEBUG",
@@ -402,6 +417,7 @@
"WARNING",
#endif
NULL);
+ GNUNET_DISK_directory_remove ("/tmp/gnunet-test-fs-download/");
GNUNET_PROGRAM_run ((sizeof (argvx) / sizeof (char *)) - 1,
argvx, "test-fs-download-persistence",
"nohelp", options, &run, NULL);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r11221 - gnunet/src/fs,
gnunet <=