From: Christian Grothoff Date: Thu, 6 May 2010 06:57:16 +0000 (+0000) Subject: init top on deserialization X-Git-Tag: initial-import-from-subversion-38251~21871 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=6ebc869359633883f576a9f23e6ddf6b698eec14;p=oweals%2Fgnunet.git init top on deserialization --- diff --git a/src/fs/fs.c b/src/fs/fs.c index 00948916e..aa41f6855 100644 --- a/src/fs/fs.c +++ b/src/fs/fs.c @@ -749,6 +749,7 @@ deserialize_fi_node (struct GNUNET_FS_Handle *h, return NULL; } ret = GNUNET_malloc (sizeof (struct GNUNET_FS_FileInformation)); + ret->h = h; ksks = NULL; chks = NULL; filename = NULL; @@ -1382,6 +1383,7 @@ deserialize_publish_file (void *cls, GNUNET_free (emsg); } GNUNET_free_non_null (ns); + pc->top = GNUNET_FS_make_top (h, &GNUNET_FS_publish_signal_suspend_, pc); return GNUNET_OK; cleanup: GNUNET_free_non_null (pc->nid); @@ -1914,6 +1916,9 @@ deserialize_unindex_file (void *cls, GNUNET_break (0); goto cleanup; } + uc->top = GNUNET_FS_make_top (h, + &GNUNET_FS_unindex_signal_suspend_, + uc); pi.status = GNUNET_FS_STATUS_UNINDEX_RESUME; pi.value.unindex.specifics.resume.message = uc->emsg; GNUNET_FS_unindex_make_status_ (&pi, @@ -2468,7 +2473,12 @@ deserialize_download (struct GNUNET_FS_Handle *h, dc->search = search; search->download = dc; } - signal_download_resume (dc); + if ( (parent == NULL) || + (search == NULL) ) + dc->top = GNUNET_FS_make_top (dc->h, + &GNUNET_FS_download_signal_suspend_, + dc); + signal_download_resume (dc); GNUNET_free (uris); return; cleanup: @@ -2604,6 +2614,7 @@ deserialize_search_file (void *cls, char *ser; char *emsg; struct GNUNET_BIO_ReadHandle *rh; + struct GNUNET_FS_SearchContext *sc; ser = get_serialization_short_name (filename); rh = GNUNET_BIO_read_open (filename); @@ -2616,7 +2627,8 @@ deserialize_search_file (void *cls, } return GNUNET_OK; } - (void) deserialize_search (h, rh, NULL, ser); + sc = deserialize_search (h, rh, NULL, ser); + sc->top = GNUNET_FS_make_top (h, &GNUNET_FS_search_signal_suspend_, sc); GNUNET_free (ser); if (GNUNET_OK != GNUNET_BIO_read_close (rh, &emsg)) diff --git a/src/fs/fs.h b/src/fs/fs.h index d7dcd987d..d8e997324 100644 --- a/src/fs/fs.h +++ b/src/fs/fs.h @@ -1018,6 +1018,41 @@ GNUNET_FS_search_result_sync_ (struct GNUNET_FS_SearchResult *sr); void GNUNET_FS_download_sync_ (struct GNUNET_FS_DownloadContext *dc); +/** + * Create SUSPEND event for the given publish operation + * and then clean up our state (without stop signal). + * + * @param cls the 'struct GNUNET_FS_PublishContext' to signal for + */ +void +GNUNET_FS_publish_signal_suspend_ (void *cls); + +/** + * Create SUSPEND event for the given search operation + * and then clean up our state (without stop signal). + * + * @param cls the 'struct GNUNET_FS_SearchContext' to signal for + */ +void +GNUNET_FS_search_signal_suspend_ (void *cls); + +/** + * Create SUSPEND event for the given download operation + * and then clean up our state (without stop signal). + * + * @param cls the 'struct GNUNET_FS_DownloadContext' to signal for + */ +void +GNUNET_FS_download_signal_suspend_ (void *cls); + +/** + * Create SUSPEND event for the given unindex operation + * and then clean up our state (without stop signal). + * + * @param cls the 'struct GNUNET_FS_UnindexContext' to signal for + */ +void +GNUNET_FS_unindex_signal_suspend_ (void *cls); /** * Function signature of the functions that can be called @@ -1081,15 +1116,6 @@ GNUNET_FS_end_top (struct GNUNET_FS_Handle *h, struct TopLevelActivity *top); -/** - * Create SUSPEND event for the given download operation - * and then clean up our state (without stop signal). - * - * @param cls the 'struct GNUNET_FS_DownloadContext' to signal for - */ -void -GNUNET_FS_download_signal_suspend_ (void *cls); - /** * Master context for most FS operations. diff --git a/src/fs/fs_download.c b/src/fs/fs_download.c index 6000130c0..473260601 100644 --- a/src/fs/fs_download.c +++ b/src/fs/fs_download.c @@ -1558,6 +1558,10 @@ GNUNET_FS_download_start (struct GNUNET_FS_Handle *h, "Download tree has depth %u\n", dc->treedepth); #endif + if (parent == NULL) + dc->top = GNUNET_FS_make_top (dc->h, + &GNUNET_FS_download_signal_suspend_, + dc); pi.status = GNUNET_FS_STATUS_DOWNLOAD_START; pi.value.download.specifics.start.meta = meta; GNUNET_FS_download_make_status_ (&pi, dc); @@ -1567,11 +1571,6 @@ GNUNET_FS_download_start (struct GNUNET_FS_Handle *h, 1 /* 0 == CHK, 1 == top */); GNUNET_FS_download_sync_ (dc); GNUNET_FS_download_start_downloading_ (dc); - if (parent == NULL) - dc->top = GNUNET_FS_make_top (dc->h, - &GNUNET_FS_download_signal_suspend_, - dc); - return dc; } diff --git a/src/fs/fs_publish.c b/src/fs/fs_publish.c index 6364dac0a..0ca7cef2d 100644 --- a/src/fs/fs_publish.c +++ b/src/fs/fs_publish.c @@ -797,19 +797,19 @@ void GNUNET_FS_publish_main_ (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { - struct GNUNET_FS_PublishContext *sc = cls; + struct GNUNET_FS_PublishContext *pc = cls; struct GNUNET_FS_ProgressInfo pi; struct GNUNET_FS_FileInformation *p; char *fn; - sc->upload_task = GNUNET_SCHEDULER_NO_TASK; - p = sc->fi_pos; + pc->upload_task = GNUNET_SCHEDULER_NO_TASK; + p = pc->fi_pos; if (NULL == p) { /* upload of entire hierarchy complete, publish namespace entries */ - GNUNET_FS_publish_sync_ (sc); - publish_sblock (sc); + GNUNET_FS_publish_sync_ (pc); + publish_sblock (pc); return; } /* find starting position */ @@ -819,8 +819,8 @@ GNUNET_FS_publish_main_ (void *cls, (NULL == p->data.dir.entries->chk_uri) ) { p = p->data.dir.entries; - sc->fi_pos = p; - GNUNET_FS_publish_sync_ (sc); + pc->fi_pos = p; + GNUNET_FS_publish_sync_ (pc); } /* abort on error */ if (NULL != p->emsg) @@ -849,33 +849,33 @@ GNUNET_FS_publish_main_ (void *cls, pi.status = GNUNET_FS_STATUS_PUBLISH_ERROR; pi.value.publish.eta = GNUNET_TIME_UNIT_FOREVER_REL; pi.value.publish.specifics.error.message = p->emsg; - p->client_info = GNUNET_FS_publish_make_status_ (&pi, sc, p, 0); + p->client_info = GNUNET_FS_publish_make_status_ (&pi, pc, p, 0); } - sc->all_done = GNUNET_YES; - GNUNET_FS_publish_sync_ (sc); + pc->all_done = GNUNET_YES; + GNUNET_FS_publish_sync_ (pc); return; } /* handle completion */ if (NULL != p->chk_uri) { - GNUNET_FS_publish_sync_ (sc); + GNUNET_FS_publish_sync_ (pc); /* upload of "p" complete, publish KBlocks! */ if (p->keywords != NULL) { - GNUNET_FS_publish_ksk (sc->h, + GNUNET_FS_publish_ksk (pc->h, p->keywords, p->meta, p->chk_uri, p->expirationTime, p->anonymity, p->priority, - sc->options, + pc->options, &publish_kblocks_cont, - sc); + pc); } else { - publish_kblocks_cont (sc, + publish_kblocks_cont (pc, p->chk_uri, NULL); } @@ -892,27 +892,27 @@ GNUNET_FS_publish_main_ (void *cls, "", _("needs to be an actual file")); GNUNET_FS_file_information_sync_ (p); - publish_content (sc); + publish_content (pc); return; } if (p->data.file.have_hash) { - hash_for_index_cb (sc, + hash_for_index_cb (pc, &p->data.file.file_id); } else { p->start_time = GNUNET_TIME_absolute_get (); - GNUNET_CRYPTO_hash_file (sc->h->sched, + GNUNET_CRYPTO_hash_file (pc->h->sched, GNUNET_SCHEDULER_PRIORITY_IDLE, p->filename, HASHING_BLOCKSIZE, &hash_for_index_cb, - sc); + pc); } return; } - publish_content (sc); + publish_content (pc); } @@ -998,8 +998,8 @@ fip_signal_suspend(void *cls, * * @param cls the 'struct GNUNET_FS_PublishContext' to signal for */ -static void -publish_signal_suspend (void *cls) +void +GNUNET_FS_publish_signal_suspend_ (void *cls) { struct GNUNET_FS_PublishContext *pc = cls; @@ -1068,7 +1068,7 @@ GNUNET_FS_publish_start (struct GNUNET_FS_Handle *h, &fip_signal_start, ret); ret->fi_pos = ret->fi; - ret->top = GNUNET_FS_make_top (h, &publish_signal_suspend, ret); + ret->top = GNUNET_FS_make_top (h, &GNUNET_FS_publish_signal_suspend_, ret); GNUNET_FS_publish_sync_ (ret); // FIXME: calculate space needed for "fi" // and reserve as first task (then trigger diff --git a/src/fs/fs_search.c b/src/fs/fs_search.c index 9f62e04b1..171eebf4b 100644 --- a/src/fs/fs_search.c +++ b/src/fs/fs_search.c @@ -1232,16 +1232,6 @@ search_result_resume_probes (void *cls, } -/** - * Create SUSPEND event for the given search operation - * and then clean up our state (without stop signal). - * - * @param cls the 'struct GNUNET_FS_SearchContext' to signal for - */ -static void -search_signal_suspend (void *cls); - - /** * Signal suspend and free the given search result. * @@ -1263,7 +1253,7 @@ search_result_suspend (void *cls, if (sr->download != NULL) GNUNET_FS_download_signal_suspend_ (sr->download); if (sr->update_search != NULL) - search_signal_suspend (sr->update_search); + GNUNET_FS_search_signal_suspend_ (sr->update_search); pi.status = GNUNET_FS_STATUS_SEARCH_RESULT_SUSPEND; pi.value.search.specifics.result_suspend.cctx = sr->client_info; pi.value.search.specifics.result_suspend.meta = sr->meta; @@ -1289,8 +1279,8 @@ search_result_suspend (void *cls, * * @param cls the 'struct GNUNET_FS_SearchContext' to signal for */ -static void -search_signal_suspend (void *cls) +void +GNUNET_FS_search_signal_suspend_ (void *cls) { struct GNUNET_FS_SearchContext *sc = cls; struct GNUNET_FS_ProgressInfo pi; @@ -1342,7 +1332,7 @@ GNUNET_FS_search_start (struct GNUNET_FS_Handle *h, { struct GNUNET_FS_SearchContext *ret; ret = search_start (h, uri, anonymity, options, cctx, NULL); - ret->top = GNUNET_FS_make_top (h, &search_signal_suspend, ret); + ret->top = GNUNET_FS_make_top (h, &GNUNET_FS_search_signal_suspend_, ret); return ret; } diff --git a/src/fs/fs_unindex.c b/src/fs/fs_unindex.c index d422546ca..5989fd2c0 100644 --- a/src/fs/fs_unindex.c +++ b/src/fs/fs_unindex.c @@ -404,8 +404,8 @@ GNUNET_FS_unindex_process_hash_ (void *cls, * * @param cls the 'struct GNUNET_FS_UnindexContext' to signal for */ -static void -unindex_signal_suspend (void *cls) +void +GNUNET_FS_unindex_signal_suspend_ (void *cls) { struct GNUNET_FS_UnindexContext *uc = cls; struct GNUNET_FS_ProgressInfo pi; @@ -462,7 +462,7 @@ GNUNET_FS_unindex_start (struct GNUNET_FS_Handle *h, &GNUNET_FS_unindex_process_hash_, ret); ret->top = GNUNET_FS_make_top (h, - &unindex_signal_suspend, + &GNUNET_FS_unindex_signal_suspend_, ret); return ret; }