fixing block reconstruction start/shutdown code
[oweals/gnunet.git] / src / fs / fs.h
index 9d662b267aaef22f4e8c0f822adfc9ffb40d82e0..e655a3e57e76e3242440a6737c4a401d8a2324cb 100644 (file)
@@ -1,4 +1,3 @@
-
 /*
      This file is part of GNUnet.
      (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Christian Grothoff (and other contributing authors)
 
 /**
  * Maximum number of outgoing messages we queue per peer.
+ *
+ * Performance measurements for 2 peer setup for 50 MB file
+ * (with MAX_DATASTORE_QUEUE = 1 and RETRY_PROBABILITY_INV = 1):
+ *
+ *   2: 1700 kb/s, 1372 kb/s
+ *   8: 2117 kb/s, 1284 kb/s, 1112 kb/s
+ *  16: 3500 kb/s, 3200 kb/s, 3388 kb/s
+ *  32: 3441 kb/s, 3163 kb/s, 3277 kb/s
+ * 128: 1700 kb/s; 2010 kb/s, 3383 kb/s, 1156 kb/s
+ *
+ * Conclusion: 16 seems to be a pretty good value (stable
+ * and high performance, no excessive memory use).
  */
 #define MAX_QUEUE_PER_PEER 16
 
@@ -902,6 +913,18 @@ GNUNET_FS_download_make_status_ (struct GNUNET_FS_ProgressInfo *pi,
                                 struct GNUNET_FS_DownloadContext *dc);
 
 
+/**
+ * Task that creates the initial (top-level) download
+ * request for the file.
+ *
+ * @param cls the 'struct GNUNET_FS_DownloadContext'
+ * @param tc scheduler context
+ */
+void
+GNUNET_FS_download_start_task_ (void *cls,
+                               const struct GNUNET_SCHEDULER_TaskContext *tc);
+
+
 /**
  * Fill in all of the generic fields for 
  * an unindex event and call the callback.
@@ -1159,11 +1182,6 @@ GNUNET_FS_end_top (struct GNUNET_FS_Handle *h,
  */
 struct GNUNET_FS_Handle
 {
-  /**
-   * Scheduler.
-   */
-  struct GNUNET_SCHEDULER_Handle *sched;
-
   /**
    * Configuration to use.
    */
@@ -1594,8 +1612,20 @@ struct GNUNET_FS_SearchContext
    * when the search is being stopped (if not
    * GNUNET_SCHEDULER_NO_TASK).  Used for the task that adds some
    * artificial delay when trying to reconnect to the FS service.
-   */
+o   */
   GNUNET_SCHEDULER_TaskIdentifier task;
+
+  /**
+   * How many of the entries in the search request
+   * map have been passed to the service so far?
+   */
+  unsigned int search_request_map_offset;
+
+  /**
+   * How many of the keywords in the KSK
+   * map have been passed to the service so far?
+   */
+  unsigned int keyword_offset;
   
   /**
    * Anonymity level for the search.
@@ -1652,6 +1682,12 @@ struct DownloadRequest
 };
 
 
+/**
+ * Closure for 'reconstruct_cont' and 'reconstruct_cb'.
+ */
+struct ReconstructContext;
+
+
 /**
  * Context for controlling a download.
  */
@@ -1695,6 +1731,11 @@ struct GNUNET_FS_DownloadContext
    */
   struct GNUNET_FS_DownloadContext *child_tail;
 
+  /**
+   * State for block reconstruction.
+   */
+  struct ReconstructContext *rcc;
+
   /**
    * Previous download belonging to the same parent.
    */
@@ -1784,6 +1825,11 @@ struct GNUNET_FS_DownloadContext
    */
   GNUNET_SCHEDULER_TaskIdentifier task;
 
+  /**
+   * Task used to start the download.
+   */
+  GNUNET_SCHEDULER_TaskIdentifier start_task;
+
   /**
    * What was the size of the file on disk that we're downloading
    * before we started?  Used to detect if there is a point in
@@ -1842,6 +1888,12 @@ struct GNUNET_FS_DownloadContext
    * data from the meta data yet?
    */
   int tried_full_data;
+
+  /**
+   * Have we tried to reconstruct an IBLOCK from disk
+   * and failed (and should hence not try again?)
+   */
+  int reconstruct_failed;
 };