aboutsummaryrefslogtreecommitdiff
path: root/src/fs/fs_publish.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2013-09-14 13:51:27 +0000
committerChristian Grothoff <christian@grothoff.org>2013-09-14 13:51:27 +0000
commitc2882d0223530d1f2ac84f9675f23bda11270d08 (patch)
tree77c5a7973735a93e58e482d1a21ecd62bf6d08bf /src/fs/fs_publish.c
parente5ba359af49fac05185f5ec0b4dbb47c7060167a (diff)
downloadgnunet-c2882d0223530d1f2ac84f9675f23bda11270d08.tar.gz
gnunet-c2882d0223530d1f2ac84f9675f23bda11270d08.zip
-fixing #3034
Diffstat (limited to 'src/fs/fs_publish.c')
-rw-r--r--src/fs/fs_publish.c72
1 files changed, 43 insertions, 29 deletions
diff --git a/src/fs/fs_publish.c b/src/fs/fs_publish.c
index 9483ec36a..c554c8bb2 100644
--- a/src/fs/fs_publish.c
+++ b/src/fs/fs_publish.c
@@ -106,8 +106,8 @@ publish_cleanup (struct GNUNET_FS_PublishContext *pc)
106 * Function called by the datastore API with 106 * Function called by the datastore API with
107 * the result from the PUT request. 107 * the result from the PUT request.
108 * 108 *
109 * @param cls the 'struct GNUNET_FS_PublishContext' 109 * @param cls the `struct GNUNET_FS_PublishContext *`
110 * @param success GNUNET_OK on success 110 * @param success #GNUNET_OK on success
111 * @param min_expiration minimum expiration time required for content to be stored 111 * @param min_expiration minimum expiration time required for content to be stored
112 * @param msg error message (or NULL) 112 * @param msg error message (or NULL)
113 */ 113 */
@@ -200,7 +200,7 @@ signal_publish_error (struct GNUNET_FS_FileInformation *p,
200/** 200/**
201 * Datastore returns from reservation cancel request. 201 * Datastore returns from reservation cancel request.
202 * 202 *
203 * @param cls the 'struct GNUNET_FS_PublishContext' 203 * @param cls the `struct GNUNET_FS_PublishContext *`
204 * @param success success code (not used) 204 * @param success success code (not used)
205 * @param min_expiration minimum expiration time required for content to be stored 205 * @param min_expiration minimum expiration time required for content to be stored
206 * @param msg error message (typically NULL, not used) 206 * @param msg error message (typically NULL, not used)
@@ -284,7 +284,7 @@ publish_sblock (struct GNUNET_FS_PublishContext *pc)
284 * We've finished publishing a KBlock as part of a larger upload. 284 * We've finished publishing a KBlock as part of a larger upload.
285 * Check the result and continue the larger upload. 285 * Check the result and continue the larger upload.
286 * 286 *
287 * @param cls the "struct GNUNET_FS_PublishContext*" 287 * @param cls the `struct GNUNET_FS_PublishContext *`
288 * of the larger upload 288 * of the larger upload
289 * @param uri URI of the published blocks 289 * @param uri URI of the published blocks
290 * @param emsg NULL on success, otherwise error message 290 * @param emsg NULL on success, otherwise error message
@@ -399,6 +399,7 @@ encode_cont (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
399 399
400 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Finished with tree encoder\n"); 400 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Finished with tree encoder\n");
401 p = pc->fi_pos; 401 p = pc->fi_pos;
402 GNUNET_FS_file_information_sync_ (p);
402 GNUNET_FS_tree_encoder_finish (p->te, &p->chk_uri, &emsg); 403 GNUNET_FS_tree_encoder_finish (p->te, &p->chk_uri, &emsg);
403 p->te = NULL; 404 p->te = NULL;
404 if (NULL != emsg) 405 if (NULL != emsg)
@@ -423,8 +424,7 @@ encode_cont (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
423 pi.value.publish.specifics.progress.depth = GNUNET_FS_compute_depth (flen); 424 pi.value.publish.specifics.progress.depth = GNUNET_FS_compute_depth (flen);
424 p->client_info = GNUNET_FS_publish_make_status_ (&pi, pc, p, flen); 425 p->client_info = GNUNET_FS_publish_make_status_ (&pi, pc, p, flen);
425 } 426 }
426 GNUNET_FS_file_information_sync_ (p); 427 /* continue with main */ /* continue with main */
427 /* continue with main */
428 GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == pc->upload_task); 428 GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == pc->upload_task);
429 pc->upload_task = 429 pc->upload_task =
430 GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_BACKGROUND, 430 GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_BACKGROUND,
@@ -444,7 +444,7 @@ encode_cont (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
444 * @param depth depth of the block in the file, 0 for DBLOCK 444 * @param depth depth of the block in the file, 0 for DBLOCK
445 * @param type type of the block (IBLOCK or DBLOCK) 445 * @param type type of the block (IBLOCK or DBLOCK)
446 * @param block the (encrypted) block 446 * @param block the (encrypted) block
447 * @param block_size size of block (in bytes) 447 * @param block_size size of @a block (in bytes)
448 */ 448 */
449static void 449static void
450block_proc (void *cls, const struct ContentHashKey *chk, uint64_t offset, 450block_proc (void *cls, const struct ContentHashKey *chk, uint64_t offset,
@@ -508,7 +508,7 @@ block_proc (void *cls, const struct ContentHashKey *chk, uint64_t offset,
508 * @param cls closure 508 * @param cls closure
509 * @param offset where are we in the file 509 * @param offset where are we in the file
510 * @param pt_block plaintext of the currently processed block 510 * @param pt_block plaintext of the currently processed block
511 * @param pt_size size of pt_block 511 * @param pt_size size of @a pt_block
512 * @param depth depth of the block in the tree, 0 for DBLOCK 512 * @param depth depth of the block in the tree, 0 for DBLOCK
513 */ 513 */
514static void 514static void
@@ -611,11 +611,12 @@ publish_content (struct GNUNET_FS_PublishContext *pc)
611 * Process the response (or lack thereof) from 611 * Process the response (or lack thereof) from
612 * the "fs" service to our 'start index' request. 612 * the "fs" service to our 'start index' request.
613 * 613 *
614 * @param cls closure (of type "struct GNUNET_FS_PublishContext*"_) 614 * @param cls closure (of type `struct GNUNET_FS_PublishContext *`)
615 * @param msg the response we got 615 * @param msg the response we got
616 */ 616 */
617static void 617static void
618process_index_start_response (void *cls, const struct GNUNET_MessageHeader *msg) 618process_index_start_response (void *cls,
619 const struct GNUNET_MessageHeader *msg)
619{ 620{
620 struct GNUNET_FS_PublishContext *pc = cls; 621 struct GNUNET_FS_PublishContext *pc = cls;
621 struct GNUNET_FS_FileInformation *p; 622 struct GNUNET_FS_FileInformation *p;
@@ -668,7 +669,8 @@ process_index_start_response (void *cls, const struct GNUNET_MessageHeader *msg)
668 * @param res resulting hash, NULL on error 669 * @param res resulting hash, NULL on error
669 */ 670 */
670static void 671static void
671hash_for_index_cb (void *cls, const struct GNUNET_HashCode * res) 672hash_for_index_cb (void *cls,
673 const struct GNUNET_HashCode *res)
672{ 674{
673 struct GNUNET_FS_PublishContext *pc = cls; 675 struct GNUNET_FS_PublishContext *pc = cls;
674 struct GNUNET_FS_FileInformation *p; 676 struct GNUNET_FS_FileInformation *p;
@@ -773,7 +775,7 @@ hash_for_index_cb (void *cls, const struct GNUNET_HashCode * res)
773/** 775/**
774 * Main function that performs the upload. 776 * Main function that performs the upload.
775 * 777 *
776 * @param cls "struct GNUNET_FS_PublishContext" identifies the upload 778 * @param cls `struct GNUNET_FS_PublishContext *` identifies the upload
777 * @param tc task context 779 * @param tc task context
778 */ 780 */
779void 781void
@@ -799,8 +801,10 @@ GNUNET_FS_publish_main_ (void *cls,
799 return; 801 return;
800 } 802 }
801 /* find starting position */ 803 /* find starting position */
802 while ((p->is_directory == GNUNET_YES) && (NULL != p->data.dir.entries) && (NULL == p->emsg) 804 while ( (GNUNET_YES == p->is_directory) &&
803 && (NULL == p->data.dir.entries->chk_uri)) 805 (NULL != p->data.dir.entries) &&
806 (NULL == p->emsg) &&
807 (NULL == p->data.dir.entries->chk_uri) )
804 { 808 {
805 p = p->data.dir.entries; 809 p = p->data.dir.entries;
806 pc->fi_pos = p; 810 pc->fi_pos = p;
@@ -809,7 +813,9 @@ GNUNET_FS_publish_main_ (void *cls,
809 /* abort on error */ 813 /* abort on error */
810 if (NULL != p->emsg) 814 if (NULL != p->emsg)
811 { 815 {
812 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Error uploading: %s\n", p->emsg); 816 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
817 "Error uploading: %s\n",
818 p->emsg);
813 /* error with current file, abort all 819 /* error with current file, abort all
814 * related files as well! */ 820 * related files as well! */
815 while (NULL != p->dir) 821 while (NULL != p->dir)
@@ -897,7 +903,7 @@ GNUNET_FS_publish_main_ (void *cls,
897 * Signal the FS's progress function that we are starting 903 * Signal the FS's progress function that we are starting
898 * an upload. 904 * an upload.
899 * 905 *
900 * @param cls closure (of type "struct GNUNET_FS_PublishContext*") 906 * @param cls closure (of type `struct GNUNET_FS_PublishContext *`)
901 * @param fi the entry in the publish-structure 907 * @param fi the entry in the publish-structure
902 * @param length length of the file or directory 908 * @param length length of the file or directory
903 * @param meta metadata for the file or directory (can be modified) 909 * @param meta metadata for the file or directory (can be modified)
@@ -905,13 +911,17 @@ GNUNET_FS_publish_main_ (void *cls,
905 * @param bo block options 911 * @param bo block options
906 * @param do_index should we index? 912 * @param do_index should we index?
907 * @param client_info pointer to client context set upon creation (can be modified) 913 * @param client_info pointer to client context set upon creation (can be modified)
908 * @return GNUNET_OK to continue (always) 914 * @return #GNUNET_OK to continue (always)
909 */ 915 */
910static int 916static int
911fip_signal_start (void *cls, struct GNUNET_FS_FileInformation *fi, 917fip_signal_start (void *cls,
912 uint64_t length, struct GNUNET_CONTAINER_MetaData *meta, 918 struct GNUNET_FS_FileInformation *fi,
913 struct GNUNET_FS_Uri **uri, struct GNUNET_FS_BlockOptions *bo, 919 uint64_t length,
914 int *do_index, void **client_info) 920 struct GNUNET_CONTAINER_MetaData *meta,
921 struct GNUNET_FS_Uri **uri,
922 struct GNUNET_FS_BlockOptions *bo,
923 int *do_index,
924 void **client_info)
915{ 925{
916 struct GNUNET_FS_PublishContext *pc = cls; 926 struct GNUNET_FS_PublishContext *pc = cls;
917 struct GNUNET_FS_ProgressInfo pi; 927 struct GNUNET_FS_ProgressInfo pi;
@@ -1024,13 +1034,16 @@ suspend_operation (struct GNUNET_FS_FileInformation *fi,
1024 * @param bo block options 1034 * @param bo block options
1025 * @param do_index should we index? 1035 * @param do_index should we index?
1026 * @param client_info pointer to client context set upon creation (can be modified) 1036 * @param client_info pointer to client context set upon creation (can be modified)
1027 * @return GNUNET_OK to continue (always) 1037 * @return #GNUNET_OK to continue (always)
1028 */ 1038 */
1029static int 1039static int
1030fip_signal_suspend (void *cls, struct GNUNET_FS_FileInformation *fi, 1040fip_signal_suspend (void *cls,
1031 uint64_t length, struct GNUNET_CONTAINER_MetaData *meta, 1041 struct GNUNET_FS_FileInformation *fi,
1042 uint64_t length,
1043 struct GNUNET_CONTAINER_MetaData *meta,
1032 struct GNUNET_FS_Uri **uri, 1044 struct GNUNET_FS_Uri **uri,
1033 struct GNUNET_FS_BlockOptions *bo, int *do_index, 1045 struct GNUNET_FS_BlockOptions *bo,
1046 int *do_index,
1034 void **client_info) 1047 void **client_info)
1035{ 1048{
1036 struct GNUNET_FS_PublishContext *pc = cls; 1049 struct GNUNET_FS_PublishContext *pc = cls;
@@ -1081,7 +1094,7 @@ GNUNET_FS_publish_signal_suspend_ (void *cls)
1081 * We have gotten a reply for our space reservation request. 1094 * We have gotten a reply for our space reservation request.
1082 * Either fail (insufficient space) or start publishing for good. 1095 * Either fail (insufficient space) or start publishing for good.
1083 * 1096 *
1084 * @param cls the 'struct GNUNET_FS_PublishContext*' 1097 * @param cls the `struct GNUNET_FS_PublishContext *`
1085 * @param success positive reservation ID on success 1098 * @param success positive reservation ID on success
1086 * @param min_expiration minimum expiration time required for content to be stored 1099 * @param min_expiration minimum expiration time required for content to be stored
1087 * @param msg error message on error, otherwise NULL 1100 * @param msg error message on error, otherwise NULL
@@ -1097,7 +1110,8 @@ finish_reserve (void *cls, int success,
1097 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Reservation complete (%d)!\n", success); 1110 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Reservation complete (%d)!\n", success);
1098 if ((msg != NULL) || (success <= 0)) 1111 if ((msg != NULL) || (success <= 0))
1099 { 1112 {
1100 GNUNET_asprintf (&pc->fi->emsg, _("Insufficient space for publishing: %s"), 1113 GNUNET_asprintf (&pc->fi->emsg,
1114 _("Insufficient space for publishing: %s"),
1101 msg); 1115 msg);
1102 signal_publish_error (pc->fi, pc, pc->fi->emsg); 1116 signal_publish_error (pc->fi, pc, pc->fi->emsg);
1103 return; 1117 return;
@@ -1193,7 +1207,7 @@ GNUNET_FS_publish_start (struct GNUNET_FS_Handle *h,
1193 * Signal the FS's progress function that we are stopping 1207 * Signal the FS's progress function that we are stopping
1194 * an upload. 1208 * an upload.
1195 * 1209 *
1196 * @param cls closure (of type "struct GNUNET_FS_PublishContext*") 1210 * @param cls closure (of type `struct GNUNET_FS_PublishContext *`)
1197 * @param fi the entry in the publish-structure 1211 * @param fi the entry in the publish-structure
1198 * @param length length of the file or directory 1212 * @param length length of the file or directory
1199 * @param meta metadata for the file or directory (can be modified) 1213 * @param meta metadata for the file or directory (can be modified)
@@ -1201,7 +1215,7 @@ GNUNET_FS_publish_start (struct GNUNET_FS_Handle *h,
1201 * @param bo block options (can be modified) 1215 * @param bo block options (can be modified)
1202 * @param do_index should we index? 1216 * @param do_index should we index?
1203 * @param client_info pointer to client context set upon creation (can be modified) 1217 * @param client_info pointer to client context set upon creation (can be modified)
1204 * @return GNUNET_OK to continue (always) 1218 * @return #GNUNET_OK to continue (always)
1205 */ 1219 */
1206static int 1220static int
1207fip_signal_stop (void *cls, struct GNUNET_FS_FileInformation *fi, 1221fip_signal_stop (void *cls, struct GNUNET_FS_FileInformation *fi,