[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r3426 - in GNUnet/src: applications/fs/ecrs applications/fs
From: |
grothoff |
Subject: |
[GNUnet-SVN] r3426 - in GNUnet/src: applications/fs/ecrs applications/fs/fsui util/threads |
Date: |
Sat, 30 Sep 2006 20:30:42 -0700 (PDT) |
Author: grothoff
Date: 2006-09-30 20:30:37 -0700 (Sat, 30 Sep 2006)
New Revision: 3426
Modified:
GNUnet/src/applications/fs/ecrs/unindex.c
GNUnet/src/applications/fs/fsui/download.c
GNUnet/src/applications/fs/fsui/searchtest.c
GNUnet/src/applications/fs/fsui/unindex.c
GNUnet/src/applications/fs/fsui/upload.c
GNUnet/src/util/threads/pthread.c
Log:
fixes
Modified: GNUnet/src/applications/fs/ecrs/unindex.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/unindex.c 2006-10-01 01:43:35 UTC (rev
3425)
+++ GNUnet/src/applications/fs/ecrs/unindex.c 2006-10-01 03:30:37 UTC (rev
3426)
@@ -202,7 +202,8 @@
int wasIndexed;
start = get_time();
- if (YES != disk_file_test(ectx, filename)) {
+ if (YES != disk_file_test(ectx,
+ filename)) {
GE_BREAK(ectx, 0);
return SYSERR;
}
Modified: GNUnet/src/applications/fs/fsui/download.c
===================================================================
--- GNUnet/src/applications/fs/fsui/download.c 2006-10-01 01:43:35 UTC (rev
3425)
+++ GNUnet/src/applications/fs/fsui/download.c 2006-10-01 03:30:37 UTC (rev
3426)
@@ -34,7 +34,7 @@
#include "gnunet_fsui_lib.h"
#include "fsui.h"
-#define DEBUG_DTM YES
+#define DEBUG_DTM NO
/**
* Start to download a file.
Modified: GNUnet/src/applications/fs/fsui/searchtest.c
===================================================================
--- GNUnet/src/applications/fs/fsui/searchtest.c 2006-10-01 01:43:35 UTC
(rev 3425)
+++ GNUnet/src/applications/fs/fsui/searchtest.c 2006-10-01 03:30:37 UTC
(rev 3426)
@@ -32,36 +32,31 @@
#define CHECK(a) if (!(a)) { ok = NO; GE_BREAK(NULL, 0); goto FAILURE; }
-static struct FSUI_SearchList * search;
-
-
static char * makeName(unsigned int i) {
- char * name;
+ const char * name;
char * fn;
- fn = STRDUP("/tmp/gnunet-fsuisearchtest");
- name = string_expandFileName(NULL, fn);
+ name = "/tmp/gnunet-fsuisearchtest";
disk_directory_create(NULL, name);
- FREE(fn);
fn = MALLOC(strlen(name) + 40);
SNPRINTF(fn,
strlen(name) + 40,
"%s%sFSUITEST%u",
+ name,
DIR_SEPARATOR_STR,
- name,
i);
- FREE(name);
return fn;
}
static volatile enum FSUI_EventType lastEvent;
+static struct ECRS_URI * uri;
+
static struct FSUI_Context * ctx;
static void * eventCallback(void * cls,
const FSUI_Event * event) {
static char unused;
- char * fn;
switch(event->type) {
case FSUI_search_resuming:
@@ -71,15 +66,7 @@
return &unused;
case FSUI_search_result:
printf("Received search result\n");
- FSUI_stopSearch(ctx,
- search);
- fn = makeName(43);
- FSUI_startDownload(ctx,
- 0,
- NO,
- event->data.SearchResult.fi.uri,
- fn);
- FREE(fn);
+ uri = ECRS_dupUri(event->data.SearchResult.fi.uri);
break;
case FSUI_upload_complete:
printf("Upload complete.\n");
@@ -90,6 +77,15 @@
case FSUI_unindex_complete:
printf("Unindex complete.\n");
break;
+ case FSUI_upload_error:
+ printf("Upload error.\n");
+ break;
+ case FSUI_download_error:
+ printf("Download error.\n");
+ break;
+ case FSUI_unindex_error:
+ printf("Unindex error.\n");
+ break;
default:
break;
}
@@ -101,7 +97,6 @@
int main(int argc, char * argv[]){
pid_t daemon;
int ok;
- struct ECRS_URI * uri = NULL;
char * fn = NULL;
char * keywords[] = {
"search_foo",
@@ -115,7 +110,11 @@
struct GC_Configuration * cfg;
struct FSUI_UploadList * upload;
struct FSUI_UnindexList * unindex;
+ struct FSUI_DownloadList * download;
+ struct FSUI_SearchList * search;
+ struct ECRS_URI * luri;
+ ok = YES;
cfg = GC_create_C_impl();
if (-1 == GC_parse_configuration(cfg,
"check.conf")) {
@@ -147,10 +146,12 @@
keywords[0],
_("AND"),
keywords[1]);
- uri = ECRS_parseCharKeywordURI(NULL, keyword);
+ luri = ECRS_parseCharKeywordURI(NULL, keyword);
search = FSUI_startSearch(ctx,
0,
- uri);
+ luri);
+ ECRS_freeUri(luri);
+ uri = NULL;
CHECK(NULL != search);
FSUI_stop(ctx);
/* resume search! */
@@ -183,6 +184,8 @@
kuri,
kuri);
CHECK(NULL != upload);
+ FREE(fn);
+ fn = NULL;
ECRS_freeUri(kuri);
ECRS_freeMetaData(meta);
prog = 0;
@@ -190,39 +193,65 @@
prog++;
CHECK(prog < 10000)
PTHREAD_SLEEP(50 * cronMILLIS);
+ if (GNUNET_SHUTDOWN_TEST() == YES)
+ break;
}
FSUI_stopUpload(ctx, upload);
+ while (uri == NULL) {
+ prog++;
+ CHECK(prog < 10000)
+ PTHREAD_SLEEP(500 * cronMILLIS);
+ }
+ FSUI_stopSearch(ctx,
+ search);
+ CHECK(uri != NULL);
+ fn = makeName(43);
+ download = FSUI_startDownload(ctx,
+ 0,
+ NO,
+ uri,
+ fn);
+ FREE(fn);
+ fn = NULL;
+ ECRS_freeUri(uri);
+
prog = 0;
while (lastEvent != FSUI_download_complete) {
prog++;
CHECK(prog < 10000);
PTHREAD_SLEEP(50 * cronMILLIS);
+ if (GNUNET_SHUTDOWN_TEST() == YES)
+ break;
}
+ FSUI_stopDownload(ctx, download);
+ fn = makeName(42);
unindex = FSUI_unindex(ctx, fn);
+ FREE(fn);
+ fn = NULL;
CHECK(NULL != unindex);
prog = 0;
while (lastEvent != FSUI_unindex_complete) {
prog++;
CHECK(prog < 10000);
PTHREAD_SLEEP(50 * cronMILLIS);
+ if (GNUNET_SHUTDOWN_TEST() == YES)
+ break;
}
FSUI_stopUnindex(ctx, unindex);
/* END OF TEST CODE */
FAILURE:
- if (uri != NULL)
- ECRS_freeUri(uri);
if (ctx != NULL)
FSUI_stop(ctx);
- if (fn != NULL) {
- UNLINK(fn);
- FREE(fn);
- }
- fn = makeName(43);
+ FREENONNULL(fn);
/* TODO: verify file 'fn(42)' == file 'fn(43)' */
+ fn = makeName(42);
UNLINK(fn);
FREE(fn);
+ fn = makeName(43);
+ UNLINK(fn);
+ FREE(fn);
GE_ASSERT(NULL, OK == os_daemon_stop(NULL, daemon));
Modified: GNUnet/src/applications/fs/fsui/unindex.c
===================================================================
--- GNUnet/src/applications/fs/fsui/unindex.c 2006-10-01 01:43:35 UTC (rev
3425)
+++ GNUnet/src/applications/fs/fsui/unindex.c 2006-10-01 03:30:37 UTC (rev
3426)
@@ -114,6 +114,11 @@
GE_BREAK(ctx->ectx, 0);
return NULL;
}
+ if (YES != disk_file_test(ctx->ectx,
+ filename)) {
+ GE_BREAK(ctx->ectx, 0);
+ return NULL;
+ }
utc = MALLOC(sizeof(FSUI_UnindexList));
utc->ctx = ctx;
utc->filename = STRDUP(filename);
Modified: GNUnet/src/applications/fs/fsui/upload.c
===================================================================
--- GNUnet/src/applications/fs/fsui/upload.c 2006-10-01 01:43:35 UTC (rev
3425)
+++ GNUnet/src/applications/fs/fsui/upload.c 2006-10-01 03:30:37 UTC (rev
3426)
@@ -317,6 +317,13 @@
return OK;
}
+static int tt(void * cls) {
+ FSUI_UploadList * utc = cls;
+ if (utc->force_termination == YES)
+ return SYSERR;
+ return OK;
+}
+
/**
* Thread that does the upload.
*/
@@ -359,10 +366,10 @@
utc->anonymityLevel,
utc->priority,
utc->expiration,
- (ECRS_UploadProgressCallback) &progressCallback,
+ &progressCallback,
utc,
- NULL,
- NULL,
+ &tt,
+ utc,
&uri);
if (ret == OK) {
event.type = FSUI_upload_complete;
@@ -578,10 +585,9 @@
void * unused;
FSUI_UploadList * prev;
struct GE_Context * ectx;
- void * unused;
ectx = ctx->ectx;
- if (dl == NULL) {
+ if (ul == NULL) {
GE_BREAK(ectx, 0);
return SYSERR;
}
@@ -589,7 +595,7 @@
GE_DEBUG | GE_REQUEST | GE_USER,
"FSUI_stopUpload called.\n");
MUTEX_LOCK(ctx->lock);
- prev = ctx->uploadOperations;
+ prev = ctx->activeUploads;
while ( (prev != ul) &&
(prev != NULL) &&
(prev->next != ul) )
@@ -602,7 +608,7 @@
return SYSERR;
}
if (prev == ul) {
- ctx->uploadOperations = ul->next;
+ ctx->activeUploads = ul->next;
} else {
prev->next = ul->next;
}
Modified: GNUnet/src/util/threads/pthread.c
===================================================================
--- GNUnet/src/util/threads/pthread.c 2006-10-01 01:43:35 UTC (rev 3425)
+++ GNUnet/src/util/threads/pthread.c 2006-10-01 03:30:37 UTC (rev 3426)
@@ -228,7 +228,8 @@
void PTHREAD_STOP_SLEEP(PThread * handle) {
int ret;
- GE_ASSERT(NULL, handle != NULL);
+ if (handle == NULL)
+ return;
#ifdef WINDOWS
ret = QueueUserAPC((PAPCFUNC) __PTHREAD_SIGNALED,
pthread_getw32threadhandle_np(handle->pt),
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r3426 - in GNUnet/src: applications/fs/ecrs applications/fs/fsui util/threads,
grothoff <=