gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r10764 - in gnunet: . src/fs


From: gnunet
Subject: [GNUnet-SVN] r10764 - in gnunet: . src/fs
Date: Fri, 2 Apr 2010 22:58:19 +0200

Author: grothoff
Date: 2010-04-02 22:58:19 +0200 (Fri, 02 Apr 2010)
New Revision: 10764

Modified:
   gnunet/TODO
   gnunet/src/fs/fs.h
   gnunet/src/fs/fs_download.c
Log:
fix

Modified: gnunet/TODO
===================================================================
--- gnunet/TODO 2010-04-02 20:22:08 UTC (rev 10763)
+++ gnunet/TODO 2010-04-02 20:58:19 UTC (rev 10764)
@@ -26,8 +26,6 @@
   - utilization can (easily, restart?) go out of control (very large), causing
     content expiration job to go crazy and delete everything!
 * FS: [CG]
-  - EASY BUGS:
-    + gnunet-download does not terminate when done (stop missing!)
   - on some systems, keyword search does not find locally published content
     (need testcase of command-line tools! - also good to cover getopt API!)
     [could be related to datastore issue above!]

Modified: gnunet/src/fs/fs.h
===================================================================
--- gnunet/src/fs/fs.h  2010-04-02 20:22:08 UTC (rev 10763)
+++ gnunet/src/fs/fs.h  2010-04-02 20:58:19 UTC (rev 10764)
@@ -1094,6 +1094,13 @@
    */
   enum GNUNET_FS_DownloadOptions options;
 
+  /**
+   * Flag set upon transitive completion (includes child downloads).
+   * This flag is only set to GNUNET_YES for directories where all
+   * child-downloads have also completed (and signalled completion).
+   */
+  int has_finished;
+
 };
 
 struct GNUNET_FS_Namespace

Modified: gnunet/src/fs/fs_download.c
===================================================================
--- gnunet/src/fs/fs_download.c 2010-04-02 20:22:08 UTC (rev 10763)
+++ gnunet/src/fs/fs_download.c 2010-04-02 20:58:19 UTC (rev 10764)
@@ -711,6 +711,39 @@
 
 
 /**
+ * Check if all child-downloads have completed and
+ * if so, signal completion (and possibly recurse to
+ * parent).
+ */
+static void
+check_completed (struct GNUNET_FS_DownloadContext *dc)
+{
+  struct GNUNET_FS_ProgressInfo pi;
+  struct GNUNET_FS_DownloadContext *pos;
+
+  pos = dc->child_head;
+  while (pos != NULL)
+    {
+      if ( (pos->emsg == NULL) &&
+          (pos->completed < pos->length) )
+       return; /* not done yet */
+      if ( (pos->child_head != NULL) &&
+          (pos->has_finished != GNUNET_YES) )
+       return; /* not transitively done yet */
+      pos = pos->next;
+    }
+  dc->has_finished = GNUNET_YES;
+  /* signal completion */
+  pi.status = GNUNET_FS_STATUS_DOWNLOAD_COMPLETED;
+  make_download_status (&pi, dc);
+  dc->client_info = dc->h->upcb (dc->h->upcb_cls,
+                                &pi);
+  if (dc->parent != NULL)
+    check_completed (dc->parent);  
+}
+
+
+/**
  * Iterator over entries in the pending requests in the 'active' map for the
  * reply that we just got.
  *
@@ -918,6 +951,8 @@
          make_download_status (&pi, dc);
          dc->client_info = dc->h->upcb (dc->h->upcb_cls,
                                         &pi);
+         if (dc->parent != NULL)
+           check_completed (dc->parent);
        }
       GNUNET_assert (sm->depth == dc->treedepth);
     }





reply via email to

[Prev in Thread] Current Thread [Next in Thread]