aboutsummaryrefslogtreecommitdiff
path: root/src/datastore
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2011-03-25 08:48:14 +0000
committerChristian Grothoff <christian@grothoff.org>2011-03-25 08:48:14 +0000
commit78469082de0b7fa49724504b7e21bb2e9b4bef05 (patch)
treecc672be10a2a40003828ec18844774150f27b9ba /src/datastore
parent2574474f98d5a4feefab2bbd7092c9d0ff9d64e8 (diff)
downloadgnunet-78469082de0b7fa49724504b7e21bb2e9b4bef05.tar.gz
gnunet-78469082de0b7fa49724504b7e21bb2e9b4bef05.zip
better API
Diffstat (limited to 'src/datastore')
-rw-r--r--src/datastore/datastore.h2
-rw-r--r--src/datastore/datastore_api.c37
-rw-r--r--src/datastore/perf_datastore_api.c4
-rw-r--r--src/datastore/test_datastore_api.c8
-rw-r--r--src/datastore/test_datastore_api_management.c2
5 files changed, 16 insertions, 37 deletions
diff --git a/src/datastore/datastore.h b/src/datastore/datastore.h
index 8fa0ca044..55ca7c8e5 100644
--- a/src/datastore/datastore.h
+++ b/src/datastore/datastore.h
@@ -27,7 +27,7 @@
27#ifndef DATASTORE_H 27#ifndef DATASTORE_H
28#define DATASTORE_H 28#define DATASTORE_H
29 29
30#define DEBUG_DATASTORE GNUNET_NO 30#define DEBUG_DATASTORE GNUNET_YES
31 31
32#include "gnunet_util_lib.h" 32#include "gnunet_util_lib.h"
33 33
diff --git a/src/datastore/datastore_api.c b/src/datastore/datastore_api.c
index f9b3db81b..cf6a2cc8e 100644
--- a/src/datastore/datastore_api.c
+++ b/src/datastore/datastore_api.c
@@ -1197,11 +1197,12 @@ process_result_message (void *cls,
1197 if (ntohs(msg->type) == GNUNET_MESSAGE_TYPE_DATASTORE_DATA_END) 1197 if (ntohs(msg->type) == GNUNET_MESSAGE_TYPE_DATASTORE_DATA_END)
1198 { 1198 {
1199 GNUNET_break (ntohs(msg->size) == sizeof(struct GNUNET_MessageHeader)); 1199 GNUNET_break (ntohs(msg->size) == sizeof(struct GNUNET_MessageHeader));
1200 free_queue_entry (qe);
1200#if DEBUG_DATASTORE 1201#if DEBUG_DATASTORE
1201 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1202 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1202 "Received end of result set\n"); 1203 "Received end of result set, new queue size is %u\n",
1204 h->queue_size);
1203#endif 1205#endif
1204 free_queue_entry (qe);
1205 if (rc.iter != NULL) 1206 if (rc.iter != NULL)
1206 rc.iter (rc.iter_cls, 1207 rc.iter (rc.iter_cls,
1207 NULL, 0, NULL, 0, 0, 0, 1208 NULL, 0, NULL, 0, 0, 0,
@@ -1247,7 +1248,7 @@ process_result_message (void *cls,
1247 do_disconnect (h); 1248 do_disconnect (h);
1248 return; 1249 return;
1249 } 1250 }
1250 GNUNET_DATASTORE_get_next (h, GNUNET_NO); 1251 GNUNET_DATASTORE_get_next (h);
1251 return; 1252 return;
1252 } 1253 }
1253 dm = (const struct DataMessage*) msg; 1254 dm = (const struct DataMessage*) msg;
@@ -1473,26 +1474,13 @@ GNUNET_DATASTORE_get (struct GNUNET_DATASTORE_Handle *h,
1473 * from the datastore. 1474 * from the datastore.
1474 * 1475 *
1475 * @param h handle to the datastore 1476 * @param h handle to the datastore
1476 * @param more GNUNET_YES to get moxre results, GNUNET_NO to abort
1477 * iteration (with a final call to "iter" with key/data == NULL).
1478 */ 1477 */
1479void 1478void
1480GNUNET_DATASTORE_get_next (struct GNUNET_DATASTORE_Handle *h, 1479GNUNET_DATASTORE_get_next (struct GNUNET_DATASTORE_Handle *h)
1481 int more)
1482{ 1480{
1483 struct GNUNET_DATASTORE_QueueEntry *qe = h->queue_head; 1481 struct GNUNET_DATASTORE_QueueEntry *qe = h->queue_head;
1484 struct ResultContext rc = qe->qc.rc;
1485 1482
1486 GNUNET_assert (&process_result_message == qe->response_proc); 1483 GNUNET_assert (&process_result_message == qe->response_proc);
1487 if (GNUNET_YES != more)
1488 {
1489 qe->qc.rc.iter = NULL;
1490 qe->qc.rc.iter_cls = NULL;
1491 if (rc.iter != NULL)
1492 rc.iter (rc.iter_cls,
1493 NULL, 0, NULL, 0, 0, 0,
1494 GNUNET_TIME_UNIT_ZERO_ABS, 0);
1495 }
1496 h->in_receive = GNUNET_YES; 1484 h->in_receive = GNUNET_YES;
1497 GNUNET_CLIENT_receive (h->client, 1485 GNUNET_CLIENT_receive (h->client,
1498 qe->response_proc, 1486 qe->response_proc,
@@ -1511,7 +1499,6 @@ void
1511GNUNET_DATASTORE_cancel (struct GNUNET_DATASTORE_QueueEntry *qe) 1499GNUNET_DATASTORE_cancel (struct GNUNET_DATASTORE_QueueEntry *qe)
1512{ 1500{
1513 struct GNUNET_DATASTORE_Handle *h; 1501 struct GNUNET_DATASTORE_Handle *h;
1514 int reconnect;
1515 1502
1516 h = qe->h; 1503 h = qe->h;
1517#if DEBUG_DATASTORE 1504#if DEBUG_DATASTORE
@@ -1521,19 +1508,11 @@ GNUNET_DATASTORE_cancel (struct GNUNET_DATASTORE_QueueEntry *qe)
1521 qe->was_transmitted, 1508 qe->was_transmitted,
1522 h->queue_head == qe); 1509 h->queue_head == qe);
1523#endif 1510#endif
1524 reconnect = GNUNET_NO;
1525 if (GNUNET_YES == qe->was_transmitted) 1511 if (GNUNET_YES == qe->was_transmitted)
1526 { 1512 {
1527 if (qe->response_proc == &process_result_message) 1513 free_queue_entry (qe);
1528 { 1514 h->retry_time = GNUNET_TIME_UNIT_ZERO;
1529 qe->qc.rc.iter = NULL; 1515 do_disconnect (h);
1530 if (GNUNET_YES != h->in_receive)
1531 GNUNET_DATASTORE_get_next (h, GNUNET_YES);
1532 }
1533 else
1534 {
1535 qe->qc.sc.cont = NULL;
1536 }
1537 return; 1516 return;
1538 } 1517 }
1539 free_queue_entry (qe); 1518 free_queue_entry (qe);
diff --git a/src/datastore/perf_datastore_api.c b/src/datastore/perf_datastore_api.c
index eb8c88744..de9a8b236 100644
--- a/src/datastore/perf_datastore_api.c
+++ b/src/datastore/perf_datastore_api.c
@@ -223,13 +223,13 @@ delete_value (void *cls,
223 stored_ops++; 223 stored_ops++;
224 if (stored_bytes < MAX_SIZE) 224 if (stored_bytes < MAX_SIZE)
225 { 225 {
226 GNUNET_DATASTORE_get_next (datastore, GNUNET_YES); 226 GNUNET_DATASTORE_get_next (datastore);
227 return; 227 return;
228 } 228 }
229 crc->key = *key; 229 crc->key = *key;
230 crc->esize = size; 230 crc->esize = size;
231 memcpy (crc->data, data, size); 231 memcpy (crc->data, data, size);
232 GNUNET_DATASTORE_get_next (datastore, GNUNET_YES); 232 GNUNET_DATASTORE_get_next (datastore);
233} 233}
234 234
235 235
diff --git a/src/datastore/test_datastore_api.c b/src/datastore/test_datastore_api.c
index b7809c3d7..d8e4b7b34 100644
--- a/src/datastore/test_datastore_api.c
+++ b/src/datastore/test_datastore_api.c
@@ -210,7 +210,7 @@ check_value (void *cls,
210 GNUNET_assert (priority == get_priority (i)); 210 GNUNET_assert (priority == get_priority (i));
211 GNUNET_assert (anonymity == get_anonymity(i)); 211 GNUNET_assert (anonymity == get_anonymity(i));
212 GNUNET_assert (expiration.abs_value == get_expiration(i).abs_value); 212 GNUNET_assert (expiration.abs_value == get_expiration(i).abs_value);
213 GNUNET_DATASTORE_get_next (datastore, GNUNET_YES); 213 GNUNET_DATASTORE_get_next (datastore);
214} 214}
215 215
216 216
@@ -249,7 +249,7 @@ delete_value (void *cls,
249 crc->key = *key; 249 crc->key = *key;
250 crc->data = GNUNET_malloc (size); 250 crc->data = GNUNET_malloc (size);
251 memcpy (crc->data, data, size); 251 memcpy (crc->data, data, size);
252 GNUNET_DATASTORE_get_next (datastore, GNUNET_YES); 252 GNUNET_DATASTORE_get_next (datastore);
253} 253}
254 254
255 255
@@ -329,7 +329,7 @@ check_multiple (void *cls,
329#endif 329#endif
330 if (priority == get_priority (42)) 330 if (priority == get_priority (42))
331 crc->uid = uid; 331 crc->uid = uid;
332 GNUNET_DATASTORE_get_next (datastore, GNUNET_YES); 332 GNUNET_DATASTORE_get_next (datastore);
333} 333}
334 334
335 335
@@ -370,7 +370,7 @@ check_update (void *cls,
370 } 370 }
371 else 371 else
372 GNUNET_assert (size == get_size (43)); 372 GNUNET_assert (size == get_size (43));
373 GNUNET_DATASTORE_get_next (datastore, GNUNET_YES); 373 GNUNET_DATASTORE_get_next (datastore);
374} 374}
375 375
376 376
diff --git a/src/datastore/test_datastore_api_management.c b/src/datastore/test_datastore_api_management.c
index 1c490cbd4..2873caa02 100644
--- a/src/datastore/test_datastore_api_management.c
+++ b/src/datastore/test_datastore_api_management.c
@@ -181,7 +181,7 @@ check_value (void *cls,
181 GNUNET_assert (priority == get_priority (i)); 181 GNUNET_assert (priority == get_priority (i));
182 GNUNET_assert (anonymity == get_anonymity(i)); 182 GNUNET_assert (anonymity == get_anonymity(i));
183 GNUNET_assert (expiration.abs_value == get_expiration(i).abs_value); 183 GNUNET_assert (expiration.abs_value == get_expiration(i).abs_value);
184 GNUNET_DATASTORE_get_next (datastore, GNUNET_YES); 184 GNUNET_DATASTORE_get_next (datastore);
185} 185}
186 186
187 187