fixes
authorChristian Grothoff <christian@grothoff.org>
Fri, 4 Mar 2011 12:41:54 +0000 (12:41 +0000)
committerChristian Grothoff <christian@grothoff.org>
Fri, 4 Mar 2011 12:41:54 +0000 (12:41 +0000)
src/fs/gnunet-service-fs_put.c

index 862a795babf729e95956f5b64aa26849e49bc7dc..6afeb4faa443aaac48b6c18806d48eb3e794b7ce 100644 (file)
  * @author Christian Grothoff
  */
 #include "platform.h"
+#include "gnunet-service-fs.h"
 #include "gnunet-service-fs_put.h"
 
 
+/**
+ * How often do we at most PUT content into the DHT?
+ */
+#define MAX_DHT_PUT_FREQ GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5)
+
+
 /**
  * Request to datastore for DHT PUTs (or NULL).
  */
@@ -70,7 +77,7 @@ consider_dht_put_gathering (void *cls)
 {
   struct GNUNET_TIME_Relative delay;
 
-  if (dsh == NULL)
+  if (GSF_dsh == NULL)
     return;
   if (dht_qe != NULL)
     return;
@@ -95,6 +102,17 @@ consider_dht_put_gathering (void *cls)
 }
 
 
+/**
+ * Function called upon completion of the DHT PUT operation.
+ */
+static void
+dht_put_continuation (void *cls,
+                     const struct GNUNET_SCHEDULER_TaskContext *tc)
+{
+  GNUNET_DATASTORE_get_next (GSF_dsh, GNUNET_YES);
+}
+
+
 /**
  * Store content in DHT.
  *
@@ -151,7 +169,7 @@ process_dht_put_content (void *cls,
              GNUNET_h2s (key),
              type);
 #endif
-  GNUNET_DHT_put (dht_handle,
+  GNUNET_DHT_put (GSF_dht,
                  key,
                  DEFAULT_PUT_REPLICATION,
                  GNUNET_DHT_RO_NONE,
@@ -176,16 +194,16 @@ gather_dht_put_blocks (void *cls,
                       const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
   dht_task = GNUNET_SCHEDULER_NO_TASK;
-  if (dsh != NULL)
-    {
-      if (dht_put_type == GNUNET_BLOCK_TYPE_FS_ONDEMAND)
-       dht_put_type = GNUNET_BLOCK_TYPE_FS_KBLOCK;
-      dht_qe = GNUNET_DATASTORE_get_zero_anonymity (dsh, 0, UINT_MAX,
-                                                   GNUNET_TIME_UNIT_FOREVER_REL,
-                                                   dht_put_type++,
-                                                   &process_dht_put_content, NULL);
-      GNUNET_assert (dht_qe != NULL);
-    }
+  if (GSF_dsh == NULL)
+    return;
+  if (dht_put_type == GNUNET_BLOCK_TYPE_FS_ONDEMAND)
+    dht_put_type = GNUNET_BLOCK_TYPE_FS_KBLOCK;
+  dht_qe = GNUNET_DATASTORE_get_zero_anonymity (GSF_dsh, 
+                                               0, UINT_MAX,
+                                               GNUNET_TIME_UNIT_FOREVER_REL,
+                                               dht_put_type++,
+                                               &process_dht_put_content, NULL);
+  GNUNET_assert (dht_qe != NULL);
 }