better API
authorChristian Grothoff <christian@grothoff.org>
Fri, 25 Mar 2011 08:48:14 +0000 (08:48 +0000)
committerChristian Grothoff <christian@grothoff.org>
Fri, 25 Mar 2011 08:48:14 +0000 (08:48 +0000)
src/datastore/datastore.h
src/datastore/datastore_api.c
src/datastore/perf_datastore_api.c
src/datastore/test_datastore_api.c
src/datastore/test_datastore_api_management.c
src/include/gnunet_datastore_service.h

index 8fa0ca0446559539416e4a2ffaa8aa4f6ecc4503..55ca7c8e5c7e9c2a4f4dbdb425ae3ddd3d971877 100644 (file)
@@ -27,7 +27,7 @@
 #ifndef DATASTORE_H
 #define DATASTORE_H
 
-#define DEBUG_DATASTORE GNUNET_NO
+#define DEBUG_DATASTORE GNUNET_YES
 
 #include "gnunet_util_lib.h"
 
index f9b3db81bdf8c7646594d46fad9331e0181ee21c..cf6a2cc8e0a44bf9ced5eed25f2c8dd2d4bd64ff 100644 (file)
@@ -1197,11 +1197,12 @@ process_result_message (void *cls,
   if (ntohs(msg->type) == GNUNET_MESSAGE_TYPE_DATASTORE_DATA_END) 
     {
       GNUNET_break (ntohs(msg->size) == sizeof(struct GNUNET_MessageHeader));
+      free_queue_entry (qe);
 #if DEBUG_DATASTORE
       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                 "Received end of result set\n");
+                 "Received end of result set, new queue size is %u\n",
+                 h->queue_size);
 #endif
-      free_queue_entry (qe);
       if (rc.iter != NULL)
        rc.iter (rc.iter_cls,
                 NULL, 0, NULL, 0, 0, 0, 
@@ -1247,7 +1248,7 @@ process_result_message (void *cls,
          do_disconnect (h);      
          return;
        }
-      GNUNET_DATASTORE_get_next (h, GNUNET_NO);
+      GNUNET_DATASTORE_get_next (h);
       return;
     }
   dm = (const struct DataMessage*) msg;
