aboutsummaryrefslogtreecommitdiff
path: root/src/fs/fs_publish.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2013-09-15 18:23:27 +0000
committerChristian Grothoff <christian@grothoff.org>2013-09-15 18:23:27 +0000
commit8b20ea06fdb75740cead194d5c6826b4233ec500 (patch)
treeb96b67ef0785a2bf9f1db49cee82e8cc5da4843e /src/fs/fs_publish.c
parent34f5392dc97d411d437c963af3a6a8ade2529306 (diff)
downloadgnunet-8b20ea06fdb75740cead194d5c6826b4233ec500.tar.gz
gnunet-8b20ea06fdb75740cead194d5c6826b4233ec500.zip
-doxygen fixes, and fixing publish URI serization for proper resume
Diffstat (limited to 'src/fs/fs_publish.c')
-rw-r--r--src/fs/fs_publish.c77
1 files changed, 45 insertions, 32 deletions
diff --git a/src/fs/fs_publish.c b/src/fs/fs_publish.c
index 73af99ce9..224f0c35e 100644
--- a/src/fs/fs_publish.c
+++ b/src/fs/fs_publish.c
@@ -213,7 +213,8 @@ finish_release_reserve (void *cls, int success,
213 struct GNUNET_FS_PublishContext *pc = cls; 213 struct GNUNET_FS_PublishContext *pc = cls;
214 214
215 pc->qre = NULL; 215 pc->qre = NULL;
216 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Releasing reserve done!\n"); 216 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
217 "Releasing reserve done!\n");
217 signal_publish_completion (pc->fi, pc); 218 signal_publish_completion (pc->fi, pc);
218 pc->all_done = GNUNET_YES; 219 pc->all_done = GNUNET_YES;
219 GNUNET_FS_publish_sync_ (pc); 220 GNUNET_FS_publish_sync_ (pc);
@@ -299,7 +300,8 @@ publish_kblocks_cont (void *cls, const struct GNUNET_FS_Uri *uri,
299 pc->ksk_pc = NULL; 300 pc->ksk_pc = NULL;
300 if (NULL != emsg) 301 if (NULL != emsg)
301 { 302 {
302 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Error uploading KSK blocks: %s\n", 303 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
304 "Error uploading KSK blocks: %s\n",
303 emsg); 305 emsg);
304 signal_publish_error (p, pc, emsg); 306 signal_publish_error (p, pc, emsg);
305 GNUNET_FS_file_information_sync_ (p); 307 GNUNET_FS_file_information_sync_ (p);
@@ -396,15 +398,21 @@ encode_cont (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
396 char *emsg; 398 char *emsg;
397 uint64_t flen; 399 uint64_t flen;
398 400
399 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Finished with tree encoder\n"); 401 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
402 "Finished with tree encoder\n");
400 p = pc->fi_pos; 403 p = pc->fi_pos;
404 p->chk_uri = GNUNET_FS_tree_encoder_get_uri (p->te);
401 GNUNET_FS_file_information_sync_ (p); 405 GNUNET_FS_file_information_sync_ (p);
402 GNUNET_FS_tree_encoder_finish (p->te, &p->chk_uri, &emsg); 406 GNUNET_FS_tree_encoder_finish (p->te, &emsg);
403 p->te = NULL; 407 p->te = NULL;
404 if (NULL != emsg) 408 if (NULL != emsg)
405 { 409 {
406 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Error during tree walk: %s\n", emsg); 410 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
407 GNUNET_asprintf (&p->emsg, _("Publishing failed: %s"), emsg); 411 "Error during tree walk: %s\n",
412 emsg);
413 GNUNET_asprintf (&p->emsg,
414 _("Publishing failed: %s"),
415 emsg);
408 GNUNET_free (emsg); 416 GNUNET_free (emsg);
409 pi.status = GNUNET_FS_STATUS_PUBLISH_ERROR; 417 pi.status = GNUNET_FS_STATUS_PUBLISH_ERROR;
410 pi.value.publish.eta = GNUNET_TIME_UNIT_FOREVER_REL; 418 pi.value.publish.eta = GNUNET_TIME_UNIT_FOREVER_REL;
@@ -434,8 +442,8 @@ encode_cont (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
434/** 442/**
435 * Function called asking for the current (encoded) 443 * Function called asking for the current (encoded)
436 * block to be processed. After processing the 444 * block to be processed. After processing the
437 * client should either call "GNUNET_FS_tree_encode_next" 445 * client should either call #GNUNET_FS_tree_encode_next
438 * or (on error) "GNUNET_FS_tree_encode_finish". 446 * or (on error) #GNUNET_FS_tree_encode_finish.
439 * 447 *
440 * @param cls closure 448 * @param cls closure
441 * @param chk content hash key for the block 449 * @param chk content hash key for the block
@@ -465,8 +473,9 @@ block_proc (void *cls, const struct ContentHashKey *chk, uint64_t offset,
465 return; 473 return;
466 } 474 }
467 475
468 if ((p->is_directory != GNUNET_YES) && (GNUNET_YES == p->data.file.do_index) && 476 if ( (GNUNET_YES != p->is_directory) &&
469 (type == GNUNET_BLOCK_TYPE_FS_DBLOCK)) 477 (GNUNET_YES == p->data.file.do_index) &&
478 (GNUNET_BLOCK_TYPE_FS_DBLOCK == type) )
470 { 479 {
471 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 480 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
472 "Indexing block `%s' for offset %llu with index size %u\n", 481 "Indexing block `%s' for offset %llu with index size %u\n",
@@ -546,17 +555,17 @@ publish_content (struct GNUNET_FS_PublishContext *pc)
546 uint64_t size; 555 uint64_t size;
547 556
548 p = pc->fi_pos; 557 p = pc->fi_pos;
549 GNUNET_assert (p != NULL); 558 GNUNET_assert (NULL != p);
550 if (NULL == p->te) 559 if (NULL == p->te)
551 { 560 {
552 if (p->is_directory == GNUNET_YES) 561 if (GNUNET_YES == p->is_directory)
553 { 562 {
554 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Creating directory\n"); 563 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Creating directory\n");
555 db = GNUNET_FS_directory_builder_create (p->meta); 564 db = GNUNET_FS_directory_builder_create (p->meta);
556 dirpos = p->data.dir.entries; 565 dirpos = p->data.dir.entries;
557 while (NULL != dirpos) 566 while (NULL != dirpos)
558 { 567 {
559 if (dirpos->is_directory == GNUNET_YES) 568 if (GNUNET_YES == dirpos->is_directory)
560 { 569 {
561 raw_data = dirpos->data.dir.dir_data; 570 raw_data = dirpos->data.dir.dir_data;
562 dirpos->data.dir.dir_data = NULL; 571 dirpos->data.dir.dir_data = NULL;
@@ -593,15 +602,17 @@ publish_content (struct GNUNET_FS_PublishContext *pc)
593 &p->data.dir.dir_data); 602 &p->data.dir.dir_data);
594 GNUNET_FS_file_information_sync_ (p); 603 GNUNET_FS_file_information_sync_ (p);
595 } 604 }
596 size = (p->is_directory == GNUNET_YES) ? p->data.dir.dir_size : p->data.file.file_size; 605 size = (GNUNET_YES == p->is_directory) ? p->data.dir.dir_size : p->data.file.file_size;
597 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Creating tree encoder\n"); 606 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
607 "Creating tree encoder\n");
598 p->te = 608 p->te =
599 GNUNET_FS_tree_encoder_create (pc->h, size, pc, &block_reader, 609 GNUNET_FS_tree_encoder_create (pc->h, size, pc, &block_reader,
600 &block_proc, &progress_proc, 610 &block_proc, &progress_proc,
601 &encode_cont); 611 &encode_cont);
602 612
603 } 613 }
604 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Processing next block from tree\n"); 614 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
615 "Processing next block from tree\n");
605 GNUNET_FS_tree_encoder_next (p->te); 616 GNUNET_FS_tree_encoder_next (p->te);
606} 617}
607 618
@@ -625,11 +636,10 @@ process_index_start_response (void *cls,
625 GNUNET_CLIENT_disconnect (pc->client); 636 GNUNET_CLIENT_disconnect (pc->client);
626 pc->client = NULL; 637 pc->client = NULL;
627 p = pc->fi_pos; 638 p = pc->fi_pos;
628 if (msg == NULL) 639 if (NULL == msg)
629 { 640 {
630 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 641 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
631 _ 642 _("Can not index file `%s': %s. Will try to insert instead.\n"),
632 ("Can not index file `%s': %s. Will try to insert instead.\n"),
633 p->filename, 643 p->filename,
634 _("timeout on index-start request to `fs' service")); 644 _("timeout on index-start request to `fs' service"));
635 p->data.file.do_index = GNUNET_NO; 645 p->data.file.do_index = GNUNET_NO;
@@ -685,9 +695,9 @@ hash_for_index_cb (void *cls,
685 if (NULL == res) 695 if (NULL == res)
686 { 696 {
687 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 697 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
688 _ 698 _("Can not index file `%s': %s. Will try to insert instead.\n"),
689 ("Can not index file `%s': %s. Will try to insert instead.\n"), 699 p->filename,
690 p->filename, _("failed to compute hash")); 700 _("failed to compute hash"));
691 p->data.file.do_index = GNUNET_NO; 701 p->data.file.do_index = GNUNET_NO;
692 GNUNET_FS_file_information_sync_ (p); 702 GNUNET_FS_file_information_sync_ (p);
693 publish_content (pc); 703 publish_content (pc);
@@ -730,9 +740,9 @@ hash_for_index_cb (void *cls,
730 if (NULL == client) 740 if (NULL == client)
731 { 741 {
732 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 742 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
733 _ 743 _("Can not index file `%s': %s. Will try to insert instead.\n"),
734 ("Can not index file `%s': %s. Will try to insert instead.\n"), 744 p->filename,
735 p->filename, _("could not connect to `fs' service")); 745 _("could not connect to `fs' service"));
736 p->data.file.do_index = GNUNET_NO; 746 p->data.file.do_index = GNUNET_NO;
737 publish_content (pc); 747 publish_content (pc);
738 GNUNET_free (fn); 748 GNUNET_free (fn);
@@ -854,10 +864,11 @@ GNUNET_FS_publish_main_ (void *cls,
854 p->bo.expiration_time); 864 p->bo.expiration_time);
855 GNUNET_FS_uri_destroy (p->chk_uri); 865 GNUNET_FS_uri_destroy (p->chk_uri);
856 p->chk_uri = loc; 866 p->chk_uri = loc;
867 GNUNET_FS_file_information_sync_ (p);
857 } 868 }
858 GNUNET_FS_publish_sync_ (pc); 869 GNUNET_FS_publish_sync_ (pc);
859 /* upload of "p" complete, publish KBlocks! */ 870 /* upload of "p" complete, publish KBlocks! */
860 if (p->keywords != NULL) 871 if (NULL != p->keywords)
861 { 872 {
862 pc->ksk_pc = GNUNET_FS_publish_ksk (pc->h, p->keywords, p->meta, p->chk_uri, &p->bo, 873 pc->ksk_pc = GNUNET_FS_publish_ksk (pc->h, p->keywords, p->meta, p->chk_uri, &p->bo,
863 pc->options, &publish_kblocks_cont, pc); 874 pc->options, &publish_kblocks_cont, pc);
@@ -868,7 +879,7 @@ GNUNET_FS_publish_main_ (void *cls,
868 } 879 }
869 return; 880 return;
870 } 881 }
871 if ((p->is_directory != GNUNET_YES) && (p->data.file.do_index)) 882 if ((GNUNET_YES != p->is_directory) && (p->data.file.do_index))
872 { 883 {
873 if (NULL == p->filename) 884 if (NULL == p->filename)
874 { 885 {
@@ -932,7 +943,8 @@ fip_signal_start (void *cls,
932 pc->skip_next_fi_callback = GNUNET_NO; 943 pc->skip_next_fi_callback = GNUNET_NO;
933 return GNUNET_OK; 944 return GNUNET_OK;
934 } 945 }
935 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting publish operation\n"); 946 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
947 "Starting publish operation\n");
936 if (*do_index) 948 if (*do_index)
937 { 949 {
938 /* space for on-demand blocks */ 950 /* space for on-demand blocks */
@@ -1001,10 +1013,11 @@ suspend_operation (struct GNUNET_FS_FileInformation *fi,
1001 GNUNET_FS_publish_sks_cancel (pc->sks_pc); 1013 GNUNET_FS_publish_sks_cancel (pc->sks_pc);
1002 pc->sks_pc = NULL; 1014 pc->sks_pc = NULL;
1003 } 1015 }
1004 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Suspending publish operation\n"); 1016 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1017 "Suspending publish operation\n");
1005 GNUNET_free_non_null (fi->serialization); 1018 GNUNET_free_non_null (fi->serialization);
1006 fi->serialization = NULL; 1019 fi->serialization = NULL;
1007 off = (fi->chk_uri == NULL) ? 0 : (fi->is_directory == GNUNET_YES) ? fi->data.dir.dir_size : fi->data.file.file_size; 1020 off = (NULL == fi->chk_uri) ? 0 : (GNUNET_YES == fi->is_directory) ? fi->data.dir.dir_size : fi->data.file.file_size;
1008 pi.status = GNUNET_FS_STATUS_PUBLISH_SUSPEND; 1021 pi.status = GNUNET_FS_STATUS_PUBLISH_SUSPEND;
1009 GNUNET_break (NULL == GNUNET_FS_publish_make_status_ (&pi, pc, fi, off)); 1022 GNUNET_break (NULL == GNUNET_FS_publish_make_status_ (&pi, pc, fi, off));
1010 if (NULL != pc->qre) 1023 if (NULL != pc->qre)
@@ -1025,7 +1038,7 @@ suspend_operation (struct GNUNET_FS_FileInformation *fi,
1025 * Signal the FS's progress function that we are suspending 1038 * Signal the FS's progress function that we are suspending
1026 * an upload. Performs the recursion. 1039 * an upload. Performs the recursion.
1027 * 1040 *
1028 * @param cls closure (of type "struct GNUNET_FS_PublishContext*") 1041 * @param cls closure (of type `struct GNUNET_FS_PublishContext *`)
1029 * @param fi the entry in the publish-structure 1042 * @param fi the entry in the publish-structure
1030 * @param length length of the file or directory 1043 * @param length length of the file or directory
1031 * @param meta metadata for the file or directory (can be modified) 1044 * @param meta metadata for the file or directory (can be modified)
@@ -1068,7 +1081,7 @@ fip_signal_suspend (void *cls,
1068 * Create SUSPEND event for the given publish operation 1081 * Create SUSPEND event for the given publish operation
1069 * and then clean up our state (without stop signal). 1082 * and then clean up our state (without stop signal).
1070 * 1083 *
1071 * @param cls the 'struct GNUNET_FS_PublishContext' to signal for 1084 * @param cls the `struct GNUNET_FS_PublishContext` to signal for
1072 */ 1085 */
1073void 1086void
1074GNUNET_FS_publish_signal_suspend_ (void *cls) 1087GNUNET_FS_publish_signal_suspend_ (void *cls)