[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r7141 - in GNUnet/src: applications/fs/ecrs applications/fs
From: |
gnunet |
Subject: |
[GNUnet-SVN] r7141 - in GNUnet/src: applications/fs/ecrs applications/fs/fsui include |
Date: |
Wed, 11 Jun 2008 22:30:55 -0600 (MDT) |
Author: grothoff
Date: 2008-06-11 22:30:55 -0600 (Wed, 11 Jun 2008)
New Revision: 7141
Modified:
GNUnet/src/applications/fs/ecrs/search.c
GNUnet/src/applications/fs/fsui/fsui.c
GNUnet/src/applications/fs/fsui/fsui.h
GNUnet/src/applications/fs/fsui/search.c
GNUnet/src/include/gnunet_ecrs_lib.h
Log:
further reduction in thread creation, this time for search
Modified: GNUnet/src/applications/fs/ecrs/search.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/search.c 2008-06-12 04:17:37 UTC (rev
7140)
+++ GNUnet/src/applications/fs/ecrs/search.c 2008-06-12 04:30:55 UTC (rev
7141)
@@ -92,13 +92,17 @@
int aborted;
+ int my_sctx;
+
unsigned int anonymityLevel;
};
static int
receive_response_callback (const GNUNET_HashCode * key,
- const GNUNET_DatastoreValue * value, void *cls);
+ const GNUNET_DatastoreValue * value,
+ void *cls,
+ unsigned long long uid);
/**
* Add a query to the SQC.
@@ -128,8 +132,7 @@
keyCount,
keys,
sqc->anonymityLevel,
- (GNUNET_DatastoreValueIterator) &
- receive_response_callback, ps);
+ &receive_response_callback, ps);
}
/**
@@ -288,7 +291,9 @@
*/
static int
receive_response_callback (const GNUNET_HashCode * key,
- const GNUNET_DatastoreValue * value, void *cls)
+ const GNUNET_DatastoreValue * value,
+ void *cls,
+ unsigned long long uid)
{
struct PendingSearch *ps = cls;
struct GNUNET_ECRS_SearchContext *sqc = ps->context;
@@ -458,6 +463,7 @@
struct GNUNET_ECRS_SearchContext *
GNUNET_ECRS_search_start (struct GNUNET_GE_Context *ectx,
struct GNUNET_GC_Configuration *cfg,
+ struct GNUNET_FS_SearchContext * sc,
const struct GNUNET_ECRS_URI *uri,
unsigned int anonymityLevel,
GNUNET_ECRS_SearchResultProcessor spcb,
@@ -484,12 +490,13 @@
ctx->spcb = spcb;
ctx->spcbClosure = spcbClosure;
ctx->aborted = GNUNET_NO;
- ctx->sctx = GNUNET_FS_create_search_context (ectx, cfg);
+ ctx->sctx = sc == NULL ? GNUNET_FS_create_search_context (ectx, cfg) : sc;
if (ctx->sctx == NULL)
{
GNUNET_free (ctx);
return NULL;
}
+ ctx->my_sctx = (sc == NULL);
add_search_for_uri (uri, ctx);
return ctx;
}
@@ -504,13 +511,19 @@
GNUNET_ECRS_search_stop (struct GNUNET_ECRS_SearchContext *ctx)
{
struct PendingSearch *pos;
- GNUNET_FS_destroy_search_context (ctx->sctx);
+
while (ctx->queries != NULL)
{
pos = ctx->queries;
ctx->queries = pos->next;
+ if (! ctx->my_sctx)
+ GNUNET_FS_stop_search(ctx->sctx,
+ &receive_response_callback,
+ pos);
GNUNET_free (pos);
}
+ if (ctx->my_sctx)
+ GNUNET_FS_destroy_search_context (ctx->sctx);
GNUNET_free (ctx);
}
@@ -533,7 +546,8 @@
struct GNUNET_ECRS_SearchContext *ctx;
ctx =
- GNUNET_ECRS_search_start (ectx, cfg, uri, anonymityLevel, spcb,
+ GNUNET_ECRS_search_start (ectx, cfg, NULL,
+ uri, anonymityLevel, spcb,
spcbClosure);
if (ctx == NULL)
return GNUNET_SYSERR;
Modified: GNUnet/src/applications/fs/fsui/fsui.c
===================================================================
--- GNUnet/src/applications/fs/fsui/fsui.c 2008-06-12 04:17:37 UTC (rev
7140)
+++ GNUnet/src/applications/fs/fsui/fsui.c 2008-06-12 04:30:55 UTC (rev
7141)
@@ -495,6 +495,7 @@
{
rec->search = GNUNET_ECRS_search_start (list->ctx->ectx,
list->ctx->cfg,
+ list->probe_context,
rec->uri,
list->anonymityLevel,
&GNUNET_FSUI_search_progress_callback,
Modified: GNUnet/src/applications/fs/fsui/fsui.h
===================================================================
--- GNUnet/src/applications/fs/fsui/fsui.h 2008-06-12 04:17:37 UTC (rev
7140)
+++ GNUnet/src/applications/fs/fsui/fsui.h 2008-06-12 04:30:55 UTC (rev
7141)
@@ -171,7 +171,8 @@
struct GNUNET_FSUI_Context *ctx;
/**
- * Context used for availability probes.
+ * Context used for availability probes and the
+ * ECRS searches
*/
struct GNUNET_FS_SearchContext *probe_context;
Modified: GNUnet/src/applications/fs/fsui/search.c
===================================================================
--- GNUnet/src/applications/fs/fsui/search.c 2008-06-12 04:17:37 UTC (rev
7140)
+++ GNUnet/src/applications/fs/fsui/search.c 2008-06-12 04:30:55 UTC (rev
7141)
@@ -239,6 +239,7 @@
srl->search =
GNUNET_ECRS_search_start (pos->ctx->ectx,
pos->ctx->cfg,
+ pos->probe_context,
srl->uri,
pos->anonymityLevel,
&GNUNET_FSUI_search_progress_callback, pos);
@@ -318,6 +319,7 @@
srl->uri = GNUNET_ECRS_uri_duplicate (uri);
srl->search = GNUNET_ECRS_search_start (pos->ctx->ectx,
pos->ctx->cfg,
+ pos->probe_context,
pos->uri,
pos->anonymityLevel,
&GNUNET_FSUI_search_progress_callback,
@@ -483,6 +485,7 @@
{
rec->search = GNUNET_ECRS_search_start (pos->ctx->ectx,
pos->ctx->cfg,
+ pos->probe_context,
rec->uri,
pos->anonymityLevel,
&GNUNET_FSUI_search_progress_callback,
Modified: GNUnet/src/include/gnunet_ecrs_lib.h
===================================================================
--- GNUnet/src/include/gnunet_ecrs_lib.h 2008-06-12 04:17:37 UTC (rev
7140)
+++ GNUnet/src/include/gnunet_ecrs_lib.h 2008-06-12 04:30:55 UTC (rev
7141)
@@ -594,6 +594,9 @@
/**
* Start search for content (asynchronous version).
*
+ * @param sc context to use for searching, you can pass NULL (then
+ * ECRS will manage its own context); if you pass non-NULL,
+ * search_stop must be called before you can destroy the sc.
* @param uri specifies the search parameters;
* this must be a simple URI (with a single
* keyword)
@@ -604,6 +607,7 @@
struct
GNUNET_GC_Configuration
*cfg,
+ struct
GNUNET_FS_SearchContext * sc,
const struct
GNUNET_ECRS_URI
*uri,
@@ -675,6 +679,9 @@
* particular portion of the file (optimization), not to strictly
* limit the download to exactly those bytes.
*
+ * @param sc context to use for searching, you can pass NULL (then
+ * ECRS will manage its own context); if you pass non-NULL,
+ * partial_stop must be called before you can destroy the sc.
* @param uri the URI of the file (determines what to download)
* @param filename where to store the file, maybe NULL (then no file is
* created on disk)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r7141 - in GNUnet/src: applications/fs/ecrs applications/fs/fsui include,
gnunet <=