From 78469082de0b7fa49724504b7e21bb2e9b4bef05 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Fri, 25 Mar 2011 08:48:14 +0000 Subject: [PATCH] better API --- src/datastore/datastore.h | 2 +- src/datastore/datastore_api.c | 37 ++++--------------- src/datastore/perf_datastore_api.c | 4 +- src/datastore/test_datastore_api.c | 8 ++-- src/datastore/test_datastore_api_management.c | 2 +- src/include/gnunet_datastore_service.h | 5 +-- 6 files changed, 17 insertions(+), 41 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 @@ #ifndef DATASTORE_H #define DATASTORE_H -#define DEBUG_DATASTORE GNUNET_NO +#define DEBUG_DATASTORE GNUNET_YES #include "gnunet_util_lib.h" 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, 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); 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, 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); } 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, 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); } 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, 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); } diff --git a/src/include/gnunet_datastore_service.h b/src/include/gnunet_datastore_service.h index 4c9fad965..e9cb8a76f 100644 --- a/src/include/gnunet_datastore_service.h +++ b/src/include/gnunet_datastore_service.h @@ -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); /** -- 2.25.1