start fewer FS probes concurrently, run them all in the same task to avoid undue...
[oweals/gnunet.git] / src / fs / fs_api.h
index 77e26e1553c7418def8bf44d09108886ec680684..46f398e86e20db0d86342e870552b7a2a5cb117a 100644 (file)
@@ -268,6 +268,12 @@ struct GNUNET_FS_FileInformation
    */
   struct GNUNET_FS_Uri *chk_uri;
 
+  /**
+   * SKS URI for this file or directory. NULL if
+   * we have not yet computed it.
+   */
+  struct GNUNET_FS_Uri *sks_uri;
+
   /**
    * Block options for the file.
    */
@@ -524,6 +530,16 @@ struct GNUNET_FS_SearchResult
    */
   struct GNUNET_FS_Handle *h;
 
+  /**
+   * Kept in a DLL while probing.
+   */
+  struct GNUNET_FS_SearchResult *next;
+
+  /**
+   * Kept in a DLL while probing.
+   */
+  struct GNUNET_FS_SearchResult *prev;
+
   /**
    * Search context this result belongs to; can be NULL
    * for probes that come from a directory result.
@@ -574,7 +590,7 @@ struct GNUNET_FS_SearchResult
   uint8_t *keyword_bitmap;
 
   /**
-   * Key for the search result
+   * Key for the search result based on the URI.
    */
   struct GNUNET_HashCode key;
 
@@ -585,12 +601,6 @@ struct GNUNET_FS_SearchResult
    */
   GNUNET_SCHEDULER_TaskIdentifier probe_cancel_task;
 
-  /**
-   * Task we use to report periodically to the application that the
-   * probe is still running.
-   */
-  GNUNET_SCHEDULER_TaskIdentifier probe_ping_task;
-
   /**
    * When did the current probe become active?
    */
@@ -645,8 +655,11 @@ struct GNUNET_FS_SearchResult
  * @return queue handle
  */
 struct GNUNET_FS_QueueEntry *
-GNUNET_FS_queue_ (struct GNUNET_FS_Handle *h, GNUNET_FS_QueueStart start,
-                  GNUNET_FS_QueueStop stop, void *cls, unsigned int blocks,
+GNUNET_FS_queue_ (struct GNUNET_FS_Handle *h,
+                  GNUNET_FS_QueueStart start,
+                  GNUNET_FS_QueueStop stop,
+                  void *cls,
+                  unsigned int blocks,
                  enum GNUNET_FS_QueuePriority priority);
 
 
@@ -735,7 +748,7 @@ GNUNET_FS_search_probe_progress_ (void *cls,
 /**
  * Main function that performs the upload.
  *
- * @param cls "struct GNUNET_FS_PublishContext" identifies the upload
+ * @param cls `struct GNUNET_FS_PublishContext` identifies the upload
  * @param tc task context
  */
 void
@@ -897,7 +910,8 @@ GNUNET_FS_remove_sync_file_ (struct GNUNET_FS_Handle *h, const char *ext,
  * @param uni unique name of parent
  */
 void
-GNUNET_FS_remove_sync_dir_ (struct GNUNET_FS_Handle *h, const char *ext,
+GNUNET_FS_remove_sync_dir_ (struct GNUNET_FS_Handle *h,
+                            const char *ext,
                             const char *uni);
 
 
@@ -997,7 +1011,7 @@ GNUNET_FS_search_signal_suspend_ (void *cls);
  * Create SUSPEND event for the given download operation
  * and then clean up our state (without stop signal).
  *
- * @param cls the 'struct GNUNET_FS_DownloadContext' to signal for
+ * @param cls the `struct GNUNET_FS_DownloadContext` to signal for
  */
 void
 GNUNET_FS_download_signal_suspend_ (void *cls);
@@ -1131,12 +1145,28 @@ struct GNUNET_FS_Handle
    */
   struct GNUNET_FS_QueueEntry *pending_tail;
 
+  /**
+   * Head of active probes.
+   */
+  struct GNUNET_FS_SearchResult *probes_head;
+
+  /**
+   * Tail of active probes.
+   */
+  struct GNUNET_FS_SearchResult *probes_tail;
+
   /**
    * Task that processes the jobs in the running and pending queues
    * (and moves jobs around as needed).
    */
   GNUNET_SCHEDULER_TaskIdentifier queue_job;
 
+  /**
+   * Task we use to report periodically to the application that
+   * certain search probes (from @e probes_head) are still running.
+   */
+  GNUNET_SCHEDULER_TaskIdentifier probe_ping_task;
+
   /**
    * Average time we take for a single request to be satisfied.
    * FIXME: not yet calcualted properly...
@@ -1470,8 +1500,7 @@ struct GNUNET_FS_UnindexContext
 
 
 /**
- * Information we keep for each keyword in
- * a keyword search.
+ * Information we keep for each keyword in a keyword search.
  */
 struct SearchRequestEntry
 {
@@ -1558,7 +1587,7 @@ struct GNUNET_FS_SearchContext
   char *emsg;
 
   /**
-   * Map that contains a "struct GNUNET_FS_SearchResult" for each result that
+   * Map that contains a `struct GNUNET_FS_SearchResult` for each result that
    * was found in the search.  The key for each entry is the XOR of
    * the key and query in the CHK URI (as a unique identifier for the
    * search result).
@@ -1763,6 +1792,15 @@ void
 GNUNET_FS_free_download_request_ (struct DownloadRequest *dr);
 
 
+/**
+ * Stop the ping task for this search result.
+ *
+ * @param sr result to start pinging for.
+ */
+void
+GNUNET_FS_stop_probe_ping_task_ (struct GNUNET_FS_SearchResult *sr);
+
+
 /**
  * Context for controlling a download.
  */
@@ -1907,7 +1945,7 @@ struct GNUNET_FS_DownloadContext
   /**
    * ID of a task that is using this struct and that must be cancelled
    * when the download is being stopped (if not
-   * GNUNET_SCHEDULER_NO_TASK).  Used for the task that adds some
+   * #GNUNET_SCHEDULER_NO_TASK).  Used for the task that adds some
    * artificial delay when trying to reconnect to the FS service or
    * the task processing incrementally the data on disk, or the
    * task requesting blocks, etc.