[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r2259 - in GNUnet/src/applications/fs: ecrs fsui tools
From: |
grothoff |
Subject: |
[GNUnet-SVN] r2259 - in GNUnet/src/applications/fs: ecrs fsui tools |
Date: |
Fri, 18 Nov 2005 16:14:27 -0800 (PST) |
Author: grothoff
Date: 2005-11-18 16:14:23 -0800 (Fri, 18 Nov 2005)
New Revision: 2259
Modified:
GNUnet/src/applications/fs/ecrs/download.c
GNUnet/src/applications/fs/fsui/download.c
GNUnet/src/applications/fs/fsui/fsui.h
GNUnet/src/applications/fs/tools/gnunet-download.c
Log:
fixing bugs discovered investigating 974, and some clean up
Modified: GNUnet/src/applications/fs/ecrs/download.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/download.c 2005-11-18 22:11:01 UTC (rev
2258)
+++ GNUnet/src/applications/fs/ecrs/download.c 2005-11-19 00:14:23 UTC (rev
2259)
@@ -31,7 +31,7 @@
#include "ecrs.h"
#include "tree.h"
-#define DEBUG_DOWNLOAD NO
+#define DEBUG_DOWNLOAD YES
/**
* Highest TTL allowed? (equivalent of 25-50 HOPS distance!)
Modified: GNUnet/src/applications/fs/fsui/download.c
===================================================================
--- GNUnet/src/applications/fs/fsui/download.c 2005-11-18 22:11:01 UTC (rev
2258)
+++ GNUnet/src/applications/fs/fsui/download.c 2005-11-19 00:14:23 UTC (rev
2259)
@@ -30,7 +30,7 @@
#include "gnunet_fsui_lib.h"
#include "fsui.h"
-#define DEBUG_DTM NO
+#define DEBUG_DTM YES
/**
* Start to download a file.
@@ -88,6 +88,11 @@
strcat(fullName, DIR_SEPARATOR_STR);
strcat(fullName, filename);
FREE(filename);
+#if DEBUG_DTM
+ LOG(LOG_DEBUG,
+ "Starting recursive download of `%s'\n",
+ fullName);
+#endif
startDownload(parent->ctx,
parent->anonymityLevel,
fi->uri,
@@ -108,7 +113,8 @@
unsigned long long lastBlockOffset,
const char * lastBlock,
unsigned int lastBlockSize,
- FSUI_DownloadList * dl) {
+ void * cls) {
+ FSUI_DownloadList * dl = cls;
FSUI_Event event;
struct ECRS_MetaData * md;
FSUI_DownloadList * root;
@@ -118,10 +124,10 @@
(root->parent != &dl->ctx->activeDownloads) )
root = root->parent;
- dl->completed = completedBytes;
+ dl->completedFile = completedBytes;
event.type = FSUI_download_progress;
event.data.DownloadProgress.total = totalBytes;
- event.data.DownloadProgress.completed = completedBytes;
+ event.data.DownloadProgress.completed = dl->completed + completedBytes;
event.data.DownloadProgress.last_offset = lastBlockOffset;
event.data.DownloadProgress.eta = eta;
event.data.DownloadProgress.last_block = lastBlock;
@@ -165,7 +171,8 @@
* Check if termination of this download is desired.
*/
static int
-testTerminate(FSUI_DownloadList * dl) {
+testTerminate(void * cls) {
+ FSUI_DownloadList * dl = cls;
if (dl->signalTerminate == YES)
return SYSERR;
else
@@ -175,7 +182,8 @@
/**
* Thread that downloads a file.
*/
-void * downloadThread(FSUI_DownloadList * dl) {
+void * downloadThread(void * cls) {
+ FSUI_DownloadList * dl = cls;
int ret;
FSUI_Event event;
struct ECRS_MetaData * md;
@@ -187,21 +195,21 @@
ret = ECRS_downloadFile(dl->uri,
dl->filename,
dl->anonymityLevel,
-
(ECRS_DownloadProgressCallback)&downloadProgressCallback,
+ &downloadProgressCallback,
dl,
- (ECRS_TestTerminate) &testTerminate,
+ &testTerminate,
dl);
if (ret == OK)
dl->finished = YES;
totalBytes = ECRS_fileSize(dl->uri);
root = dl;
- while ( (root->parent != NULL) &&
- (root->parent != &dl->ctx->activeDownloads) ) {
+ while (root->parent != &dl->ctx->activeDownloads) {
+ root->completed += totalBytes;
root = root->parent;
- root->completed += totalBytes;
}
+ root->completed += totalBytes;
+
-
if ( (ret == OK) &&
(dl->is_recursive) &&
(dl->is_directory) ) {
@@ -254,6 +262,7 @@
dl->signalTerminate = YES;
} else {
dl->signalTerminate = YES;
+ GNUNET_ASSERT(dl != &dl->ctx->activeDownloads);
while ( (dl != NULL) &&
(dl->ctx != NULL) &&
(dl != &dl->ctx->activeDownloads) ) {
@@ -375,8 +384,10 @@
#if DEBUG_DTM
LOG(LOG_DEBUG,
- "Download thread manager investigates pending downlod of file `%s'\n",
- list->filename);
+ "Download thread manager investigates pending downlod of file `%s'
(%u/%u downloads)\n",
+ list->filename,
+ list->ctx->activeDownloadThreads,
+ list->ctx->threadPoolSize);
#endif
ret = NO;
/* should this one be started? */
@@ -392,7 +403,7 @@
#endif
list->signalTerminate = NO;
if (0 == PTHREAD_CREATE(&list->handle,
- (PThreadMain)&downloadThread,
+ &downloadThread,
list,
32 * 1024)) {
list->ctx->activeDownloadThreads++;
@@ -407,8 +418,10 @@
(list->signalTerminate == NO) ) {
#if DEBUG_DTM
LOG(LOG_DEBUG,
- "Download thread manager aborts active downlod of file `%s'\n",
- list->filename);
+ "Download thread manager aborts active downlod of file `%s' (%u/%u
downloads)\n",
+ list->filename,
+ list->ctx->activeDownloadThreads,
+ list->ctx->threadPoolSize);
#endif
list->signalTerminate = YES;
PTHREAD_JOIN(&list->handle,
Modified: GNUnet/src/applications/fs/fsui/fsui.h
===================================================================
--- GNUnet/src/applications/fs/fsui/fsui.h 2005-11-18 22:11:01 UTC (rev
2258)
+++ GNUnet/src/applications/fs/fsui/fsui.h 2005-11-19 00:14:23 UTC (rev
2259)
@@ -200,6 +200,11 @@
unsigned long long completed;
/**
+ * How many bytes have been retrieved so far for this particular file only.
+ */
+ unsigned long long completedFile;
+
+ /**
* URI for this download.
*/
struct ECRS_URI * uri;
@@ -349,7 +354,7 @@
/**
* Thread that downloads a file.
*/
-void * downloadThread(FSUI_DownloadList * dl);
+void * downloadThread(void * dl);
/* from search.c */
/**
Modified: GNUnet/src/applications/fs/tools/gnunet-download.c
===================================================================
--- GNUnet/src/applications/fs/tools/gnunet-download.c 2005-11-18 22:11:01 UTC
(rev 2258)
+++ GNUnet/src/applications/fs/tools/gnunet-download.c 2005-11-19 00:14:23 UTC
(rev 2259)
@@ -169,7 +169,7 @@
case FSUI_download_aborted:
if (FSUI_getDownloadParent(event->data.DownloadError.pos) == NULL) {
/* top-download aborted */
- printf(_("Error downloading: %s\n"),
+ PRINTF(_("Error downloading: %s\n"),
event->data.DownloadError.message);
*ok = SYSERR;
SEMAPHORE_UP(signalFinished);
@@ -188,7 +188,7 @@
case FSUI_download_complete:
if ( (event->data.DownloadProgress.completed ==
event->data.DownloadProgress.total) ) {
- printf(_("Download of file `%s' complete. "
+ PRINTF(_("Download of file `%s' complete. "
"Speed was %8.3f kilobyte per second.\n"),
event->data.DownloadProgress.filename,
(event->data.DownloadProgress.completed/1024.0) /
@@ -199,12 +199,6 @@
*ok = OK;
SEMAPHORE_UP(signalFinished);
}
- } else {
- PRINTF(_("Recursive download of directory `%s' at "
- "%llu of %llu bytes.\n"),
- event->data.DownloadProgress.filename,
- event->data.DownloadProgress.completed,
- event->data.DownloadProgress.total);
}
break;
default:
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r2259 - in GNUnet/src/applications/fs: ecrs fsui tools,
grothoff <=