Author: grothoff Date: 2008-02-22 22:19:05 -0700 (Fri, 22 Feb 2008) New Revision: 6418
Modified: GNUnet/src/applications/fs/fsui/deserialize.c GNUnet/src/applications/fs/fsui/search.c GNUnet/src/applications/fs/fsui/searchtest.c GNUnet/src/applications/fs/fsui/serialize.c GNUnet/src/applications/fs/gap/gap.c GNUnet/src/include/gnunet_fsui_lib.h GNUnet/todo Log: fixes Modified: GNUnet/src/applications/fs/fsui/deserialize.c =================================================================== --- GNUnet/src/applications/fs/fsui/deserialize.c 2008-02-23 04:56:04 UTC (rev 6417) +++ GNUnet/src/applications/fs/fsui/deserialize.c 2008-02-23 05:19:05 UTC (rev 6418) @@ -337,7 +337,7 @@ GNUNET_GE_BREAK (NULL, 0); return GNUNET_SYSERR; } - if (0 != memcmp (magic, "FSUI01\n\0", 8)) + if (0 != memcmp (magic, "FSUI02\n\0", 8)) { GNUNET_GE_BREAK (NULL, 0); return GNUNET_SYSERR; @@ -687,6 +687,7 @@ READLONG (sshared.expiration); if ((big & 2) == 2) READSTRING (sshared.extractor_config, 1024 * 1024); + READSTRING(sshared.top_filename, 1024 * 1024); if ((big & 4) == 4) { sshared.global_keywords = read_uri (ctx->ectx, fd); @@ -716,6 +717,7 @@ #endif break; } + } return GNUNET_SYSERR; } Modified: GNUnet/src/applications/fs/fsui/search.c =================================================================== --- GNUnet/src/applications/fs/fsui/search.c 2008-02-23 04:56:04 UTC (rev 6417) +++ GNUnet/src/applications/fs/fsui/search.c 2008-02-23 05:19:05 UTC (rev 6418) @@ -1,6 +1,6 @@ /* This file is part of GNUnet. - (C) 2001, 2002, 2003, 2004, 2006 Christian Grothoff (and other contributing authors) + (C) 2001, 2002, 2003, 2004, 2006, 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 @@ -248,6 +248,13 @@ 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; @@ -286,6 +293,22 @@ } /** + * 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 * @@ -348,6 +371,54 @@ } /** + * Pause a search. + */ +int +GNUNET_FSUI_search_pause (struct GNUNET_FSUI_Context *ctx, + struct GNUNET_FSUI_SearchList *sl) +{ + void * unused; + + GNUNET_mutex_lock (ctx->lock); + if (sl->state != GNUNET_FSUI_ACTIVE) + { + GNUNET_mutex_unlock (ctx->lock); + return GNUNET_SYSERR; + } + sl->state = GNUNET_FSUI_PAUSED; + GNUNET_thread_stop_sleep (sl->handle); + GNUNET_thread_join (sl->handle, &unused); + GNUNET_mutex_unlock (ctx->lock); + return GNUNET_OK; +} + +/** + * Restart a paused search. + */ +int +GNUNET_FSUI_search_restart (struct GNUNET_FSUI_Context *ctx, + struct GNUNET_FSUI_SearchList *pos) +{ + GNUNET_mutex_lock (ctx->lock); + pos->state = GNUNET_FSUI_ACTIVE; + pos->handle = + GNUNET_thread_create (&GNUNET_FSUI_searchThreadRestartSignal, pos, + 32 * 1024); + 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; + } + GNUNET_mutex_unlock (ctx->lock); + return GNUNET_OK; +} + +/** * Stop a search. */ int Modified: GNUnet/src/applications/fs/fsui/searchtest.c =================================================================== --- GNUnet/src/applications/fs/fsui/searchtest.c 2008-02-23 04:56:04 UTC (rev 6417) +++ GNUnet/src/applications/fs/fsui/searchtest.c 2008-02-23 05:19:05 UTC (rev 6418) @@ -69,6 +69,9 @@ case GNUNET_FSUI_search_suspended: search = NULL; break; + case GNUNET_FSUI_search_paused: + case GNUNET_FSUI_search_restarted: + break; case GNUNET_FSUI_download_resumed: case GNUNET_FSUI_upload_resumed: case GNUNET_FSUI_unindex_resumed: @@ -163,6 +166,14 @@ ctx = GNUNET_FSUI_start (NULL, cfg, "fsuisearchtest", 32, GNUNET_YES, &eventCallback, NULL); + GNUNET_FSUI_search_pause(ctx, search); + GNUNET_FSUI_stop (ctx); + /* resume search! */ + ctx = GNUNET_FSUI_start (NULL, + cfg, "fsuisearchtest", 32, GNUNET_YES, + &eventCallback, NULL); + GNUNET_FSUI_search_restart(ctx, search); + fn = makeName (42); GNUNET_disk_file_write (NULL, fn, "foo bar test!", strlen ("foo bar test!"), Modified: GNUnet/src/applications/fs/fsui/serialize.c =================================================================== --- GNUnet/src/applications/fs/fsui/serialize.c 2008-02-23 04:56:04 UTC (rev 6417) +++ GNUnet/src/applications/fs/fsui/serialize.c 2008-02-23 05:19:05 UTC (rev 6418) @@ -316,6 +316,7 @@ WRITELONG (fd, shared->expiration); if (shared->extractor_config != NULL) WRITESTRING (fd, shared->extractor_config); + WRITESTRING (fd, shared->top_filename); if (shared->global_keywords != NULL) writeURI (fd, shared->global_keywords); writeUploadList (fd, ctx, upos, GNUNET_YES); @@ -335,7 +336,7 @@ S_IRUSR | S_IWUSR); if (fd == -1) return; - WRITE (fd, "FSUI01\n\0", 8); /* magic */ + WRITE (fd, "FSUI02\n\0", 8); /* magic */ writeCollection (fd, ctx); writeSearches (fd, ctx); writeDownloadList (ctx->ectx, fd, ctx, ctx->activeDownloads.child); Modified: GNUnet/src/applications/fs/gap/gap.c =================================================================== --- GNUnet/src/applications/fs/gap/gap.c 2008-02-23 04:56:04 UTC (rev 6417) +++ GNUnet/src/applications/fs/gap/gap.c 2008-02-23 05:19:05 UTC (rev 6418) @@ -449,7 +449,7 @@ size, data, &hc)) { - was_new = GNUNET_YES; + was_new = GNUNET_YES; GNUNET_GE_ASSERT (NULL, rl->response_target != 0); GNUNET_FS_PT_resolve (rl->response_target, &target); GNUNET_GE_ASSERT (NULL, block_count <= MAX_ENTRIES_PER_SLOT); @@ -490,7 +490,7 @@ } if (was_new == GNUNET_YES) GNUNET_FS_MIGRATION_inject (primary_query, - size, data, expiration, block_count, blocked); + size, data, expiration, block_count, blocked); GNUNET_mutex_unlock (GNUNET_FS_lock); GNUNET_FS_PT_change_rc (rid, -1); return value; Modified: GNUnet/src/include/gnunet_fsui_lib.h =================================================================== --- GNUnet/src/include/gnunet_fsui_lib.h 2008-02-23 04:56:04 UTC (rev 6417) +++ GNUnet/src/include/gnunet_fsui_lib.h 2008-02-23 05:19:05 UTC (rev 6418) @@ -1,6 +1,6 @@ /* This file is part of GNUnet - (C) 2004, 2005, 2006 Christian Grothoff (and other contributing authors) + (C) 2004, 2005, 2006, 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 @@ -134,6 +134,8 @@ GNUNET_FSUI_search_error, GNUNET_FSUI_search_suspended, GNUNET_FSUI_search_resumed, + GNUNET_FSUI_search_paused, + GNUNET_FSUI_search_restarted, GNUNET_FSUI_download_started, GNUNET_FSUI_download_stopped, GNUNET_FSUI_download_progress, @@ -172,6 +174,10 @@ * ACTIVE means that there is currently a thread running * the download (and that thread is allowed to continue).<br> * + * PAUSED means that the user asked to pause the activity + * (and that it is to be resumed once the user explicitly + * asks for it to be resumed). + * * COMPLETED means that the download is finished (but the * thread has not been joined yet). The download thread * makes the transition from PENDING to COMPLETED when it @@ -210,13 +216,14 @@ { GNUNET_FSUI_PENDING = 0, GNUNET_FSUI_ACTIVE = 1, - GNUNET_FSUI_COMPLETED = 2, - GNUNET_FSUI_COMPLETED_JOINED = 3, - GNUNET_FSUI_ABORTED = 4, - GNUNET_FSUI_ABORTED_JOINED = 5, - GNUNET_FSUI_ERROR = 6, - GNUNET_FSUI_ERROR_JOINED = 7, - GNUNET_FSUI_SUSPENDING = 8, + GNUNET_FSUI_PAUSED = 2, + GNUNET_FSUI_COMPLETED = 3, + GNUNET_FSUI_COMPLETED_JOINED = 4, + GNUNET_FSUI_ABORTED = 5, + GNUNET_FSUI_ABORTED_JOINED = 6, + GNUNET_FSUI_ERROR = 7, + GNUNET_FSUI_ERROR_JOINED = 8, + GNUNET_FSUI_SUSPENDING = 9, } GNUNET_FSUI_State; /** @@ -391,11 +398,25 @@ } SearchStopped; + struct + { + GNUNET_FSUI_SearchContext sc; + } SearchPaused; + struct { + GNUNET_FSUI_SearchContext sc; + + } SearchRestarted; + + + + struct + { + GNUNET_FSUI_DownloadContext dc; /** @@ -856,7 +877,6 @@ */ void GNUNET_FSUI_stop (struct GNUNET_FSUI_Context *ctx); /* fsui.c */ - /** * Start a search. * @@ -872,6 +892,20 @@ int GNUNET_FSUI_search_abort (struct GNUNET_FSUI_Context *ctx, struct GNUNET_FSUI_SearchList *sl); /* search.c */ /** + * Pause a search. + * + * @return GNUNET_SYSERR if such a search is not known + */ +int GNUNET_FSUI_search_pause (struct GNUNET_FSUI_Context *ctx, struct GNUNET_FSUI_SearchList *sl); /* search.c */ + +/** + * Restart a paused search. + * + * @return GNUNET_SYSERR if such a search is not known + */ +int GNUNET_FSUI_search_restart (struct GNUNET_FSUI_Context *ctx, struct GNUNET_FSUI_SearchList *sl); /* search.c */ + +/** * Stop a search. * * @return GNUNET_SYSERR if such a search is not known Modified: GNUnet/todo =================================================================== --- GNUnet/todo 2008-02-23 04:56:04 UTC (rev 6417) +++ GNUnet/todo 2008-02-23 05:19:05 UTC (rev 6418) @@ -7,7 +7,6 @@ 0.8.0 [6'08] (aka "advanced features"): - full support for FSUI pause/resume of search - HTTP transport uses FAR too much CPU (80-90%!?) => possibly fixed! -- power insert (#854) - clean up VPN code - tune GAP query planning code [RC] - gnunet-chat (CS-only) @@ -52,7 +51,9 @@ - testbed using remote testing topology setup - HTTPS support (#1225) - clean up indexing with gnunet-insert (#1107) +- power insert (#854) + 1.0.0 (aka "userfriendly"): _______________________________________________ GNUnet-SVN mailing list GNUnet-SVN@gnu.org http://lists.gnu.org/mailman/listinfo/gnunet-svn