gnunet-svn
[Top][All Lists]
Advanced

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

[gnunet] branch master updated: PEERSTORE: Fix watcher test race conditi


From: gnunet
Subject: [gnunet] branch master updated: PEERSTORE: Fix watcher test race conditions
Date: Fri, 01 Mar 2024 11:17:33 +0100

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 c81e8cfda PEERSTORE: Fix watcher test race conditions
c81e8cfda is described below

commit c81e8cfda851a3c3a2c1ca9006f3d2e496cb1e69
Author: Martin Schanzenbach <schanzen@gnunet.org>
AuthorDate: Fri Mar 1 11:17:27 2024 +0100

    PEERSTORE: Fix watcher test race conditions
---
 src/service/peerstore/test_peerstore_api_watch.c | 35 ++++++++++++++++--------
 1 file changed, 23 insertions(+), 12 deletions(-)

diff --git a/src/service/peerstore/test_peerstore_api_watch.c 
b/src/service/peerstore/test_peerstore_api_watch.c
index e195bb814..9f547f2dd 100644
--- a/src/service/peerstore/test_peerstore_api_watch.c
+++ b/src/service/peerstore/test_peerstore_api_watch.c
@@ -35,6 +35,8 @@ static struct GNUNET_PEERSTORE_Handle *h;
 
 static struct GNUNET_PEERSTORE_Monitor *wc;
 
+static struct GNUNET_PEERSTORE_StoreContext *sr;
+
 static char *ss = "test_peerstore_api_watch";
 
 static char *k = "test_peerstore_api_watch_key";
@@ -46,8 +48,11 @@ static struct GNUNET_PeerIdentity p;
 static void
 finish (void *cls)
 {
+  if (NULL != sr)
+    GNUNET_PEERSTORE_store_cancel (sr);
+  if (NULL != wc)
+    GNUNET_PEERSTORE_monitor_stop (wc);
   GNUNET_PEERSTORE_disconnect (h);
-  GNUNET_PEERSTORE_monitor_stop(wc);
   GNUNET_SCHEDULER_shutdown ();
 }
 
@@ -55,16 +60,16 @@ finish (void *cls)
 static void
 cont (void *cls)
 {
-  GNUNET_PEERSTORE_store (h,
-                          ss,
-                          &p,
-                          k,
-                          val,
-                          strlen (val) + 1,
-                          GNUNET_TIME_UNIT_FOREVER_ABS,
-                          GNUNET_PEERSTORE_STOREOPTION_REPLACE,
-                          NULL,
-                          NULL);
+  sr = GNUNET_PEERSTORE_store (h,
+                               ss,
+                               &p,
+                               k,
+                               val,
+                               strlen (val) + 1,
+                               GNUNET_TIME_UNIT_FOREVER_ABS,
+                               GNUNET_PEERSTORE_STOREOPTION_REPLACE,
+                               NULL,
+                               NULL);
 }
 
 
@@ -76,7 +81,11 @@ watch_cb (void *cls,
           const char *emsg)
 {
   GNUNET_assert (NULL == emsg);
-  GNUNET_assert (GNUNET_YES != initial_iteration);
+  if (GNUNET_YES == initial_iteration)
+  {
+    GNUNET_PEERSTORE_monitor_next (wc, 1);
+    return;
+  }
   if (NULL == record)
   {
     GNUNET_break (0);
@@ -98,6 +107,7 @@ sync_cb (void *cls)
   initial_iteration = GNUNET_NO;
 }
 
+
 static void
 error_cb (void *cls)
 {
@@ -105,6 +115,7 @@ error_cb (void *cls)
   GNUNET_assert (0);
 }
 
+
 static void
 run (void *cls,
      const struct GNUNET_CONFIGURATION_Handle *cfg,

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

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