-options to play with
[oweals/gnunet.git] / src / fs / gnunet-service-fs_pr.c
index ecd841808935336ba44248483309425e7254d5cc..76e04f57cf5684b60caecc564e69ca2d423ab0cd 100644 (file)
  */
 #define INSANE_STATISTICS GNUNET_NO
 
+/**
+ * If obtaining a block via stream fails, how often do we retry it before
+ * giving up for good (and sticking to non-anonymous transfer)?
+ */
+#define STREAM_RETRY_MAX 3
+
+
 /**
  * An active request.
  */
@@ -165,6 +172,12 @@ struct GSF_PendingRequest
    */
   uint64_t first_uid;
 
+  /**
+   * How often have we retried this request via 'stream'?
+   * (used to bound overall retries).
+   */
+  unsigned int stream_retry_count;
+
   /**
    * Number of valid entries in the 'replies_seen' array.
    */
@@ -1181,7 +1194,16 @@ stream_reply_proc (void *cls,
     GNUNET_break (0 == data_size);
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                "Error retrieiving block via stream\n");
-    /* FIXME: should re-try a few times... */
+    pr->stream_retry_count++;
+    if (pr->stream_retry_count >= STREAM_RETRY_MAX)
+      return; /* give up on stream */
+    /* retry -- without delay, as this is non-anonymous
+       and mesh/stream connect will take some time anyway */
+    pr->stream_request = GSF_stream_query (pr->public_data.target,
+                                          &pr->public_data.query,
+                                          pr->public_data.type,
+                                          &stream_reply_proc,
+                                          pr);
     return;
   }
   if (GNUNET_YES !=