Author: grothoff Date: 2008-02-24 23:12:45 -0700 (Sun, 24 Feb 2008) New Revision: 6451
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/applications/fs/tools/gnunet-search.c GNUnet/src/include/gnunet_ecrs_lib.h GNUnet/src/include/gnunet_fsui_lib.h GNUnet/src/transports/http.c Log: adding asynchronous ECRS search API Modified: GNUnet/src/applications/fs/ecrs/search.c =================================================================== --- GNUnet/src/applications/fs/ecrs/search.c 2008-02-25 05:10:51 UTC (rev 6450) +++ GNUnet/src/applications/fs/ecrs/search.c 2008-02-25 06:12:45 UTC (rev 6451) @@ -41,7 +41,7 @@ { struct PendingSearch *next; - struct SearchContext *context; + struct GNUNET_ECRS_SearchContext *context; /** * The key (for decryption) @@ -63,7 +63,7 @@ /** * Context for search operation. */ -struct SearchContext +struct GNUNET_ECRS_SearchContext { /** * Time when the cron-job was first started. @@ -112,7 +112,7 @@ add_search (unsigned int type, unsigned int keyCount, const GNUNET_HashCode * keys, - const GNUNET_HashCode * dkey, struct SearchContext *sqc) + const GNUNET_HashCode * dkey, struct GNUNET_ECRS_SearchContext *sqc) { struct PendingSearch *ps; @@ -144,7 +144,7 @@ */ static void add_search_for_uri (const struct GNUNET_ECRS_URI *uri, - struct SearchContext *sqc) + struct GNUNET_ECRS_SearchContext *sqc) { struct GNUNET_GE_Context *ectx = sqc->ectx; @@ -267,7 +267,7 @@ static int process_nblock_result (const NBlock * nb, const GNUNET_HashCode * key, - unsigned int size, struct SearchContext *sqc) + unsigned int size, struct GNUNET_ECRS_SearchContext *sqc) { struct GNUNET_GE_Context *ectx = sqc->ectx; GNUNET_ECRS_FileInfo fi; @@ -310,7 +310,7 @@ const GNUNET_DatastoreValue * value, void *cls) { struct PendingSearch *ps = cls; - struct SearchContext *sqc = ps->context; + struct GNUNET_ECRS_SearchContext *sqc = ps->context; struct GNUNET_GE_Context *ectx = sqc->ectx; unsigned int type; GNUNET_ECRS_FileInfo fi; @@ -544,8 +544,54 @@ return GNUNET_OK; } +/** + * Start search for content. + * + * @param uri specifies the search parameters + * @param uri set to the URI of the uploaded file + */ +struct GNUNET_ECRS_SearchContext * +GNUNET_ECRS_search_start (struct GNUNET_GE_Context *ectx, struct GNUNET_GC_Configuration *cfg, const struct GNUNET_ECRS_URI *uri, unsigned int anonymityLevel, GNUNET_ECRS_SearchResultProcessor spcb, void *spcbClosure) +{ + struct GNUNET_ECRS_SearchContext * ctx; + ctx = GNUNET_malloc(sizeof( struct GNUNET_ECRS_SearchContext)); + ctx->start = GNUNET_get_time (); + ctx->anonymityLevel = anonymityLevel; + ctx->ectx = ectx; + ctx->cfg = cfg; + ctx->queries = NULL; + ctx->spcb = spcb; + ctx->spcbClosure = spcbClosure; + ctx->aborted = GNUNET_NO; + ctx->lock = GNUNET_mutex_create (GNUNET_YES); + ctx->sctx = GNUNET_FS_create_search_context (ectx, cfg, ctx->lock); + add_search_for_uri (uri, ctx); + return ctx; +} + /** + * Stop search for content. + * + * @param uri specifies the search parameters + * @param uri set to the URI of the uploaded file + */ +void +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; + GNUNET_free (pos); + } + GNUNET_mutex_destroy (ctx->lock); + GNUNET_free(ctx); +} + +/** * Search for content. * * @param timeout how long to wait (relative) @@ -561,32 +607,14 @@ void *spcbClosure, GNUNET_ECRS_TestTerminate tt, void *ttClosure) { - struct PendingSearch *pos; - struct SearchContext ctx; + struct GNUNET_ECRS_SearchContext * ctx; - ctx.start = GNUNET_get_time (); - ctx.anonymityLevel = anonymityLevel; - ctx.ectx = ectx; - ctx.cfg = cfg; - ctx.queries = NULL; - ctx.spcb = spcb; - ctx.spcbClosure = spcbClosure; - ctx.aborted = GNUNET_NO; - ctx.lock = GNUNET_mutex_create (GNUNET_YES); - ctx.sctx = GNUNET_FS_create_search_context (ectx, cfg, ctx.lock); - add_search_for_uri (uri, &ctx); + ctx = GNUNET_ECRS_search_start(ectx, cfg, uri, anonymityLevel, spcb, spcbClosure); while (((NULL == tt) || (GNUNET_OK == tt (ttClosure))) && - (GNUNET_NO == GNUNET_shutdown_test ()) && (ctx.aborted == GNUNET_NO)) + (GNUNET_NO == GNUNET_shutdown_test ()) && (ctx->aborted == GNUNET_NO)) GNUNET_thread_sleep (100 * GNUNET_CRON_MILLISECONDS); - GNUNET_FS_destroy_search_context (ctx.sctx); - while (ctx.queries != NULL) - { - pos = ctx.queries; - ctx.queries = pos->next; - GNUNET_free (pos); - } - GNUNET_mutex_destroy (ctx.lock); + GNUNET_ECRS_search_stop(ctx); return GNUNET_OK; } Modified: GNUnet/src/applications/fs/fsui/fsui.c =================================================================== --- GNUnet/src/applications/fs/fsui/fsui.c 2008-02-25 05:10:51 UTC (rev 6450) +++ GNUnet/src/applications/fs/fsui/fsui.c 2008-02-25 06:12:45 UTC (rev 6451) @@ -322,12 +322,19 @@ if (list->state == GNUNET_FSUI_PENDING) { list->state = GNUNET_FSUI_ACTIVE; - list->handle = - GNUNET_thread_create (&GNUNET_FSUI_searchThread, list, 32 * 1024); + list->handle = GNUNET_ECRS_search_start(list->ctx->ectx, + list->ctx->cfg, + list->uri, + list->anonymityLevel, + &GNUNET_FSUI_search_progress_callback, + list); if (list->handle == NULL) - GNUNET_GE_DIE_STRERROR (ectx, - GNUNET_GE_FATAL | GNUNET_GE_ADMIN | - GNUNET_GE_IMMEDIATE, "pthread_create"); + { + GNUNET_GE_LOG (ectx, + GNUNET_GE_FATAL | GNUNET_GE_ADMIN | + GNUNET_GE_IMMEDIATE, "Failed to resume search\n"); + list->state = GNUNET_FSUI_PENDING; + } } list = list->next; } @@ -491,8 +498,8 @@ { if (spos->state == GNUNET_FSUI_ACTIVE) spos->state = GNUNET_FSUI_PENDING; - GNUNET_thread_stop_sleep (spos->handle); - GNUNET_thread_join (spos->handle, &unused); + GNUNET_ECRS_search_stop(spos->handle); + spos->handle = NULL; if (spos->state != GNUNET_FSUI_PENDING) spos->state++; /* _JOINED */ } Modified: GNUnet/src/applications/fs/fsui/fsui.h =================================================================== --- GNUnet/src/applications/fs/fsui/fsui.h 2008-02-25 05:10:51 UTC (rev 6450) +++ GNUnet/src/applications/fs/fsui/fsui.h 2008-02-25 06:12:45 UTC (rev 6451) @@ -78,7 +78,7 @@ /** * Handle to the thread which performs the search. */ - struct GNUNET_ThreadHandle *handle; + struct GNUNET_ECRS_SearchContext *handle; /** * Which URI are we searching? @@ -456,10 +456,12 @@ */ int GNUNET_FSUI_updateDownloadThread (GNUNET_FSUI_DownloadList * list); +int +GNUNET_FSUI_search_progress_callback (const GNUNET_ECRS_FileInfo * fi, + const GNUNET_HashCode * key, int isRoot, void *cls); + void *GNUNET_FSUI_uploadThread (void *dl); -void *GNUNET_FSUI_searchThread (void *pos); - void *GNUNET_FSUI_unindexThread (void *cls); void GNUNET_FSUI_serialize (struct GNUNET_FSUI_Context *ctx); Modified: GNUnet/src/applications/fs/fsui/search.c =================================================================== --- GNUnet/src/applications/fs/fsui/search.c 2008-02-25 05:10:51 UTC (rev 6450) +++ GNUnet/src/applications/fs/fsui/search.c 2008-02-25 06:12:45 UTC (rev 6451) @@ -67,9 +67,9 @@ /** * Process results found by ECRS. */ -static int -spcb (const GNUNET_ECRS_FileInfo * fi, - const GNUNET_HashCode * key, int isRoot, void *cls) +int +GNUNET_FSUI_search_progress_callback (const GNUNET_ECRS_FileInfo * fi, + const GNUNET_HashCode * key, int isRoot, void *cls) { GNUNET_FSUI_SearchList *pos = cls; unsigned int i; @@ -198,117 +198,7 @@ return GNUNET_OK; } -static int -testTerminate (void *cls) -{ - GNUNET_FSUI_SearchList *pos = cls; - if (pos->state == GNUNET_FSUI_ACTIVE) - return GNUNET_OK; - return GNUNET_SYSERR; -} - /** - * Thread that searches for data. - */ -void * -GNUNET_FSUI_searchThread (void *cls) -{ - GNUNET_FSUI_SearchList *pos = cls; - GNUNET_FSUI_Event event; - int ret; - struct GNUNET_GE_Memory *mem; - struct GNUNET_GE_Context *ee; - - mem = GNUNET_GE_memory_create (2); - ee = GNUNET_GE_create_context_memory (GNUNET_GE_USER | GNUNET_GE_ADMIN | - GNUNET_GE_ERROR | GNUNET_GE_WARNING | - GNUNET_GE_FATAL | GNUNET_GE_BULK | - GNUNET_GE_IMMEDIATE, mem); - ret = - GNUNET_ECRS_search (ee, pos->ctx->cfg, pos->uri, pos->anonymityLevel, - &spcb, pos, &testTerminate, pos); - if (ret != GNUNET_OK) - { - const char *error; - - pos->state = GNUNET_FSUI_ERROR; - event.type = GNUNET_FSUI_search_error; - event.data.SearchError.sc.pos = pos; - event.data.SearchError.sc.cctx = pos->cctx; - error = GNUNET_GE_memory_get (mem, 0); - if (error == NULL) - error = _("Error running search (no reason given)."); - event.data.SearchError.message = error; - pos->ctx->ecb (pos->ctx->ecbClosure, &event); - } - else if (pos->state == GNUNET_FSUI_ABORTED) - { - event.type = GNUNET_FSUI_search_aborted; - event.data.SearchAborted.sc.pos = pos; - event.data.SearchAborted.sc.cctx = pos->cctx; - pos->ctx->ecb (pos->ctx->ecbClosure, &event); - } - else if (pos->state == GNUNET_FSUI_PAUSED) - { - event.type = GNUNET_FSUI_search_paused; - event.data.SearchPaused.sc.pos = pos; - event.data.SearchPaused.sc.cctx = pos->cctx; - pos->ctx->ecb (pos->ctx->ecbClosure, &event); - } - else if (pos->state == GNUNET_FSUI_ACTIVE) - { - pos->state = GNUNET_FSUI_COMPLETED; - event.type = GNUNET_FSUI_search_completed; - event.data.SearchCompleted.sc.pos = pos; - event.data.SearchCompleted.sc.cctx = pos->cctx; - pos->ctx->ecb (pos->ctx->ecbClosure, &event); - } - else - { - GNUNET_GE_ASSERT (NULL, pos->state == GNUNET_FSUI_PENDING); - /* must be suspending */ - } - GNUNET_GE_free_context (ee); - GNUNET_GE_memory_free (mem); - - return NULL; -} - -/** - * Thread that searches for data (and signals startup). - */ -void * -GNUNET_FSUI_searchThreadSignal (void *cls) -{ - GNUNET_FSUI_SearchList *pos = cls; - GNUNET_FSUI_Event event; - - event.type = GNUNET_FSUI_search_started; - event.data.SearchStarted.sc.pos = pos; - event.data.SearchStarted.sc.cctx = NULL; - event.data.SearchStarted.searchURI = pos->uri; - event.data.SearchStarted.anonymityLevel = pos->anonymityLevel; - pos->cctx = pos->ctx->ecb (pos->ctx->ecbClosure, &event); - return GNUNET_FSUI_searchThread (pos); -} - -/** - * Thread that searches for data (and signals startup). - */ -static void * -GNUNET_FSUI_searchThreadRestartSignal (void *cls) -{ - GNUNET_FSUI_SearchList *pos = cls; - GNUNET_FSUI_Event event; - - event.type = GNUNET_FSUI_search_restarted; - event.data.SearchStarted.sc.pos = pos; - event.data.SearchStarted.sc.cctx = pos->cctx; - pos->ctx->ecb (pos->ctx->ecbClosure, &event); - return GNUNET_FSUI_searchThread (pos); -} - -/** * Start a search. */ struct GNUNET_FSUI_SearchList * @@ -318,6 +208,7 @@ { GNUNET_FSUI_SearchList *pos; struct GNUNET_GE_Context *ectx; + GNUNET_FSUI_Event event; ectx = ctx->ectx; GNUNET_mutex_lock (ctx->lock); @@ -332,14 +223,20 @@ pos->anonymityLevel = anonymityLevel; pos->ctx = ctx; pos->start_time = GNUNET_get_time (); - pos->handle = - GNUNET_thread_create (&GNUNET_FSUI_searchThreadSignal, pos, 32 * 1024); + event.type = GNUNET_FSUI_search_started; + event.data.SearchStarted.sc.pos = pos; + event.data.SearchStarted.sc.cctx = NULL; + event.data.SearchStarted.searchURI = pos->uri; + event.data.SearchStarted.anonymityLevel = pos->anonymityLevel; + pos->cctx = pos->ctx->ecb (pos->ctx->ecbClosure, &event); + pos->handle = GNUNET_ECRS_search_start(pos->ctx->ectx, + pos->ctx->cfg, + pos->uri, + pos->anonymityLevel, + &GNUNET_FSUI_search_progress_callback, + pos); if (pos->handle == NULL) { - GNUNET_GE_LOG_STRERROR (ectx, - GNUNET_GE_ERROR | GNUNET_GE_IMMEDIATE | - GNUNET_GE_USER | GNUNET_GE_ADMIN, - "PTHREAD_CREATE"); GNUNET_ECRS_uri_destroy (pos->uri); GNUNET_free (pos); GNUNET_mutex_unlock (ctx->lock); @@ -358,15 +255,28 @@ GNUNET_FSUI_search_abort (struct GNUNET_FSUI_Context *ctx, struct GNUNET_FSUI_SearchList *sl) { + GNUNET_FSUI_Event event; + + GNUNET_mutex_lock (ctx->lock); if (sl->state == GNUNET_FSUI_PENDING) { sl->state = GNUNET_FSUI_ABORTED_JOINED; + GNUNET_mutex_unlock (ctx->lock); return GNUNET_OK; } if (sl->state != GNUNET_FSUI_ACTIVE) - return GNUNET_SYSERR; - sl->state = GNUNET_FSUI_ABORTED; - GNUNET_thread_stop_sleep (sl->handle); + { + GNUNET_mutex_unlock (ctx->lock); + return GNUNET_SYSERR; + } + GNUNET_ECRS_search_stop(sl->handle); + sl->state = GNUNET_FSUI_ABORTED_JOINED; + sl->handle = NULL; + event.type = GNUNET_FSUI_search_aborted; + event.data.SearchAborted.sc.pos = sl; + event.data.SearchAborted.sc.cctx = sl->cctx; + sl->ctx->ecb (sl->ctx->ecbClosure, &event); + GNUNET_mutex_unlock (ctx->lock); return GNUNET_OK; } @@ -377,7 +287,7 @@ GNUNET_FSUI_search_pause (struct GNUNET_FSUI_Context *ctx, struct GNUNET_FSUI_SearchList *sl) { - void *unused; + GNUNET_FSUI_Event event; GNUNET_mutex_lock (ctx->lock); if (sl->state != GNUNET_FSUI_ACTIVE) @@ -385,9 +295,12 @@ GNUNET_mutex_unlock (ctx->lock); return GNUNET_SYSERR; } + GNUNET_ECRS_search_stop(sl->handle); sl->state = GNUNET_FSUI_PAUSED; - GNUNET_thread_stop_sleep (sl->handle); - GNUNET_thread_join (sl->handle, &unused); + event.type = GNUNET_FSUI_search_paused; + event.data.SearchPaused.sc.pos = sl; + event.data.SearchPaused.sc.cctx = sl->cctx; + sl->ctx->ecb (sl->ctx->ecbClosure, &event); GNUNET_mutex_unlock (ctx->lock); return GNUNET_OK; } @@ -399,17 +312,22 @@ GNUNET_FSUI_search_restart (struct GNUNET_FSUI_Context *ctx, struct GNUNET_FSUI_SearchList *pos) { + GNUNET_FSUI_Event event; + GNUNET_mutex_lock (ctx->lock); pos->state = GNUNET_FSUI_ACTIVE; - pos->handle = - GNUNET_thread_create (&GNUNET_FSUI_searchThreadRestartSignal, pos, - 32 * 1024); + event.type = GNUNET_FSUI_search_restarted; + event.data.SearchStarted.sc.pos = pos; + event.data.SearchStarted.sc.cctx = pos->cctx; + pos->ctx->ecb (pos->ctx->ecbClosure, &event); + pos->handle = GNUNET_ECRS_search_start(pos->ctx->ectx, + pos->ctx->cfg, + pos->uri, + pos->anonymityLevel, + &GNUNET_FSUI_search_progress_callback, + pos); if (pos->handle == NULL) { - GNUNET_GE_LOG_STRERROR (ctx->ectx, - GNUNET_GE_ERROR | GNUNET_GE_IMMEDIATE | - GNUNET_GE_USER | GNUNET_GE_ADMIN, - "PTHREAD_CREATE"); pos->state = GNUNET_FSUI_PAUSED; GNUNET_mutex_unlock (ctx->lock); return GNUNET_SYSERR; @@ -428,7 +346,6 @@ GNUNET_FSUI_Event event; GNUNET_FSUI_SearchList *pos; GNUNET_FSUI_SearchList *prev; - void *unused; int i; GNUNET_mutex_lock (ctx->lock); @@ -455,28 +372,11 @@ GNUNET_array_grow (sl->my_downloads, sl->my_downloads_size, 0); GNUNET_mutex_unlock (ctx->lock); pos->next = NULL; - if ((pos->state == GNUNET_FSUI_COMPLETED) || - (pos->state == GNUNET_FSUI_ABORTED) - || (pos->state == GNUNET_FSUI_ERROR)) - { - GNUNET_GE_ASSERT (ctx->ectx, pos->handle != NULL); - GNUNET_thread_join (pos->handle, &unused); - pos->handle = NULL; - if (pos->state == GNUNET_FSUI_ACTIVE) - pos->state = GNUNET_FSUI_PENDING; - else - pos->state++; /* add _JOINED */ - } - else - { - GNUNET_GE_ASSERT (ctx->ectx, pos->handle == NULL); - } + GNUNET_GE_ASSERT (ctx->ectx, pos->handle == NULL); event.type = GNUNET_FSUI_search_stopped; event.data.SearchStopped.sc.pos = pos; event.data.SearchStopped.sc.cctx = pos->cctx; pos->ctx->ecb (pos->ctx->ecbClosure, &event); - - GNUNET_ECRS_uri_destroy (pos->uri); for (i = 0; i < pos->sizeResultsReceived; i++) { Modified: GNUnet/src/applications/fs/tools/gnunet-search.c =================================================================== --- GNUnet/src/applications/fs/tools/gnunet-search.c 2008-02-25 05:10:51 UTC (rev 6450) +++ GNUnet/src/applications/fs/tools/gnunet-search.c 2008-02-25 06:12:45 UTC (rev 6451) @@ -73,18 +73,10 @@ switch (event->type) { - case GNUNET_FSUI_search_error: - errorCode = 3; - GNUNET_shutdown_initiate (); - break; case GNUNET_FSUI_search_aborted: errorCode = 4; GNUNET_shutdown_initiate (); break; - case GNUNET_FSUI_search_completed: - errorCode = 0; - GNUNET_shutdown_initiate (); - break; case GNUNET_FSUI_search_result: /* retain URIs for possible directory dump later */ GNUNET_array_grow (fis, fiCount, fiCount + 1); Modified: GNUnet/src/include/gnunet_ecrs_lib.h =================================================================== --- GNUnet/src/include/gnunet_ecrs_lib.h 2008-02-25 05:10:51 UTC (rev 6450) +++ GNUnet/src/include/gnunet_ecrs_lib.h 2008-02-25 06:12:45 UTC (rev 6451) @@ -1,6 +1,6 @@ /* This file is part of GNUnet - (C) 2004, 2005, 2006, 2007 Christian Grothoff (and other contributing authors) + (C) 2004, 2005, 2006, 2007, 2008 Christian Grothoff (and other contributing authors) GNUnet is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published @@ -55,7 +55,7 @@ * 5.0.x: with location URIs * 6.x.x: who knows? :-) */ -#define GNUNET_ECRS_VERSION "5.0.1" +#define GNUNET_ECRS_VERSION "5.1.0" #define GNUNET_DIRECTORY_MIME "application/gnunet-directory" #define GNUNET_DIRECTORY_MAGIC "\211GND\r\n\032\n" @@ -689,12 +689,32 @@ (const GNUNET_ECRS_FileInfo * fi, const GNUNET_HashCode * key, int isRoot, void *closure); +struct GNUNET_ECRS_SearchContext; + /** - * Search for content. + * Start search for content (asynchronous version). * * @param uri specifies the search parameters * @param uri set to the URI of the uploaded file */ +struct GNUNET_ECRS_SearchContext * +GNUNET_ECRS_search_start (struct GNUNET_GE_Context *ectx, struct GNUNET_GC_Configuration *cfg, const struct GNUNET_ECRS_URI *uri, unsigned int anonymityLevel, GNUNET_ECRS_SearchResultProcessor spcb, void *spcbClosure); /* search.c */ + +/** + * Stop search for content. + * + * @param uri specifies the search parameters + * @param uri set to the URI of the uploaded file + */ +void +GNUNET_ECRS_search_stop (struct GNUNET_ECRS_SearchContext * sctx); + +/** + * Search for content (synchronous version). + * + * @param uri specifies the search parameters + * @param uri set to the URI of the uploaded file + */ int GNUNET_ECRS_search (struct GNUNET_GE_Context *ectx, struct GNUNET_GC_Configuration *cfg, const struct GNUNET_ECRS_URI *uri, unsigned int anonymityLevel, GNUNET_ECRS_SearchResultProcessor spcb, void *spcbClosure, GNUNET_ECRS_TestTerminate tt, void *ttClosure); /* search.c */ /** @@ -719,7 +739,7 @@ const char *lastBlock, unsigned int lastBlockSize, void *closure); /** - * GNUNET_ND_DOWNLOAD a file. + * DOWNLOAD a file. * * @param uri the URI of the file (determines what to download) * @param filename where to store the file @@ -727,7 +747,7 @@ int GNUNET_ECRS_file_download (struct GNUNET_GE_Context *ectx, struct GNUNET_GC_Configuration *cfg, const struct GNUNET_ECRS_URI *uri, const char *filename, unsigned int anonymityLevel, GNUNET_ECRS_DownloadProgressCallback dpcb, void *dpcbClosure, GNUNET_ECRS_TestTerminate tt, void *ttClosure); /* download.c */ /** - * GNUNET_ND_DOWNLOAD parts of a file. Note that this will store + * DOWNLOAD parts of a file. Note that this will store * the blocks at the respective offset in the given file. * Also, the download is still using the blocking of the * underlying ECRS encoding. As a result, the download Modified: GNUnet/src/include/gnunet_fsui_lib.h =================================================================== --- GNUnet/src/include/gnunet_fsui_lib.h 2008-02-25 05:10:51 UTC (rev 6450) +++ GNUnet/src/include/gnunet_fsui_lib.h 2008-02-25 06:12:45 UTC (rev 6451) @@ -129,9 +129,7 @@ GNUNET_FSUI_search_started, GNUNET_FSUI_search_stopped, GNUNET_FSUI_search_result, - GNUNET_FSUI_search_completed, GNUNET_FSUI_search_aborted, - GNUNET_FSUI_search_error, GNUNET_FSUI_search_suspended, GNUNET_FSUI_search_resumed, GNUNET_FSUI_search_paused, @@ -332,19 +330,11 @@ } SearchResult; - struct { GNUNET_FSUI_SearchContext sc; - } SearchCompleted; - - struct - { - - GNUNET_FSUI_SearchContext sc; - } SearchAborted; struct @@ -352,15 +342,6 @@ GNUNET_FSUI_SearchContext sc; - const char *message; - - } SearchError; - - struct - { - - GNUNET_FSUI_SearchContext sc; - } SearchSuspended; struct Modified: GNUnet/src/transports/http.c =================================================================== --- GNUnet/src/transports/http.c 2008-02-25 05:10:51 UTC (rev 6450) +++ GNUnet/src/transports/http.c 2008-02-25 06:12:45 UTC (rev 6451) @@ -378,6 +378,24 @@ static int stat_put_received; +static int stat_select_calls; + +static int stat_send_calls; + +static int stat_connect_calls; + +static int stat_curl_send_callbacks; + +static int stat_curl_receive_callbacks; + +static int stat_mhd_access_callbacks; + +static int stat_mhd_read_callbacks; + +static int stat_mhd_close_callbacks; + +static int stat_connect_calls; + /** * How many requests do we have currently pending * (with libcurl)? @@ -582,6 +600,8 @@ struct MHDGetData *gpos; #endif + if (stats != NULL) + stats->change(stat_mhd_close_callbacks, 1); ENTER (); if (httpsession == NULL) return; /* oops */ @@ -702,8 +722,9 @@ contentReaderCallback (void *cls, size_t pos, char *buf, int max) { struct MHDGetData *mgd = cls; - GNUNET_CronTime now; + if (stats != NULL) + stats->change(stat_mhd_read_callbacks, 1); ENTER (); GNUNET_mutex_lock (lock); if (mgd->wpos < max) @@ -711,9 +732,8 @@ memcpy (buf, &mgd->wbuff[mgd->woff], max); mgd->wpos -= max; mgd->woff += max; - now = GNUNET_get_time (); if (max > 0) - mgd->last_get_activity = now; + mgd->last_get_activity = GNUNET_get_time (); if (mgd->wpos == 0) mgd->woff = 0; GNUNET_mutex_unlock (lock); @@ -782,6 +802,8 @@ unsigned int cpy; unsigned int poff; + if (stats != NULL) + stats->change(stat_mhd_access_callbacks, 1); ENTER (); #if DEBUG_HTTP GNUNET_GE_LOG (coreAPI->ectx, @@ -1010,6 +1032,8 @@ GNUNET_MessageHeader *hdr; GNUNET_TransportPacket *mp; + if (stats != NULL) + stats->change(stat_curl_receive_callbacks, 1); ENTER (); httpSession->cs.client.last_get_activity = GNUNET_get_time (); #if DEBUG_HTTP @@ -1083,6 +1107,8 @@ struct HTTPPutData *put = ctx; size_t max = size * nmemb; + if (stats != NULL) + stats->change(stat_curl_send_callbacks, 1); ENTER (); put->last_activity = GNUNET_get_time (); if (max > put->size - put->pos) @@ -1268,6 +1294,8 @@ HTTPSession *httpSession; int i; + if (stats != NULL) + stats->change(stat_connect_calls, 1); ENTER (); /* check if we have a session pending for this peer */ tsession = NULL; @@ -1514,6 +1542,8 @@ char *tmp; #endif + if (stats != NULL) + stats->change(stat_send_calls, 1); ENTER (); if (httpSession->is_client) { @@ -1859,6 +1889,8 @@ tv.tv_sec = timeout / 1000; tv.tv_usec = (timeout % 1000) * 1000; STEP (); + if (stats != NULL) + stats->change(stat_select_calls, 1); SELECT (max + 1, &rs, &ws, &es, (have_tv == MHD_YES) ? &tv : NULL); STEP (); if (GNUNET_YES != http_running) @@ -2098,6 +2130,24 @@ stat_put_issued = stats->create (gettext_noop ("# HTTP PUT issued")); stat_put_received = stats->create (gettext_noop ("# HTTP PUT received")); + stat_select_calls + = stats->create (gettext_noop ("# HTTP select calls")); + + stat_send_calls + = stats->create (gettext_noop ("# HTTP send calls")); + + stat_curl_send_callbacks + = stats->create (gettext_noop ("# HTTP curl send callbacks")); + stat_curl_receive_callbacks + = stats->create (gettext_noop ("# HTTP curl receive callbacks")); + stat_mhd_access_callbacks + = stats->create (gettext_noop ("# HTTP mhd access callbacks")); + stat_mhd_read_callbacks + = stats->create (gettext_noop ("# HTTP mhd read callbacks")); + stat_mhd_close_callbacks + = stats->create (gettext_noop ("# HTTP mhd close callbacks")); + stat_connect_calls + = stats->create (gettext_noop ("# HTTP connect calls")); } GNUNET_GC_get_configuration_value_string (coreAPI->cfg, "GNUNETD", "HTTP-PROXY", "", _______________________________________________ GNUnet-SVN mailing list GNUnet-SVN@gnu.org http://lists.gnu.org/mailman/listinfo/gnunet-svn