[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnunet] branch master updated: -fix peerstore api and tests
From: |
gnunet |
Subject: |
[gnunet] branch master updated: -fix peerstore api and tests |
Date: |
Sun, 28 Mar 2021 16:17:11 +0200 |
This is an automated email from the git hooks/post-receive script.
martin-schanzenbach pushed a commit to branch master
in repository gnunet.
The following commit(s) were added to refs/heads/master by this push:
new 3515b8cb3 -fix peerstore api and tests
3515b8cb3 is described below
commit 3515b8cb39b2c240a6d4af298d83862fb7a502d0
Author: Martin Schanzenbach <mschanzenbach@posteo.de>
AuthorDate: Sun Mar 28 16:15:25 2021 +0200
-fix peerstore api and tests
---
src/peerstore/peerstore_api.c | 5 ++
src/peerstore/test_peerstore_api_sync.c | 87 +++++++++++++++++++++++++++------
2 files changed, 76 insertions(+), 16 deletions(-)
diff --git a/src/peerstore/peerstore_api.c b/src/peerstore/peerstore_api.c
index db5aee0d5..196d44faa 100644
--- a/src/peerstore/peerstore_api.c
+++ b/src/peerstore/peerstore_api.c
@@ -823,7 +823,12 @@ reconnect (void *cls)
&handle_client_error,
h);
if (NULL == h->mq)
+ {
+ h->reconnect_task =
+ GNUNET_SCHEDULER_add_delayed (h->reconnect_delay, &reconnect, h);
+ h->reconnect_delay = GNUNET_TIME_STD_BACKOFF (h->reconnect_delay);
return;
+ }
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Resending pending requests after reconnect.\n");
if (NULL != h->watches)
diff --git a/src/peerstore/test_peerstore_api_sync.c
b/src/peerstore/test_peerstore_api_sync.c
index 4c826c654..5057c98b5 100644
--- a/src/peerstore/test_peerstore_api_sync.c
+++ b/src/peerstore/test_peerstore_api_sync.c
@@ -66,6 +66,24 @@ static const char *key = "test_peerstore_api_store_key";
static const char *val = "test_peerstore_api_store_val";
+/**
+ * Timeout
+ */
+#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10)
+
+/**
+ * Timeout task
+ */
+static struct GNUNET_SCHEDULER_Task *to;
+
+/**
+ * Iterate handle
+ */
+static struct GNUNET_PEERSTORE_IterateContext *it;
+
+static void
+test_cont (void *cls);
+
/**
* Function that should be called with the result of the
* lookup, and finally once with NULL to signal the end
@@ -89,9 +107,24 @@ iterate_cb (void *cls,
GNUNET_break (NULL == emsg);
if (NULL == record)
{
- GNUNET_PEERSTORE_disconnect (h,
- GNUNET_NO);
- GNUNET_SCHEDULER_shutdown ();
+ it = NULL;
+ if (0 == ok)
+ {
+ GNUNET_PEERSTORE_disconnect (h,
+ GNUNET_NO);
+ if (NULL != to)
+ {
+ GNUNET_SCHEDULER_cancel (to);
+ to = NULL;
+ }
+ GNUNET_SCHEDULER_shutdown ();
+ return;
+ }
+ /**
+ * Try again
+ */
+ GNUNET_SCHEDULER_add_now (&test_cont,
+ NULL);
return;
}
rec_val = record->value;
@@ -100,6 +133,22 @@ iterate_cb (void *cls,
}
+static void
+timeout_task (void *cls)
+{
+ to = NULL;
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Timeout reached\n");
+ if (NULL != it)
+ GNUNET_PEERSTORE_iterate_cancel (it);
+ it = NULL;
+ GNUNET_PEERSTORE_disconnect (h,
+ GNUNET_NO);
+ GNUNET_SCHEDULER_shutdown ();
+ return;
+}
+
+
/**
* Run the 2nd stage of the test where we fetch the
* data that should have been stored.
@@ -109,12 +158,11 @@ iterate_cb (void *cls,
static void
test_cont (void *cls)
{
- h = GNUNET_PEERSTORE_connect (cfg);
- GNUNET_PEERSTORE_iterate (h,
- subsystem,
- &pid, key,
- &iterate_cb,
- NULL);
+ it = GNUNET_PEERSTORE_iterate (h,
+ subsystem,
+ &pid, key,
+ &iterate_cb,
+ NULL);
}
@@ -122,10 +170,9 @@ static void
disc_cont (void *cls)
{
GNUNET_PEERSTORE_disconnect (h, GNUNET_YES);
- h = NULL;
- GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
- &test_cont,
- NULL);
+ h = GNUNET_PEERSTORE_connect (cfg);
+ GNUNET_SCHEDULER_add_now (&test_cont,
+ NULL);
}
@@ -133,12 +180,17 @@ static void
store_cont (void *cls, int success)
{
ok = success;
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Success: %s\n",
+ (GNUNET_SYSERR == ok) ? "no" : "yes");
/* We need to wait a little bit to give the disconnect
a chance to actually finish the operation; otherwise,
the test may fail non-deterministically if the new
connection is faster than the cleanup routine of the
- old one. */GNUNET_SCHEDULER_add_now (&disc_cont,
- NULL);
+ old one. */
+ GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
+ &disc_cont,
+ NULL);
}
@@ -174,7 +226,10 @@ run (void *cls,
{
cfg = c;
memset (&pid, 1, sizeof(pid));
- test1 ();
+ to = GNUNET_SCHEDULER_add_delayed (TIMEOUT,
+ &timeout_task,
+ NULL);
+ GNUNET_SCHEDULER_add_now (&test1, NULL);
}
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gnunet] branch master updated: -fix peerstore api and tests,
gnunet <=