@@ -1473,26 +1474,13 @@ GNUNET_DATASTORE_get (struct GNUNET_DATASTORE_Handle *h,
  * from the datastore.
  * 
  * @param h handle to the datastore
- * @param more GNUNET_YES to get moxre results, GNUNET_NO to abort
- *        iteration (with a final call to "iter" with key/data == NULL).
  */
 void 
-GNUNET_DATASTORE_get_next (struct GNUNET_DATASTORE_Handle *h,
-                          int more)
+GNUNET_DATASTORE_get_next (struct GNUNET_DATASTORE_Handle *h)
 {
   struct GNUNET_DATASTORE_QueueEntry *qe = h->queue_head;
-  struct ResultContext rc = qe->qc.rc;
 
   GNUNET_assert (&process_result_message == qe->response_proc);
-  if (GNUNET_YES != more)
-    {
-      qe->qc.rc.iter = NULL;
-      qe->qc.rc.iter_cls = NULL;
-      if (rc.iter != NULL)
-       rc.iter (rc.iter_cls,
-                NULL, 0, NULL, 0, 0, 0, 
-                GNUNET_TIME_UNIT_ZERO_ABS, 0); 
-    }
   h->in_receive = GNUNET_YES;
   GNUNET_CLIENT_receive (h->client,
                         qe->response_proc,
@@ -1511,7 +1499,6 @@ void
 GNUNET_DATASTORE_cancel (struct GNUNET_DATASTORE_QueueEntry *qe)
 {
   struct GNUNET_DATASTORE_Handle *h;
-  int reconnect;
 
   h = qe->h;
 #if DEBUG_DATASTORE
@@ -1521,19 +1508,11 @@ GNUNET_DATASTORE_cancel (struct GNUNET_DATASTORE_QueueEntry *qe)
               qe->was_transmitted,
               h->queue_head == qe);
 #endif
-  reconnect = GNUNET_NO;
   if (GNUNET_YES == qe->was_transmitted) 
     {
-      if (qe->response_proc == &process_result_message)        
-       {
-         qe->qc.rc.iter = NULL;    
-         if (GNUNET_YES != h->in_receive)
-           GNUNET_DATASTORE_get_next (h, GNUNET_YES);
-       }
-      else
-       {
-         qe->qc.sc.cont = NULL;
-       }
+      free_queue_entry (qe);
+      h->retry_time = GNUNET_TIME_UNIT_ZERO;
+      do_disconnect (h);
       return;
     }
   free_queue_entry (qe);
index eb8c887448621b8c83470dae91c2134700bc3866..de9a8b23633048741967b94d8bee2000ae8249d0 100644 (file)
@@ -223,13 +223,13 @@ delete_value (void *cls,
   stored_ops++;
   if (stored_bytes < MAX_SIZE)
     {
-      GNUNET_DATASTORE_get_next (datastore, GNUNET_YES);
+      GNUNET_DATASTORE_get_next (datastore);
       return;     
     }
   crc->key = *key;
   crc->esize = size;
   memcpy (crc->data, data, size);
-  GNUNET_DATASTORE_get_next (datastore, GNUNET_YES);
+  GNUNET_DATASTORE_get_next (datastore);
 }
 
 
index b7809c3d74148caa7f3d4df692bb0ce9d62c0293..d8e4b7b342eec4183616e0e1274d192974408977 100644 (file)
@@ -210,7 +210,7 @@ check_value (void *cls,
   GNUNET_assert (priority == get_priority (i));
   GNUNET_assert (anonymity == get_anonymity(i));
   GNUNET_assert (expiration.abs_value == get_expiration(i).abs_value);
-  GNUNET_DATASTORE_get_next (datastore, GNUNET_YES);
+  GNUNET_DATASTORE_get_next (datastore);
 }
 
 
@@ -249,7 +249,7 @@ delete_value (void *cls,
   crc->key = *key;
   crc->data = GNUNET_malloc (size);
   memcpy (crc->data, data, size);
-  GNUNET_DATASTORE_get_next (datastore, GNUNET_YES);
+  GNUNET_DATASTORE_get_next (datastore);
 }
 
 
@@ -329,7 +329,7 @@ check_multiple (void *cls,
 #endif
   if (priority == get_priority (42))
     crc->uid = uid;
-  GNUNET_DATASTORE_get_next (datastore, GNUNET_YES);
+  GNUNET_DATASTORE_get_next (datastore);
 }
 
 
@@ -370,7 +370,7 @@ check_update (void *cls,
     }
   else
     GNUNET_assert (size == get_size (43));
-  GNUNET_DATASTORE_get_next (datastore, GNUNET_YES);
+  GNUNET_DATASTORE_get_next (datastore);
 }
 
 
index 1c490cbd4e85799cd525fb0159ebd733de67baab..2873caa02190621710e58bebdbba7f56db65a29b 100644 (file)
@@ -181,7 +181,7 @@ check_value (void *cls,
   GNUNET_assert (priority == get_priority (i));
   GNUNET_assert (anonymity == get_anonymity(i));
   GNUNET_assert (expiration.abs_value == get_expiration(i).abs_value);
-  GNUNET_DATASTORE_get_next (datastore, GNUNET_YES);
+  GNUNET_DATASTORE_get_next (datastore);
 }
 
 
index 4c9fad965e590c39111026d23dbbc1d0ecf4bffb..e9cb8a76fe4f5f14cc0d058ed7cc52c660a130fb 100644 (file)
@@ -317,12 +317,9 @@ GNUNET_DATASTORE_get (struct GNUNET_DATASTORE_Handle *h,
  * from the datastore.
  * 
  * @param h handle to the datastore
- * @param more GNUNET_YES to get moxre results, GNUNET_NO to abort
- *        iteration (with a final call to "iter" with key/data == NULL).
  */
 void
-GNUNET_DATASTORE_get_next (struct GNUNET_DATASTORE_Handle *h,
-                          int more);
+GNUNET_DATASTORE_get_next (struct GNUNET_DATASTORE_Handle *h);
 
 
 /**