fix
[oweals/gnunet.git] / src / fs / gnunet-service-fs_drq.c
index 43e138e131439c0359e1ac0a36ef7f16b3159dd4..b549c6707ab5979988bd9eb5758eeb45ad7b9aea 100644 (file)
@@ -83,7 +83,7 @@ struct DatastoreRequestQueue
   /**
    * Datastore entry type we are doing the 'get' for.
    */
-  uint32_t type;
+  enum GNUNET_BLOCK_Type type;
 
   /**
    * Is this request at the head of the queue irrespective of its
@@ -113,10 +113,6 @@ static struct DatastoreRequestQueue *drq_head;
  */
 static struct DatastoreRequestQueue *drq_tail;
 
-/**
- * Our connection to the datastore.
- */
-static struct GNUNET_DATASTORE_Handle *dsh;
 
 /**
  * Pointer to the currently actively running request,
@@ -154,7 +150,7 @@ get_iterator (void *cls,
              const GNUNET_HashCode * key,
              uint32_t size,
              const void *data,
-             uint32_t type,
+             enum GNUNET_BLOCK_Type type,
              uint32_t priority,
              uint32_t anonymity,
              struct GNUNET_TIME_Absolute
@@ -222,9 +218,10 @@ run_next_request (void *cls,
   GNUNET_DATASTORE_get (dsh, 
                        &gc->key,
                        gc->type, 
+                       42 /* FIXME */, 64 /* FIXME */,
+                       GNUNET_TIME_absolute_get_remaining(gc->timeout),
                        &get_iterator,
-                       gc,
-                       GNUNET_TIME_absolute_get_remaining(gc->timeout));
+                       gc);
 }
 
 
@@ -294,9 +291,6 @@ shutdown_task (void *cls,
              "DRQ shutdown initiated\n");
 #endif
   GNUNET_assert (NULL != dsh);
-  GNUNET_DATASTORE_disconnect (dsh,
-                              GNUNET_NO);
-  dsh = NULL;
   while (NULL != (drq = drq_head))
     {
       drq_head = drq->next;
@@ -310,11 +304,17 @@ shutdown_task (void *cls,
   drq_tail = NULL;
   if (drq_running != NULL)
     {
-      GNUNET_SCHEDULER_cancel (sched,
-                              drq_running->task);
-      drq_running->iter (drq_running->iter_cls,
-                        NULL, 0, NULL, 0, 0, 0, 
-                        GNUNET_TIME_UNIT_ZERO_ABS, 0);
+      if (drq_running->task != GNUNET_SCHEDULER_NO_TASK)
+       {
+         GNUNET_SCHEDULER_cancel (sched,
+                                  drq_running->task);
+       }
+      if (drq_running->iter != NULL)
+       {
+         drq_running->iter (drq_running->iter_cls,
+                            NULL, 0, NULL, 0, 0, 0, 
+                            GNUNET_TIME_UNIT_ZERO_ABS, 0);
+       }
       GNUNET_free (drq_running);
       drq_running = NULL;
     }
@@ -339,7 +339,7 @@ shutdown_task (void *cls,
  */
 struct DatastoreRequestQueue *
 GNUNET_FS_drq_get (const GNUNET_HashCode * key,
-                  uint32_t type,
+                  enum GNUNET_BLOCK_Type type,
                   GNUNET_DATASTORE_Iterator iter, 
                   void *iter_cls,
                   struct GNUNET_TIME_Relative timeout,
@@ -458,7 +458,6 @@ drq_remove_cont (void *cls,
   rc->cont (rc->cont_cls,
            success,
            msg);
-  GNUNET_DATASTORE_disconnect (rc->rmdsh, GNUNET_NO);
   GNUNET_free (rc);
 }
 
@@ -487,8 +486,6 @@ GNUNET_FS_drq_remove (const GNUNET_HashCode *key,
   struct GNUNET_DATASTORE_Handle *rmdsh; 
   struct RemoveContext *rc;
 
-  rmdsh = GNUNET_DATASTORE_connect (cfg,
-                                   sched);
   if (rmdsh == NULL)
     {
       GNUNET_break (0);
@@ -502,8 +499,10 @@ GNUNET_FS_drq_remove (const GNUNET_HashCode *key,
   rc->cont_cls = cont_cls;
   rc->rmdsh = rmdsh;
   GNUNET_DATASTORE_remove (rmdsh, key, size, data,
+                          -3, 128,
+                          timeout,
                           &drq_remove_cont, 
-                          rc, timeout);
+                          rc);
 }