aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2009-09-02 18:52:09 +0000
committerChristian Grothoff <christian@grothoff.org>2009-09-02 18:52:09 +0000
commit3e5a482b0e25536e3fff87b32ebf210adaf8b95a (patch)
tree2973aedd9528901d4e8fa7f7953ab02bb5141f2d /src
parent09118c85cd5200267784985900e4f83ea31b8622 (diff)
downloadgnunet-3e5a482b0e25536e3fff87b32ebf210adaf8b95a.tar.gz
gnunet-3e5a482b0e25536e3fff87b32ebf210adaf8b95a.zip
fixing fixmes
Diffstat (limited to 'src')
-rw-r--r--src/fs/fs_publish.c79
1 files changed, 49 insertions, 30 deletions
diff --git a/src/fs/fs_publish.c b/src/fs/fs_publish.c
index 6080fae03..76f73fdc0 100644
--- a/src/fs/fs_publish.c
+++ b/src/fs/fs_publish.c
@@ -26,7 +26,7 @@
26 * @author Christian Grothoff 26 * @author Christian Grothoff
27 * 27 *
28 * TODO: 28 * TODO:
29 * - code-sharing with unindex (write unindex code, clean up new FIXME's) 29 * - code-sharing with unindex (write unindex code)
30 * - indexing cleanup: unindex on failure (can wait) 30 * - indexing cleanup: unindex on failure (can wait)
31 * - persistence support (can wait) 31 * - persistence support (can wait)
32 * - datastore reservation support (optimization) 32 * - datastore reservation support (optimization)
@@ -97,11 +97,13 @@ struct PutContCtx
97 * @param pc structure to fill in 97 * @param pc structure to fill in
98 * @param sc overall publishing context 98 * @param sc overall publishing context
99 * @param p file information for the file being published 99 * @param p file information for the file being published
100 * @param offset where in the file are we so far
100 */ 101 */
101static void 102static void
102make_publish_status (struct GNUNET_FS_ProgressInfo *pi, 103make_publish_status (struct GNUNET_FS_ProgressInfo *pi,
103 struct GNUNET_FS_PublishContext *sc, 104 struct GNUNET_FS_PublishContext *sc,
104 const struct GNUNET_FS_FileInformation *p) 105 const struct GNUNET_FS_FileInformation *p,
106 uint64_t offset)
105{ 107{
106 pi->value.publish.sc = sc; 108 pi->value.publish.sc = sc;
107 pi->value.publish.fi = p; 109 pi->value.publish.fi = p;
@@ -111,13 +113,11 @@ make_publish_status (struct GNUNET_FS_ProgressInfo *pi,
111 = (NULL == p->dir) ? NULL : p->dir->client_info; 113 = (NULL == p->dir) ? NULL : p->dir->client_info;
112 pi->value.publish.size 114 pi->value.publish.size
113 = (p->is_directory) ? p->data.dir.dir_size : p->data.file.file_size; 115 = (p->is_directory) ? p->data.dir.dir_size : p->data.file.file_size;
114#if FIXME
115 pi->value.publish.eta 116 pi->value.publish.eta
116 = GNUNET_TIME_calculate_eta (p->start_time, 117 = GNUNET_TIME_calculate_eta (p->start_time,
117 p->publish_offset, 118 offset,
118 pi->value.publish.size); 119 pi->value.publish.size);
119 pi->value.publish.completed = p->publish_offset; 120 pi->value.publish.completed = offset;
120#endif
121 pi->value.publish.duration = GNUNET_TIME_absolute_get_duration (p->start_time); 121 pi->value.publish.duration = GNUNET_TIME_absolute_get_duration (p->start_time);
122 pi->value.publish.anonymity = p->anonymity; 122 pi->value.publish.anonymity = p->anonymity;
123} 123}
@@ -173,7 +173,7 @@ ds_put_cont (void *cls,
173 msg); 173 msg);
174 GNUNET_FS_file_information_sync (pcc->p); 174 GNUNET_FS_file_information_sync (pcc->p);
175 pi.status = GNUNET_FS_STATUS_PUBLISH_ERROR; 175 pi.status = GNUNET_FS_STATUS_PUBLISH_ERROR;
176 make_publish_status (&pi, pcc->sc, pcc->p); 176 make_publish_status (&pi, pcc->sc, pcc->p, 0);
177 pi.value.publish.eta = GNUNET_TIME_UNIT_FOREVER_REL; 177 pi.value.publish.eta = GNUNET_TIME_UNIT_FOREVER_REL;
178 pi.value.publish.specifics.error.message = pcc->p->emsg; 178 pi.value.publish.specifics.error.message = pcc->p->emsg;
179 pcc->p->client_info 179 pcc->p->client_info
@@ -210,7 +210,7 @@ signal_publish_completion (struct GNUNET_FS_FileInformation *p,
210 struct GNUNET_FS_ProgressInfo pi; 210 struct GNUNET_FS_ProgressInfo pi;
211 211
212 pi.status = GNUNET_FS_STATUS_PUBLISH_COMPLETED; 212 pi.status = GNUNET_FS_STATUS_PUBLISH_COMPLETED;
213 make_publish_status (&pi, sc, p); 213 make_publish_status (&pi, sc, p, p->chk_uri->data.chk.file_length);
214 pi.value.publish.eta = GNUNET_TIME_UNIT_ZERO; 214 pi.value.publish.eta = GNUNET_TIME_UNIT_ZERO;
215 pi.value.publish.specifics.completed.chk_uri = p->chk_uri; 215 pi.value.publish.specifics.completed.chk_uri = p->chk_uri;
216 p->client_info 216 p->client_info
@@ -237,7 +237,7 @@ signal_publish_error (struct GNUNET_FS_FileInformation *p,
237 237
238 p->emsg = GNUNET_strdup (emsg); 238 p->emsg = GNUNET_strdup (emsg);
239 pi.status = GNUNET_FS_STATUS_PUBLISH_ERROR; 239 pi.status = GNUNET_FS_STATUS_PUBLISH_ERROR;
240 make_publish_status (&pi, sc, p); 240 make_publish_status (&pi, sc, p, 0);
241 pi.value.publish.eta = GNUNET_TIME_UNIT_FOREVER_REL; 241 pi.value.publish.eta = GNUNET_TIME_UNIT_FOREVER_REL;
242 pi.value.publish.specifics.error.message =emsg; 242 pi.value.publish.specifics.error.message =emsg;
243 p->client_info 243 p->client_info
@@ -350,7 +350,19 @@ publish_kblocks_cont (void *cls,
350} 350}
351 351
352 352
353// FIXME: document 353/**
354 * Function called by the tree encoder to obtain
355 * a block of plaintext data (for the lowest level
356 * of the tree).
357 *
358 * @param cls our publishing context
359 * @param offset identifies which block to get
360 * @param max (maximum) number of bytes to get; returning
361 * fewer will also cause errors
362 * @param buf where to copy the plaintext buffer
363 * @param emsg location to store an error message (on error)
364 * @return number of bytes copied to buf, 0 on error
365 */
354static size_t 366static size_t
355block_reader (void *cls, 367block_reader (void *cls,
356 uint64_t offset, 368 uint64_t offset,
@@ -389,7 +401,14 @@ block_reader (void *cls,
389} 401}
390 402
391 403
392// FIXME: document 404/**
405 * The tree encoder has finished processing a
406 * file. Call it's finish method and deal with
407 * the final result.
408 *
409 * @param cls our publishing context
410 * @param tc scheduler's task context (not used)
411 */
393static void 412static void
394encode_cont (void *cls, 413encode_cont (void *cls,
395 const struct GNUNET_SCHEDULER_TaskContext *tc) 414 const struct GNUNET_SCHEDULER_TaskContext *tc)
@@ -412,7 +431,7 @@ encode_cont (void *cls,
412 GNUNET_free (emsg); 431 GNUNET_free (emsg);
413 GNUNET_FS_file_information_sync (p); 432 GNUNET_FS_file_information_sync (p);
414 pi.status = GNUNET_FS_STATUS_PUBLISH_ERROR; 433 pi.status = GNUNET_FS_STATUS_PUBLISH_ERROR;
415 make_publish_status (&pi, sc, p); 434 make_publish_status (&pi, sc, p, 0);
416 pi.value.publish.eta = GNUNET_TIME_UNIT_FOREVER_REL; 435 pi.value.publish.eta = GNUNET_TIME_UNIT_FOREVER_REL;
417 pi.value.publish.specifics.error.message = p->emsg; 436 pi.value.publish.specifics.error.message = p->emsg;
418 p->client_info 437 p->client_info
@@ -534,11 +553,11 @@ progress_proc (void *cls,
534 553
535 p = sc->fi_pos; 554 p = sc->fi_pos;
536 pi.status = GNUNET_FS_STATUS_PUBLISH_PROGRESS; 555 pi.status = GNUNET_FS_STATUS_PUBLISH_PROGRESS;
537 make_publish_status (&pi, sc, p); 556 make_publish_status (&pi, sc, p, offset);
538 pi.value.publish.specifics.progress.data = pt_block; 557 pi.value.publish.specifics.progress.data = pt_block;
539 pi.value.publish.specifics.progress.offset = offset; 558 pi.value.publish.specifics.progress.offset = offset;
540 pi.value.publish.specifics.progress.data_len = pt_size; 559 pi.value.publish.specifics.progress.data_len = pt_size;
541 // FIXME: add depth to pi 560 pi.value.publish.specifics.progress.depth = depth;
542 p->client_info 561 p->client_info
543 = sc->h->upcb (sc->h->upcb_cls, 562 = sc->h->upcb (sc->h->upcb_cls,
544 &pi); 563 &pi);
@@ -551,20 +570,18 @@ progress_proc (void *cls,
551 * continue with the main task. 570 * continue with the main task.
552 * 571 *
553 * @param sc overall upload data 572 * @param sc overall upload data
554 * @param p specific file or directory for which kblocks
555 * should be created
556 */ 573 */
557// FIXME: "p" argument is not needed!
558static void 574static void
559publish_content (struct GNUNET_FS_PublishContext *sc, 575publish_content (struct GNUNET_FS_PublishContext *sc)
560 struct GNUNET_FS_FileInformation *p)
561{ 576{
577 struct GNUNET_FS_FileInformation *p;
562 char *emsg; 578 char *emsg;
563 struct GNUNET_FS_DirectoryBuilder *db; 579 struct GNUNET_FS_DirectoryBuilder *db;
564 struct GNUNET_FS_FileInformation *dirpos; 580 struct GNUNET_FS_FileInformation *dirpos;
565 void *raw_data; 581 void *raw_data;
566 uint64_t size; 582 uint64_t size;
567 583
584 p = sc->fi_pos;
568 if (NULL == p->te) 585 if (NULL == p->te)
569 { 586 {
570 if (p->is_directory) 587 if (p->is_directory)
@@ -652,7 +669,7 @@ process_index_start_response (void *cls,
652 p->data.file.filename, 669 p->data.file.filename,
653 _("timeout on index-start request to `fs' service")); 670 _("timeout on index-start request to `fs' service"));
654 p->data.file.do_index = GNUNET_NO; 671 p->data.file.do_index = GNUNET_NO;
655 publish_content (sc, p); 672 publish_content (sc);
656 return; 673 return;
657 } 674 }
658 if (ntohs (msg->type) != GNUNET_MESSAGE_TYPE_FS_INDEX_START_OK) 675 if (ntohs (msg->type) != GNUNET_MESSAGE_TYPE_FS_INDEX_START_OK)
@@ -667,11 +684,11 @@ process_index_start_response (void *cls,
667 p->data.file.filename, 684 p->data.file.filename,
668 gettext (emsg)); 685 gettext (emsg));
669 p->data.file.do_index = GNUNET_NO; 686 p->data.file.do_index = GNUNET_NO;
670 publish_content (sc, p); 687 publish_content (sc);
671 return; 688 return;
672 } 689 }
673 /* success! continue with indexing */ 690 /* success! continue with indexing */
674 publish_content (sc, p); 691 publish_content (sc);
675} 692}
676 693
677 694
@@ -709,7 +726,7 @@ hash_for_index_cb (void *cls,
709 p->data.file.filename, 726 p->data.file.filename,
710 _("failed to compute hash")); 727 _("failed to compute hash"));
711 p->data.file.do_index = GNUNET_NO; 728 p->data.file.do_index = GNUNET_NO;
712 publish_content (sc, p); 729 publish_content (sc);
713 return; 730 return;
714 } 731 }
715 slen = strlen (p->data.file.filename) + 1; 732 slen = strlen (p->data.file.filename) + 1;
@@ -720,7 +737,7 @@ hash_for_index_cb (void *cls,
720 p->data.file.filename, 737 p->data.file.filename,
721 _("filename too long")); 738 _("filename too long"));
722 p->data.file.do_index = GNUNET_NO; 739 p->data.file.do_index = GNUNET_NO;
723 publish_content (sc, p); 740 publish_content (sc);
724 return; 741 return;
725 } 742 }
726 client = GNUNET_CLIENT_connect (sc->h->sched, 743 client = GNUNET_CLIENT_connect (sc->h->sched,
@@ -733,7 +750,7 @@ hash_for_index_cb (void *cls,
733 p->data.file.filename, 750 p->data.file.filename,
734 _("could not connect to `fs' service")); 751 _("could not connect to `fs' service"));
735 p->data.file.do_index = GNUNET_NO; 752 p->data.file.do_index = GNUNET_NO;
736 publish_content (sc, p); 753 publish_content (sc);
737 return; 754 return;
738 } 755 }
739 p->data.file.file_id = *res; 756 p->data.file.file_id = *res;
@@ -819,7 +836,7 @@ do_upload (void *cls,
819 GNUNET_free (fn); 836 GNUNET_free (fn);
820 GNUNET_FS_file_information_sync (p); 837 GNUNET_FS_file_information_sync (p);
821 pi.status = GNUNET_FS_STATUS_PUBLISH_ERROR; 838 pi.status = GNUNET_FS_STATUS_PUBLISH_ERROR;
822 make_publish_status (&pi, sc, p); 839 make_publish_status (&pi, sc, p, 0);
823 pi.value.publish.eta = GNUNET_TIME_UNIT_FOREVER_REL; 840 pi.value.publish.eta = GNUNET_TIME_UNIT_FOREVER_REL;
824 pi.value.publish.specifics.error.message = p->emsg; 841 pi.value.publish.specifics.error.message = p->emsg;
825 p->client_info 842 p->client_info
@@ -854,7 +871,7 @@ do_upload (void *cls,
854 _("Can not index file `%s': %s. Will try to insert instead.\n"), 871 _("Can not index file `%s': %s. Will try to insert instead.\n"),
855 "<no-name>", 872 "<no-name>",
856 _("needs to be an actual file")); 873 _("needs to be an actual file"));
857 publish_content (sc, p); 874 publish_content (sc);
858 return; 875 return;
859 } 876 }
860 GNUNET_CRYPTO_hash_file (sc->h->sched, 877 GNUNET_CRYPTO_hash_file (sc->h->sched,
@@ -866,7 +883,7 @@ do_upload (void *cls,
866 sc); 883 sc);
867 return; 884 return;
868 } 885 }
869 publish_content (sc, p); 886 publish_content (sc);
870} 887}
871 888
872 889
@@ -900,7 +917,7 @@ fip_signal_start(void *cls,
900 struct GNUNET_FS_ProgressInfo pi; 917 struct GNUNET_FS_ProgressInfo pi;
901 918
902 pi.status = GNUNET_FS_STATUS_PUBLISH_START; 919 pi.status = GNUNET_FS_STATUS_PUBLISH_START;
903 make_publish_status (&pi, sc, fi); 920 make_publish_status (&pi, sc, fi, 0);
904 *client_info = sc->h->upcb (sc->h->upcb_cls, 921 *client_info = sc->h->upcb (sc->h->upcb_cls,
905 &pi); 922 &pi);
906 return GNUNET_OK; 923 return GNUNET_OK;
@@ -1010,9 +1027,11 @@ fip_signal_stop(void *cls,
1010{ 1027{
1011 struct GNUNET_FS_PublishContext*sc = cls; 1028 struct GNUNET_FS_PublishContext*sc = cls;
1012 struct GNUNET_FS_ProgressInfo pi; 1029 struct GNUNET_FS_ProgressInfo pi;
1030 uint64_t off;
1013 1031
1032 off = (fi->chk_uri == NULL) ? 0 : length;
1014 pi.status = GNUNET_FS_STATUS_PUBLISH_STOPPED; 1033 pi.status = GNUNET_FS_STATUS_PUBLISH_STOPPED;
1015 make_publish_status (&pi, sc, fi); 1034 make_publish_status (&pi, sc, fi, off);
1016 GNUNET_break (NULL == 1035 GNUNET_break (NULL ==
1017 sc->h->upcb (sc->h->upcb_cls, 1036 sc->h->upcb (sc->h->upcb_cls,
1018 &pi)); 1037 &pi));