gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r8982 - in gnunet/src: datastore include


From: gnunet
Subject: [GNUnet-SVN] r8982 - in gnunet/src: datastore include
Date: Fri, 11 Sep 2009 08:21:00 -0600

Author: grothoff
Date: 2009-09-11 08:21:00 -0600 (Fri, 11 Sep 2009)
New Revision: 8982

Modified:
   gnunet/src/datastore/datastore_api.c
   gnunet/src/datastore/perf_datastore_api.c
   gnunet/src/datastore/test_datastore_api.c
   gnunet/src/datastore/test_datastore_api_management.c
   gnunet/src/include/gnunet_datastore_service.h
Log:
better datastore API

Modified: gnunet/src/datastore/datastore_api.c
===================================================================
--- gnunet/src/datastore/datastore_api.c        2009-09-11 11:47:30 UTC (rev 
8981)
+++ gnunet/src/datastore/datastore_api.c        2009-09-11 14:21:00 UTC (rev 
8982)
@@ -566,10 +566,6 @@
        ntohl(dm->anonymity),
        GNUNET_TIME_absolute_ntoh(dm->expiration),      
        GNUNET_ntohll(dm->uid));
-  GNUNET_CLIENT_receive (h->client,
-                        &with_result_response_handler,
-                        h,
-                        GNUNET_TIME_absolute_get_remaining (h->timeout));
 }
 
 
@@ -618,7 +614,40 @@
 }
 
 
+
 /**
+ * Function called to trigger obtaining the next result
+ * 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_Iterator cont;
+
+  if (GNUNET_YES == more)
+    {
+      GNUNET_CLIENT_receive (h->client,
+                            &with_result_response_handler,
+                            h,
+                            GNUNET_TIME_absolute_get_remaining (h->timeout));
+      return;
+    }
+  cont = h->response_proc;
+  h->response_proc = NULL;
+  GNUNET_CLIENT_disconnect (h->client);
+  h->client = GNUNET_CLIENT_connect (h->sched, "datastore", h->cfg);
+  cont (h->response_proc_cls, 
+       NULL, 0, NULL, 0, 0, 0, 
+       GNUNET_TIME_UNIT_ZERO_ABS, 0);
+}
+
+
+/**
  * Helper function that will initiate the
  * transmission of a message to the datastore
  * service.  The message must already be prepared

Modified: gnunet/src/datastore/perf_datastore_api.c
===================================================================
--- gnunet/src/datastore/perf_datastore_api.c   2009-09-11 11:47:30 UTC (rev 
8981)
+++ gnunet/src/datastore/perf_datastore_api.c   2009-09-11 14:21:00 UTC (rev 
8982)
@@ -230,10 +230,14 @@
     }
   stored_ops++;
   if (stored_bytes < MAX_SIZE)
-    return;     
+    {
+      GNUNET_DATASTORE_get_next (datastore, GNUNET_YES);
+      return;     
+    }
   crc->key = *key;
   crc->esize = size;
   memcpy (crc->data, data, size);
+  GNUNET_DATASTORE_get_next (datastore, GNUNET_YES);
 }
 
 

Modified: gnunet/src/datastore/test_datastore_api.c
===================================================================
--- gnunet/src/datastore/test_datastore_api.c   2009-09-11 11:47:30 UTC (rev 
8981)
+++ gnunet/src/datastore/test_datastore_api.c   2009-09-11 14:21:00 UTC (rev 
8982)
@@ -207,6 +207,7 @@
   GNUNET_assert (priority == get_priority (i));
   GNUNET_assert (anonymity == get_anonymity(i));
   GNUNET_assert (expiration.value == get_expiration(i).value);
+  GNUNET_DATASTORE_get_next (datastore, GNUNET_YES);
 }
 
 
@@ -237,6 +238,7 @@
   crc->key = *key;
   crc->data = GNUNET_malloc (size);
   memcpy (crc->data, data, size);
+  GNUNET_DATASTORE_get_next (datastore, GNUNET_YES);
 }
 
 
@@ -292,6 +294,7 @@
   crc->phase++;
   if (priority == get_priority (42))
     crc->uid = uid;
+  GNUNET_DATASTORE_get_next (datastore, GNUNET_YES);
 }
 
 
@@ -327,6 +330,7 @@
     }
   else
     GNUNET_assert (size == get_size (43));
+  GNUNET_DATASTORE_get_next (datastore, GNUNET_YES);
 }
 
 

Modified: gnunet/src/datastore/test_datastore_api_management.c
===================================================================
--- gnunet/src/datastore/test_datastore_api_management.c        2009-09-11 
11:47:30 UTC (rev 8981)
+++ gnunet/src/datastore/test_datastore_api_management.c        2009-09-11 
14:21:00 UTC (rev 8982)
@@ -186,6 +186,7 @@
   GNUNET_assert (priority == get_priority (i));
   GNUNET_assert (anonymity == get_anonymity(i));
   GNUNET_assert (expiration.value == get_expiration(i).value);
+  GNUNET_DATASTORE_get_next (datastore, GNUNET_YES);
 }
 
 

Modified: gnunet/src/include/gnunet_datastore_service.h
===================================================================
--- gnunet/src/include/gnunet_datastore_service.h       2009-09-11 11:47:30 UTC 
(rev 8981)
+++ gnunet/src/include/gnunet_datastore_service.h       2009-09-11 14:21:00 UTC 
(rev 8982)
@@ -218,7 +218,10 @@
 
 /**
  * Iterate over the results for a particular key
- * in the datastore.
+ * in the datastore.  The iterator will only be called
+ * once initially; if the first call did contain a
+ * result, further results can be obtained by calling
+ * "GNUNET_DATASTORE_get_next" with the given argument.
  *
  * @param h handle to the datastore
  * @param key maybe NULL (to match all entries)
@@ -232,11 +235,25 @@
 GNUNET_DATASTORE_get (struct GNUNET_DATASTORE_Handle *h,
                       const GNUNET_HashCode * key,
                      uint32_t type,
-                      GNUNET_DATASTORE_Iterator iter, void *iter_cls,
+                      GNUNET_DATASTORE_Iterator iter, 
+                     void *iter_cls,
                      struct GNUNET_TIME_Relative timeout);
 
 
 /**
+ * Function called to trigger obtaining the next result
+ * 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);
+
+
+/**
  * Get a random value from the datastore.
  *
  * @param h handle to the datastore





reply via email to

[Prev in Thread] Current Thread [Next in Thread]