From d8d3021ad9af2abe551fd6cd0fe2529a99d3683c Mon Sep 17 00:00:00 2001 From: Martin Schanzenbach Date: Sat, 18 Jun 2016 21:49:23 +0000 Subject: -fix --- src/peerstore/perf_peerstore_store.c | 3 +-- src/peerstore/test_peerstore_api_iterate.c | 37 ++++++++++++++++++------------ src/peerstore/test_peerstore_api_sync.c | 4 +--- src/peerstore/test_peerstore_api_watch.c | 3 +-- src/peerstore/test_plugin_peerstore.c | 5 ++-- 5 files changed, 27 insertions(+), 25 deletions(-) (limited to 'src') diff --git a/src/peerstore/perf_peerstore_store.c b/src/peerstore/perf_peerstore_store.c index 68df273dc..82a3adec1 100644 --- a/src/peerstore/perf_peerstore_store.c +++ b/src/peerstore/perf_peerstore_store.c @@ -60,7 +60,7 @@ store () } -static int +static void watch_cb (void *cls, const struct GNUNET_PEERSTORE_Record *record, const char *emsg) { @@ -72,7 +72,6 @@ watch_cb (void *cls, const struct GNUNET_PEERSTORE_Record *record, } else store (); - return GNUNET_YES; } diff --git a/src/peerstore/test_peerstore_api_iterate.c b/src/peerstore/test_peerstore_api_iterate.c index 797b3146e..83a6bf7b7 100644 --- a/src/peerstore/test_peerstore_api_iterate.c +++ b/src/peerstore/test_peerstore_api_iterate.c @@ -29,6 +29,7 @@ static int ok = 1; static struct GNUNET_PEERSTORE_Handle *h; +static struct GNUNET_PEERSTORE_IterateContext *ic; static char *ss = "test_peerstore_api_iterate"; static struct GNUNET_PeerIdentity p1; @@ -40,60 +41,66 @@ static char *val = "test_peerstore_api_iterate_val"; static int count = 0; -static int +static void iter3_cb (void *cls, const struct GNUNET_PEERSTORE_Record *record, const char *emsg) { if (NULL != emsg) - return GNUNET_NO; + { + GNUNET_PEERSTORE_iterate_cancel (ic); + return; + } if (NULL != record) { count++; - return GNUNET_YES; + return; } GNUNET_assert (count == 3); ok = 0; GNUNET_PEERSTORE_disconnect (h, GNUNET_NO); GNUNET_SCHEDULER_shutdown (); - return GNUNET_YES; } -static int +static void iter2_cb (void *cls, const struct GNUNET_PEERSTORE_Record *record, const char *emsg) { if (NULL != emsg) - return GNUNET_NO; + { + GNUNET_PEERSTORE_iterate_cancel (ic); + return; + } if (NULL != record) { count++; - return GNUNET_YES; + return; } GNUNET_assert (count == 2); count = 0; - GNUNET_PEERSTORE_iterate (h, ss, NULL, NULL, GNUNET_TIME_UNIT_FOREVER_REL, + ic = GNUNET_PEERSTORE_iterate (h, ss, NULL, NULL, GNUNET_TIME_UNIT_FOREVER_REL, iter3_cb, NULL); - return GNUNET_YES; } -static int +static void iter1_cb (void *cls, const struct GNUNET_PEERSTORE_Record *record, const char *emsg) { if (NULL != emsg) - return GNUNET_NO; + { + GNUNET_PEERSTORE_iterate_cancel (ic); + return; + } if (NULL != record) { count++; - return GNUNET_YES; + return; } GNUNET_assert (count == 1); count = 0; - GNUNET_PEERSTORE_iterate (h, ss, &p1, NULL, GNUNET_TIME_UNIT_FOREVER_REL, + ic = GNUNET_PEERSTORE_iterate (h, ss, &p1, NULL, GNUNET_TIME_UNIT_FOREVER_REL, iter2_cb, NULL); - return GNUNET_YES; } @@ -114,7 +121,7 @@ run (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_PEERSTORE_store (h, ss, &p2, k3, val, strlen (val) + 1, GNUNET_TIME_UNIT_FOREVER_ABS, GNUNET_PEERSTORE_STOREOPTION_REPLACE, NULL, NULL); - GNUNET_PEERSTORE_iterate (h, ss, &p1, k1, GNUNET_TIME_UNIT_FOREVER_REL, + ic = GNUNET_PEERSTORE_iterate (h, ss, &p1, k1, GNUNET_TIME_UNIT_FOREVER_REL, iter1_cb, NULL); } diff --git a/src/peerstore/test_peerstore_api_sync.c b/src/peerstore/test_peerstore_api_sync.c index 765ae9113..06d100100 100644 --- a/src/peerstore/test_peerstore_api_sync.c +++ b/src/peerstore/test_peerstore_api_sync.c @@ -79,7 +79,7 @@ static const char *val = "test_peerstore_api_store_val"; * @param emsg any error message * @return #GNUNET_YES (all good, continue) */ -static int +static void iterate_cb (void *cls, const struct GNUNET_PEERSTORE_Record *record, const char *emsg) @@ -92,12 +92,10 @@ iterate_cb (void *cls, GNUNET_PEERSTORE_disconnect (h, GNUNET_NO); GNUNET_SCHEDULER_shutdown (); - return GNUNET_YES; } rec_val = record->value; GNUNET_break (0 == strcmp (rec_val, val)); ok = 0; - return GNUNET_YES; } diff --git a/src/peerstore/test_peerstore_api_watch.c b/src/peerstore/test_peerstore_api_watch.c index 27948294f..91902ba9e 100644 --- a/src/peerstore/test_peerstore_api_watch.c +++ b/src/peerstore/test_peerstore_api_watch.c @@ -35,7 +35,7 @@ static struct GNUNET_PeerIdentity p; static char *k = "test_peerstore_api_watch_key"; static char *val = "test_peerstore_api_watch_val"; -static int +static void watch_cb (void *cls, const struct GNUNET_PEERSTORE_Record *record, const char *emsg) { @@ -44,7 +44,6 @@ watch_cb (void *cls, const struct GNUNET_PEERSTORE_Record *record, ok = 0; GNUNET_PEERSTORE_disconnect (h, GNUNET_NO); GNUNET_SCHEDULER_shutdown (); - return GNUNET_YES; } diff --git a/src/peerstore/test_plugin_peerstore.c b/src/peerstore/test_plugin_peerstore.c index da78b3f75..179e32b52 100644 --- a/src/peerstore/test_plugin_peerstore.c +++ b/src/peerstore/test_plugin_peerstore.c @@ -79,7 +79,7 @@ load_plugin (const struct GNUNET_CONFIGURATION_Handle *cfg) } -static int +static void test_record (void *cls, const struct GNUNET_PEERSTORE_Record *record, const char *error) @@ -88,13 +88,12 @@ test_record (void *cls, char* testval = "test_val"; if (NULL == record) - return GNUNET_NO; + return; GNUNET_assert (0 == memcmp (record->peer, id, sizeof (struct GNUNET_PeerIdentity))); GNUNET_assert (0 == strcmp ("subsys", record->sub_system)); GNUNET_assert (0 == strcmp ("key", record->key)); GNUNET_assert (0 == memcmp (testval, record->value, strlen (testval))); - return GNUNET_YES; } -- cgit v1.2.3