From 3d8988d8bda24d394d72302cefd0d7d76336d068 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Tue, 4 May 2010 11:55:52 +0000 Subject: [PATCH] code cleanup --- TODO | 6 ++- src/fs/fs.c | 116 ++++++++++++++++++++----------------------- src/fs/fs.h | 46 +++++++++++++++-- src/fs/fs_download.c | 8 +-- src/fs/fs_publish.c | 2 +- src/fs/fs_search.c | 92 ++++++++++++++++++++++++++++++---- src/fs/fs_unindex.c | 2 +- 7 files changed, 188 insertions(+), 84 deletions(-) diff --git a/TODO b/TODO index 3637418cb..9362b0097 100644 --- a/TODO +++ b/TODO @@ -2,7 +2,12 @@ * FS: [CG] - code review: => refactor fs.c to join common code segments! + => pbuf sprintf'ing + => initial master directory scanning => document directory structure (and use #define's for the directory names!) + - SKS update searches should be attached to individual search results, not to the + entire SKS search (!) + => API change (event signalling) & serialization change (!) - persistence testing (publish, unindex, search, download): => need driver! => schedule suspending tasks DURING event handler => good coverage! @@ -114,7 +119,6 @@ * FS: - reconstruct IBLOCKS from DBLOCKS if possible (during download; see FIXME in fs_download) - 0.9.0: * new webpage: - expand bibliography diff --git a/src/fs/fs.c b/src/fs/fs.c index ba899d6d4..749db4dfe 100644 --- a/src/fs/fs.c +++ b/src/fs/fs.c @@ -817,7 +817,7 @@ deserialize_file_information (struct GNUNET_FS_Handle *h, struct GNUNET_BIO_ReadHandle *rh; char *emsg; - rh = get_read_handle (h, "publish-fi", filename); + rh = get_read_handle (h, GNUNET_FS_SYNC_PATH_FILE_INFO, filename); if (rh == NULL) return NULL; ret = deserialize_fi_node (h, filename, rh); @@ -952,10 +952,10 @@ GNUNET_FS_file_information_sync_ (struct GNUNET_FS_FileInformation * fi) char *chks; if (NULL == fi->serialization) - fi->serialization = make_serialization_file_name (fi->h, "publish-fi"); + fi->serialization = make_serialization_file_name (fi->h, GNUNET_FS_SYNC_PATH_FILE_INFO); if (NULL == fi->serialization) return; - wh = get_write_handle (fi->h, "publish-fi", fi->serialization); + wh = get_write_handle (fi->h, GNUNET_FS_SYNC_PATH_FILE_INFO, fi->serialization); if (wh == NULL) { GNUNET_free (fi->serialization); @@ -1058,7 +1058,7 @@ GNUNET_FS_file_information_sync_ (struct GNUNET_FS_FileInformation * fi) (void) GNUNET_BIO_write_close (wh); GNUNET_free_non_null (chks); GNUNET_free_non_null (ksks); - fn = get_serialization_file_name (fi->h, "publish-fi", fi->serialization); + fn = get_serialization_file_name (fi->h, GNUNET_FS_SYNC_PATH_FILE_INFO, fi->serialization); if (0 != UNLINK (fn)) GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "unlink", fn); GNUNET_free (fn); @@ -1254,8 +1254,8 @@ deserialize_publish_file (void *cls, } if (pc->fi != NULL) GNUNET_FS_file_information_destroy (pc->fi, NULL, NULL); - if (pc->serialization != NULL) - GNUNET_FS_remove_sync_file_ (h, "publish", pc->serialization); + if (0 != UNLINK (filename)) + GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "unlink", filename); GNUNET_free_non_null (pc->serialization); GNUNET_free (pc); return GNUNET_OK; @@ -1277,7 +1277,7 @@ GNUNET_FS_publish_sync_ (struct GNUNET_FS_PublishContext *pc) if (NULL == pc->serialization) pc->serialization = make_serialization_file_name (pc->h, - "publish"); + GNUNET_FS_SYNC_PATH_MASTER_PUBLISH); if (NULL == pc->serialization) return; if (NULL == pc->fi) @@ -1287,7 +1287,7 @@ GNUNET_FS_publish_sync_ (struct GNUNET_FS_PublishContext *pc) GNUNET_break (0); return; } - wh = get_write_handle (pc->h, "publish", pc->serialization); + wh = get_write_handle (pc->h, GNUNET_FS_SYNC_PATH_MASTER_PUBLISH, pc->serialization); if ( (GNUNET_OK != GNUNET_BIO_write_string (wh, pc->nid)) || (GNUNET_OK != @@ -1303,20 +1303,21 @@ GNUNET_FS_publish_sync_ (struct GNUNET_FS_PublishContext *pc) (GNUNET_OK != GNUNET_BIO_write_string (wh, (pc->namespace == NULL) ? NULL : pc->namespace->name)) ) { - (void) GNUNET_BIO_write_close (wh); - GNUNET_FS_remove_sync_file_ (pc->h, "publish", pc->serialization); - GNUNET_free (pc->serialization); - pc->serialization = NULL; - return; + goto cleanup; } if (GNUNET_OK != GNUNET_BIO_write_close (wh)) { - GNUNET_FS_remove_sync_file_ (pc->h, "publish", pc->serialization); - GNUNET_free (pc->serialization); - pc->serialization = NULL; - return; - } + wh = NULL; + goto cleanup; + } + return; + cleanup: + if (wh != NULL) + (void) GNUNET_BIO_write_close (wh); + GNUNET_FS_remove_sync_file_ (pc->h, GNUNET_FS_SYNC_PATH_MASTER_PUBLISH, pc->serialization); + GNUNET_free (pc->serialization); + pc->serialization = NULL; } @@ -1337,10 +1338,10 @@ GNUNET_FS_unindex_sync_ (struct GNUNET_FS_UnindexContext *uc) return; if (NULL == uc->serialization) uc->serialization = make_serialization_file_name (uc->h, - "unindex"); + GNUNET_FS_SYNC_PATH_MASTER_UNINDEX); if (NULL == uc->serialization) return; - wh = get_write_handle (uc->h, "unindex", uc->serialization); + wh = get_write_handle (uc->h, GNUNET_FS_SYNC_PATH_MASTER_UNINDEX, uc->serialization); if ( (GNUNET_OK != GNUNET_BIO_write_string (wh, uc->filename)) || (GNUNET_OK != @@ -1355,21 +1356,20 @@ GNUNET_FS_unindex_sync_ (struct GNUNET_FS_UnindexContext *uc) ( (uc->state == UNINDEX_STATE_ERROR) && (GNUNET_OK != GNUNET_BIO_write_string (wh, uc->emsg)) ) ) - { - (void) GNUNET_BIO_write_close (wh); - GNUNET_FS_remove_sync_file_ (uc->h, "publish", uc->serialization); - GNUNET_free (uc->serialization); - uc->serialization = NULL; - return; - } + goto cleanup; if (GNUNET_OK != GNUNET_BIO_write_close (wh)) { - GNUNET_FS_remove_sync_file_ (uc->h, "unindex", uc->serialization); - GNUNET_free (uc->serialization); - uc->serialization = NULL; - return; + wh = NULL; + goto cleanup; } + return; + cleanup: + if (wh != NULL) + (void) GNUNET_BIO_write_close (wh); + GNUNET_FS_remove_sync_file_ (uc->h, GNUNET_FS_SYNC_PATH_MASTER_UNINDEX, uc->serialization); + GNUNET_free (uc->serialization); + uc->serialization = NULL; } @@ -1445,14 +1445,14 @@ GNUNET_FS_download_sync_ (struct GNUNET_FS_DownloadContext *dc) GNUNET_snprintf (pbuf, sizeof (pbuf), "%s%s%s", - "subdownloads", + GNUNET_FS_SYNC_PATH_CHILD_DOWNLOAD, DIR_SEPARATOR_STR, dc->parent->serialization); category = pbuf; } else { - category = "download"; + category = GNUNET_FS_SYNC_PATH_MASTER_DOWNLOAD; } if (NULL == dc->serialization) dc->serialization = make_serialization_file_name (dc->h, @@ -1544,10 +1544,10 @@ GNUNET_FS_search_result_sync_ (struct GNUNET_FS_SearchResult *sr) uris = NULL; if (NULL == sr->serialization) sr->serialization = make_serialization_file_name (sr->sc->h, - "search-results"); + GNUNET_FS_SYNC_PATH_SEARCH_RESULT); if (NULL == sr->serialization) return; - wh = get_write_handle (sr->sc->h, "search-results", sr->serialization); + wh = get_write_handle (sr->sc->h, GNUNET_FS_SYNC_PATH_SEARCH_RESULT, sr->serialization); uris = GNUNET_FS_uri_to_string (sr->uri); if ( (GNUNET_OK != GNUNET_BIO_write_string (wh, uris)) || @@ -1578,7 +1578,7 @@ GNUNET_FS_search_result_sync_ (struct GNUNET_FS_SearchResult *sr) GNUNET_free_non_null (uris); if (wh != NULL) (void) GNUNET_BIO_write_close (wh); - GNUNET_FS_remove_sync_file_ (sr->sc->h, "search-results", sr->serialization); + GNUNET_FS_remove_sync_file_ (sr->sc->h, GNUNET_FS_SYNC_PATH_SEARCH_RESULT, sr->serialization); GNUNET_free (sr->serialization); sr->serialization = NULL; } @@ -1599,13 +1599,16 @@ GNUNET_FS_search_sync_ (struct GNUNET_FS_SearchContext *sc) struct GNUNET_FS_SearchContext *scc; char *uris; char in_pause; + const char *category; + + category = (sc->parent == NULL) ? GNUNET_FS_SYNC_PATH_MASTER_SEARCH : GNUNET_FS_SYNC_PATH_CHILD_SEARCH; if (NULL == sc->serialization) sc->serialization = make_serialization_file_name (sc->h, - "search"); + category); if (NULL == sc->serialization) return; - wh = get_write_handle (sc->h, "search", sc->serialization); + wh = get_write_handle (sc->h, category, sc->serialization); GNUNET_assert ( (GNUNET_YES == GNUNET_FS_uri_test_ksk (sc->uri)) || (GNUNET_YES == GNUNET_FS_uri_test_sks (sc->uri)) ); uris = GNUNET_FS_uri_to_string (sc->uri); @@ -1647,7 +1650,7 @@ GNUNET_FS_search_sync_ (struct GNUNET_FS_SearchContext *sc) if (wh != NULL) (void) GNUNET_BIO_write_close (wh); GNUNET_free_non_null (uris); - GNUNET_FS_remove_sync_file_ (sc->h, "search", sc->serialization); + GNUNET_FS_remove_sync_file_ (sc->h, category, sc->serialization); GNUNET_free (sc->serialization); sc->serialization = NULL; } @@ -1663,7 +1666,7 @@ deserialize_publish (struct GNUNET_FS_Handle *h) { char *dn; - dn = get_serialization_file_name (h, "publish", ""); + dn = get_serialization_file_name (h, GNUNET_FS_SYNC_PATH_MASTER_PUBLISH, ""); if (dn == NULL) return; GNUNET_DISK_directory_scan (dn, &deserialize_publish_file, h); @@ -1786,7 +1789,7 @@ deserialize_unindex_file (void *cls, GNUNET_free (emsg); } if (uc->serialization != NULL) - GNUNET_FS_remove_sync_file_ (h, "unindex", uc->serialization); + GNUNET_FS_remove_sync_file_ (h, GNUNET_FS_SYNC_PATH_MASTER_UNINDEX, uc->serialization); GNUNET_free_non_null (uc->serialization); GNUNET_free (uc); return GNUNET_OK; @@ -1803,7 +1806,7 @@ deserialize_unindex (struct GNUNET_FS_Handle *h) { char *dn; - dn = get_serialization_file_name (h, "unindex", ""); + dn = get_serialization_file_name (h, GNUNET_FS_SYNC_PATH_MASTER_UNINDEX, ""); if (dn == NULL) return; GNUNET_DISK_directory_scan (dn, &deserialize_unindex_file, h); @@ -1859,7 +1862,7 @@ deserialize_search_result (void *cls, GNUNET_snprintf (pbuf, sizeof (pbuf), "%s%s%s", - "search-results", + GNUNET_FS_SYNC_PATH_SEARCH_RESULT, DIR_SEPARATOR_STR, sc->serialization); GNUNET_FS_remove_sync_file_ (sc->h, pbuf, ser); @@ -1894,7 +1897,7 @@ deserialize_search_result (void *cls, if (download != NULL) { drh = get_read_handle (sc->h, - "subdownloads", + GNUNET_FS_SYNC_PATH_CHILD_DOWNLOAD, download); deserialize_download (sc->h, drh, @@ -2044,7 +2047,7 @@ free_search_context (struct GNUNET_FS_SearchContext *sc) } GNUNET_free_non_null (sc->emsg); if (sc->serialization != NULL) - GNUNET_FS_remove_sync_file_ (sc->h, "search", sc->serialization); + GNUNET_FS_remove_sync_file_ (sc->h, GNUNET_FS_SYNC_PATH_MASTER_SEARCH, sc->serialization); /* FIXME: remove 'pbuf' directory with search results as well! */ GNUNET_free_non_null (sc->serialization); if (sc->uri != NULL) @@ -2227,7 +2230,7 @@ deserialize_download (struct GNUNET_FS_Handle *h, GNUNET_snprintf (pbuf, sizeof (pbuf), "%s%s%s", - "subdownloads", + GNUNET_FS_SYNC_PATH_CHILD_DOWNLOAD, DIR_SEPARATOR_STR, dc->serialization); dn = get_serialization_file_name (h, pbuf, ""); @@ -2333,7 +2336,7 @@ deserialize_search (struct GNUNET_FS_Handle *h, GNUNET_snprintf (pbuf, sizeof (pbuf), "%s%s%s", - "search-results", + GNUNET_FS_SYNC_PATH_SEARCH_RESULT, DIR_SEPARATOR_STR, sc->serialization); dn = get_serialization_file_name (h, pbuf, ""); @@ -2356,7 +2359,7 @@ deserialize_search (struct GNUNET_FS_Handle *h, goto cleanup; if (child_ser == NULL) break; - rhc = get_read_handle (h, "search-children", child_ser); + rhc = get_read_handle (h, GNUNET_FS_SYNC_PATH_CHILD_SEARCH, child_ser); if (rhc != NULL) { scc = deserialize_search (h, rhc, sc, child_ser); @@ -2419,7 +2422,7 @@ deserialize_search_file (void *cls, { if (ser != NULL) { - GNUNET_FS_remove_sync_file_ (h, "search", ser); + GNUNET_FS_remove_sync_file_ (h, GNUNET_FS_SYNC_PATH_MASTER_SEARCH, ser); GNUNET_free (ser); } return GNUNET_OK; @@ -2449,7 +2452,7 @@ deserialize_search_master (struct GNUNET_FS_Handle *h) { char *dn; - dn = get_serialization_file_name (h, "search", ""); + dn = get_serialization_file_name (h, GNUNET_FS_SYNC_PATH_MASTER_SEARCH, ""); if (dn == NULL) return; GNUNET_DISK_directory_scan (dn, &deserialize_search_file, h); @@ -2513,7 +2516,7 @@ deserialize_download_master (struct GNUNET_FS_Handle *h) { char *dn; - dn = get_serialization_file_name (h, "download", ""); + dn = get_serialization_file_name (h, GNUNET_FS_SYNC_PATH_MASTER_DOWNLOAD, ""); if (dn == NULL) return; GNUNET_DISK_directory_scan (dn, &deserialize_download_file, h); @@ -2543,22 +2546,15 @@ GNUNET_FS_start (struct GNUNET_SCHEDULER_Handle *sched, ...) { struct GNUNET_FS_Handle *ret; - struct GNUNET_CLIENT_Connection *client; enum GNUNET_FS_OPTIONS opt; va_list ap; - client = GNUNET_CLIENT_connect (sched, - "fs", - cfg); - if (NULL == client) - return NULL; ret = GNUNET_malloc (sizeof (struct GNUNET_FS_Handle)); ret->sched = sched; ret->cfg = cfg; ret->client_name = GNUNET_strdup (client_name); ret->upcb = upcb; ret->upcb_cls = upcb_cls; - ret->client = client; ret->flags = flags; ret->max_parallel_downloads = 1; ret->max_parallel_requests = 1; @@ -2583,7 +2579,6 @@ GNUNET_FS_start (struct GNUNET_SCHEDULER_Handle *sched, } } va_end (ap); - // FIXME: setup receive-loop with client (do we need one?) if (0 != (GNUNET_FS_FLAGS_PERSISTENCE & flags)) { /* FIXME: could write one generic deserialization @@ -2610,11 +2605,10 @@ GNUNET_FS_stop (struct GNUNET_FS_Handle *h) /* generate SUSPEND events and clean up state */ while (h->top_head != NULL) h->top_head->ssf (h->top_head->ssf_cls); - // FIXME: terminate receive-loop with client (do we need one?) + /* FIXME: terminate receive-loop with client (do we need one?) */ if (h->queue_job != GNUNET_SCHEDULER_NO_TASK) GNUNET_SCHEDULER_cancel (h->sched, h->queue_job); - GNUNET_CLIENT_disconnect (h->client, GNUNET_NO); GNUNET_free (h->client_name); GNUNET_free (h); } diff --git a/src/fs/fs.h b/src/fs/fs.h index 52fbee4c1..50c296979 100644 --- a/src/fs/fs.h +++ b/src/fs/fs.h @@ -151,6 +151,47 @@ */ #define IDLE_LOAD_THRESHOLD ((100 + GNUNET_CONSTANTS_IDLE_LOAD_THRESHOLD) / 2) +/** + * Name of the directory with top-level searches. + */ +#define GNUNET_FS_SYNC_PATH_MASTER_SEARCH "search" + +/** + * Name of the directory with sub-searches (namespace-updates). + */ +#define GNUNET_FS_SYNC_PATH_CHILD_SEARCH "search-child" + +/** + * Name of the directory with search results. + */ +#define GNUNET_FS_SYNC_PATH_SEARCH_RESULT "search-result" + +/** + * Name of the directory with master downloads (not associated + * with search or part of another download). + */ +#define GNUNET_FS_SYNC_PATH_MASTER_DOWNLOAD "download" + +/** + * Name of the directory with downloads that are part of another + * download or a search. + */ +#define GNUNET_FS_SYNC_PATH_CHILD_DOWNLOAD "download-child" + +/** + * Name of the directory with publishing operations. + */ +#define GNUNET_FS_SYNC_PATH_MASTER_PUBLISH "publish" + +/** + * Name of the directory with files that are being published + */ +#define GNUNET_FS_SYNC_PATH_FILE_INFO "publish-file" + +/** + * Name of the directory with unindex operations. + */ +#define GNUNET_FS_SYNC_PATH_MASTER_UNINDEX "unindex" /** @@ -1081,11 +1122,6 @@ struct GNUNET_FS_Handle */ void *upcb_cls; - /** - * Connection to the FS service. - */ - struct GNUNET_CLIENT_Connection *client; - /** * Head of DLL of top-level activities. */ diff --git a/src/fs/fs_download.c b/src/fs/fs_download.c index 8d5a936f0..8025ef408 100644 --- a/src/fs/fs_download.c +++ b/src/fs/fs_download.c @@ -1749,13 +1749,13 @@ GNUNET_FS_download_stop (struct GNUNET_FS_DownloadContext *dc, dc); if (dc->serialization != NULL) GNUNET_FS_remove_sync_file_ (dc->h, - (dc->parent != NULL) - ? "subdownloads" - : "download", + ( (dc->parent != NULL) || (dc->search != NULL) ) + ? GNUNET_FS_SYNC_PATH_CHILD_DOWNLOAD + : GNUNET_FS_SYNC_PATH_MASTER_DOWNLOAD , dc->serialization); if (GNUNET_YES == have_children) GNUNET_FS_remove_sync_dir_ (dc->h, - "subdownloads", + GNUNET_FS_SYNC_PATH_CHILD_DOWNLOAD, dc->serialization); pi.status = GNUNET_FS_STATUS_DOWNLOAD_STOPPED; GNUNET_FS_download_make_status_ (&pi, dc); diff --git a/src/fs/fs_publish.c b/src/fs/fs_publish.c index 8d2dacb14..ba2d09533 100644 --- a/src/fs/fs_publish.c +++ b/src/fs/fs_publish.c @@ -1149,7 +1149,7 @@ GNUNET_FS_publish_stop (struct GNUNET_FS_PublishContext *pc) } if (pc->serialization != NULL) { - GNUNET_FS_remove_sync_file_ (pc->h, "publish", pc->serialization); + GNUNET_FS_remove_sync_file_ (pc->h, GNUNET_FS_SYNC_PATH_MASTER_PUBLISH, pc->serialization); GNUNET_free (pc->serialization); pc->serialization = NULL; } diff --git a/src/fs/fs_search.c b/src/fs/fs_search.c index 8db9f115d..f36b46a16 100644 --- a/src/fs/fs_search.c +++ b/src/fs/fs_search.c @@ -24,7 +24,6 @@ * @author Christian Grothoff * * TODO: - * - remove *directory* with search results upon completion * - centralize code that sprintf's the 'pbuf[32]' strings * - add support for pushing "already seen" information * to FS service for bloomfilter (can wait) @@ -38,8 +37,6 @@ #define DEBUG_SEARCH GNUNET_NO - - /** * Fill in all of the generic fields for a search event and * call the callback. @@ -527,8 +524,7 @@ process_sks_result (struct GNUNET_FS_SearchContext *sc, uu.type = sks; uu.data.sks.namespace = sc->uri->data.sks.namespace; uu.data.sks.identifier = GNUNET_strdup (id_update); - /* FIXME: should attach update search - to the individual result, not + /* FIXME: should attach update search to the individual result, not the entire SKS search! */ search_start (sc->h, &uu, @@ -956,6 +952,9 @@ transmit_search_request (void *cls, sm[i].type = htonl (GNUNET_BLOCK_TYPE_ANY); sm[i].anonymity_level = htonl (sc->anonymity); sm[i].query = sc->requests[i].query; + /* FIXME: should transmit hash codes of all already-known results here! + (and if they do not fit, add another message with the same + header and additional already-seen results!) */ } } else @@ -984,6 +983,9 @@ transmit_search_request (void *cls, GNUNET_CRYPTO_hash_xor (&idh, &sm->target, &sm->query); + /* FIXME: should transmit hash codes of all already-known results here! + (and if they do not fit, add another message with the same + header and additional already-seen results!) */ } GNUNET_CLIENT_receive (sc->client, &receive_results, @@ -1177,6 +1179,57 @@ GNUNET_FS_search_start_searching_ (struct GNUNET_FS_SearchContext *sc) } +/** + * Freeze probes for the given search result. + * + * @param cls the global FS handle + * @param key the key for the search result (unused) + * @param value the search result to free + * @return GNUNET_OK + */ +static int +search_result_freeze_probes (void *cls, + const GNUNET_HashCode * key, + void *value) +{ + struct GNUNET_FS_SearchContext *sc = cls; + struct GNUNET_FS_Handle *h = sc->h; + struct GNUNET_FS_SearchResult *sr = value; + + if (sr->probe_ctx != NULL) + { + GNUNET_FS_download_stop (sr->probe_ctx, GNUNET_YES); + sr->probe_ctx = NULL; + } + if (sr->probe_cancel_task != GNUNET_SCHEDULER_NO_TASK) + { + GNUNET_SCHEDULER_cancel (h->sched, + sr->probe_cancel_task); + sr->probe_cancel_task = GNUNET_SCHEDULER_NO_TASK; + } + return GNUNET_OK; +} + + +/** + * Resume probes for the given search result. + * + * @param cls the global FS handle + * @param key the key for the search result (unused) + * @param value the search result to free + * @return GNUNET_OK + */ +static int +search_result_resume_probes (void *cls, + const GNUNET_HashCode * key, + void *value) +{ + struct GNUNET_FS_SearchResult *sr = value; + + GNUNET_FS_search_start_probe_ (sr); + return GNUNET_OK; +} + /** * Signal suspend and free the given search result. @@ -1309,7 +1362,9 @@ GNUNET_FS_search_pause (struct GNUNET_FS_SearchContext *sc) GNUNET_CLIENT_disconnect (sc->client, GNUNET_NO); sc->client = NULL; GNUNET_FS_search_sync_ (sc); - // FIXME: should this freeze all active probes? + GNUNET_CONTAINER_multihashmap_iterate (sc->master_result_map, + &search_result_freeze_probes, + sc); pi.status = GNUNET_FS_STATUS_SEARCH_PAUSED; sc->client_info = GNUNET_FS_search_make_status_ (&pi, sc); } @@ -1331,6 +1386,9 @@ GNUNET_FS_search_continue (struct GNUNET_FS_SearchContext *sc) GNUNET_FS_search_sync_ (sc); pi.status = GNUNET_FS_STATUS_SEARCH_CONTINUED; sc->client_info = GNUNET_FS_search_make_status_ (&pi, sc); + GNUNET_CONTAINER_multihashmap_iterate (sc->master_result_map, + &search_result_resume_probes, + sc); } @@ -1356,10 +1414,18 @@ search_result_free (void *cls, if (NULL != sr->download) { sr->download->search = NULL; + if (NULL != sr->download->serialization) + { + GNUNET_FS_remove_sync_file_ (sc->h, + GNUNET_FS_SYNC_PATH_CHILD_DOWNLOAD, + sr->download->serialization); + GNUNET_free (sr->download->serialization); + sr->download->serialization = NULL; + } pi.status = GNUNET_FS_STATUS_DOWNLOAD_LOST_PARENT; GNUNET_FS_download_make_status_ (&pi, - sr->download); - /* FIXME: promote download to top-level! */ + sr->download); + GNUNET_FS_download_sync_ (sr->download); sr->download = NULL; } pi.status = GNUNET_FS_STATUS_SEARCH_RESULT_STOPPED; @@ -1373,7 +1439,7 @@ search_result_free (void *cls, GNUNET_snprintf (pbuf, sizeof (pbuf), "%s%s%s", - "search-results", + GNUNET_FS_SYNC_PATH_SEARCH_RESULT, DIR_SEPARATOR_STR, sc->serialization); GNUNET_FS_remove_sync_file_ (sc->h, @@ -1410,7 +1476,9 @@ GNUNET_FS_search_stop (struct GNUNET_FS_SearchContext *sc) GNUNET_FS_end_top (sc->h, sc->top); if (sc->serialization != NULL) GNUNET_FS_remove_sync_file_ (sc->h, - (sc->parent != NULL) ? "search-children" : "search", + (sc->parent != NULL) + ? GNUNET_FS_SYNC_PATH_CHILD_SEARCH + : GNUNET_FS_SYNC_PATH_MASTER_SEARCH, sc->serialization); if (NULL != (parent = sc->parent)) { @@ -1426,7 +1494,9 @@ GNUNET_FS_search_stop (struct GNUNET_FS_SearchContext *sc) &search_result_free, sc); if (had_result) - GNUNET_FS_remove_sync_dir_ (sc->h, "search-results", sc->serialization); + GNUNET_FS_remove_sync_dir_ (sc->h, + GNUNET_FS_SYNC_PATH_SEARCH_RESULT, + sc->serialization); pi.status = GNUNET_FS_STATUS_SEARCH_STOPPED; sc->client_info = GNUNET_FS_search_make_status_ (&pi, sc); GNUNET_break (NULL == sc->client_info); diff --git a/src/fs/fs_unindex.c b/src/fs/fs_unindex.c index 9d14bb0cb..d53683dac 100644 --- a/src/fs/fs_unindex.c +++ b/src/fs/fs_unindex.c @@ -487,7 +487,7 @@ GNUNET_FS_unindex_stop (struct GNUNET_FS_UnindexContext *uc) } if (uc->serialization != NULL) { - GNUNET_FS_remove_sync_file_ (uc->h, "unindex", uc->serialization); + GNUNET_FS_remove_sync_file_ (uc->h, GNUNET_FS_SYNC_PATH_MASTER_UNINDEX, uc->serialization); GNUNET_free (uc->serialization); uc->serialization = NULL; } -- 2.25.1