aboutsummaryrefslogtreecommitdiff
path: root/src/fs
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2010-04-02 20:58:19 +0000
committerChristian Grothoff <christian@grothoff.org>2010-04-02 20:58:19 +0000
commit35131ac6802168472251575e42ae158a8bdf7adc (patch)
tree73e99b1677cf54335c4d3406c57e44b348eb5c1f /src/fs
parent573ff66c0553e28922e7ea362470d8a5f3a6d841 (diff)
downloadgnunet-35131ac6802168472251575e42ae158a8bdf7adc.tar.gz
gnunet-35131ac6802168472251575e42ae158a8bdf7adc.zip
fix
Diffstat (limited to 'src/fs')
-rw-r--r--src/fs/fs.h7
-rw-r--r--src/fs/fs_download.c35
2 files changed, 42 insertions, 0 deletions
diff --git a/src/fs/fs.h b/src/fs/fs.h
index 0b3b25955..3a42fee2d 100644
--- a/src/fs/fs.h
+++ b/src/fs/fs.h
@@ -1094,6 +1094,13 @@ struct GNUNET_FS_DownloadContext
1094 */ 1094 */
1095 enum GNUNET_FS_DownloadOptions options; 1095 enum GNUNET_FS_DownloadOptions options;
1096 1096
1097 /**
1098 * Flag set upon transitive completion (includes child downloads).
1099 * This flag is only set to GNUNET_YES for directories where all
1100 * child-downloads have also completed (and signalled completion).
1101 */
1102 int has_finished;
1103
1097}; 1104};
1098 1105
1099struct GNUNET_FS_Namespace 1106struct GNUNET_FS_Namespace
diff --git a/src/fs/fs_download.c b/src/fs/fs_download.c
index b4f16518d..c86759c5f 100644
--- a/src/fs/fs_download.c
+++ b/src/fs/fs_download.c
@@ -711,6 +711,39 @@ full_recursive_download (struct GNUNET_FS_DownloadContext *dc)
711 711
712 712
713/** 713/**
714 * Check if all child-downloads have completed and
715 * if so, signal completion (and possibly recurse to
716 * parent).
717 */
718static void
719check_completed (struct GNUNET_FS_DownloadContext *dc)
720{
721 struct GNUNET_FS_ProgressInfo pi;
722 struct GNUNET_FS_DownloadContext *pos;
723
724 pos = dc->child_head;
725 while (pos != NULL)
726 {
727 if ( (pos->emsg == NULL) &&
728 (pos->completed < pos->length) )
729 return; /* not done yet */
730 if ( (pos->child_head != NULL) &&
731 (pos->has_finished != GNUNET_YES) )
732 return; /* not transitively done yet */
733 pos = pos->next;
734 }
735 dc->has_finished = GNUNET_YES;
736 /* signal completion */
737 pi.status = GNUNET_FS_STATUS_DOWNLOAD_COMPLETED;
738 make_download_status (&pi, dc);
739 dc->client_info = dc->h->upcb (dc->h->upcb_cls,
740 &pi);
741 if (dc->parent != NULL)
742 check_completed (dc->parent);
743}
744
745
746/**
714 * Iterator over entries in the pending requests in the 'active' map for the 747 * Iterator over entries in the pending requests in the 'active' map for the
715 * reply that we just got. 748 * reply that we just got.
716 * 749 *
@@ -918,6 +951,8 @@ process_result_with_request (void *cls,
918 make_download_status (&pi, dc); 951 make_download_status (&pi, dc);
919 dc->client_info = dc->h->upcb (dc->h->upcb_cls, 952 dc->client_info = dc->h->upcb (dc->h->upcb_cls,
920 &pi); 953 &pi);
954 if (dc->parent != NULL)
955 check_completed (dc->parent);
921 } 956 }
922 GNUNET_assert (sm->depth == dc->treedepth); 957 GNUNET_assert (sm->depth == dc->treedepth);
923 } 958 }