gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] [gnunet] branch master updated (2408ee6b2 -> 89297d378)


From: gnunet
Subject: [GNUnet-SVN] [gnunet] branch master updated (2408ee6b2 -> 89297d378)
Date: Thu, 11 Oct 2018 16:36:34 +0200

This is an automated email from the git hooks/post-receive script.

julius-buenger pushed a change to branch master
in repository gnunet.

    from 2408ee6b2 RPS Tests: Test Subs
     new b5f742977 RPS API: (Temporarily) Fix usage of stream request handles
     new 70bdd2cc2 RPS API: Add API calls to rps header
     new 89297d378 RPS tests: Refine tests for subs

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 src/include/gnunet_rps_service.h | 32 ++++++++++++++++++++++++++
 src/rps/rps_api.c                | 29 ++++++++++++++++++++----
 src/rps/test_rps.c               | 49 +++++++++++++++++++++++++++++++++-------
 3 files changed, 97 insertions(+), 13 deletions(-)

diff --git a/src/include/gnunet_rps_service.h b/src/include/gnunet_rps_service.h
index f77c3dbc4..7fdfe491e 100644
--- a/src/include/gnunet_rps_service.h
+++ b/src/include/gnunet_rps_service.h
@@ -73,6 +73,29 @@ typedef void (* GNUNET_RPS_NotifyReadyCB) (void *cls,
   struct GNUNET_RPS_Handle *
 GNUNET_RPS_connect (const struct GNUNET_CONFIGURATION_Handle *cfg);
 
+
+/**
+ * @brief Start a sub with the given shared value
+ *
+ * @param h Handle to rps
+ * @param shared_value The shared value that defines the members of the sub 
(-gorup)
+ */
+void
+GNUNET_RPS_sub_start (struct GNUNET_RPS_Handle *h,
+                      const char *shared_value);
+
+
+/**
+ * @brief Stop a sub with the given shared value
+ *
+ * @param h Handle to rps
+ * @param shared_value The shared value that defines the members of the sub 
(-gorup)
+ */
+void
+GNUNET_RPS_sub_stop (struct GNUNET_RPS_Handle *h,
+                     const char *shared_value);
+
+
 /**
  * Request n random peers.
  *
@@ -170,6 +193,15 @@ GNUNET_RPS_stream_request (struct GNUNET_RPS_Handle 
*rps_handle,
 
 
 /**
+ * @brief Cancel a specific request for updates from the biased peer stream
+ *
+ * @param srh The request handle to cancel
+ */
+void
+GNUNET_RPS_stream_cancel (struct GNUNET_RPS_StreamRequestHandle *srh);
+
+
+/**
  * Disconnect from the rps service
  *
  * @param h the handle to the rps service
diff --git a/src/rps/rps_api.c b/src/rps/rps_api.c
index 34b28cd6a..5c68e4337 100644
--- a/src/rps/rps_api.c
+++ b/src/rps/rps_api.c
@@ -434,12 +434,18 @@ void
 GNUNET_RPS_stream_cancel (struct GNUNET_RPS_StreamRequestHandle *srh)
 {
   struct GNUNET_RPS_Handle *rps_handle;
+  struct GNUNET_RPS_StreamRequestHandle *srh_iter;
 
   rps_handle = srh->rps_handle;
-  GNUNET_CONTAINER_DLL_remove (rps_handle->stream_requests_head,
-                               rps_handle->stream_requests_tail,
-                               srh);
-  GNUNET_free (srh);
+  srh_iter = rps_handle->stream_requests_head;
+  while (NULL != srh_iter && srh_iter != srh) srh_iter = srh_iter->next;
+  if (NULL != srh_iter)
+  {
+    GNUNET_CONTAINER_DLL_remove (rps_handle->stream_requests_head,
+                                 rps_handle->stream_requests_tail,
+                                 srh);
+    GNUNET_free (srh);
+  }
   if (NULL == rps_handle->stream_requests_head) cancel_stream (rps_handle);
 }
 
@@ -542,6 +548,9 @@ handle_stream_input (void *cls,
        NULL != srh_iter;
        srh_iter = srh_iter->next)
   {
+      GNUNET_CONTAINER_DLL_remove (srh_head_tmp,
+                                   srh_tail_tmp,
+                                   srh_iter);
       GNUNET_CONTAINER_DLL_insert (h->stream_requests_head,
                                    h->stream_requests_tail,
                                    srh_iter);
@@ -928,17 +937,27 @@ GNUNET_RPS_request_cancel (struct 
GNUNET_RPS_Request_Handle *rh)
 void
 GNUNET_RPS_disconnect (struct GNUNET_RPS_Handle *h)
 {
-  GNUNET_MQ_destroy (h->mq);
   if (NULL != h->stream_requests_head)
   {
+    struct GNUNET_RPS_StreamRequestHandle *srh_iter;
+
     LOG (GNUNET_ERROR_TYPE_WARNING,
         "Still waiting for replies\n");
+    srh_iter = h->stream_requests_head;
+    while (NULL != srh_iter)
+    {
+      struct GNUNET_RPS_StreamRequestHandle *srh_tmp = srh_iter;
+      srh_iter = srh_iter->next;
+      GNUNET_RPS_stream_cancel (srh_tmp);
+    }
   }
   if (NULL != h->view_update_cb)
   {
     LOG (GNUNET_ERROR_TYPE_WARNING,
         "Still waiting for view updates\n");
+    GNUNET_RPS_view_request_cancel (h);
   }
+  GNUNET_MQ_destroy (h->mq);
   GNUNET_free (h);
 }
 
diff --git a/src/rps/test_rps.c b/src/rps/test_rps.c
index cbd3ba845..f26a9d424 100644
--- a/src/rps/test_rps.c
+++ b/src/rps/test_rps.c
@@ -190,6 +190,11 @@ struct RPSPeer
   struct GNUNET_RPS_Handle *rps_handle;
 
   /**
+   * Handle to stream requests
+   */
+  struct GNUNET_RPS_StreamRequestHandle *rps_srh;
+
+  /**
    * ID of the peer.
    */
   struct GNUNET_PeerIdentity *peer_id;
@@ -1116,6 +1121,11 @@ rps_disconnect_adapter (void *cls,
   struct RPSPeer *peer = cls;
   struct GNUNET_RPS_Handle *h = op_result;
 
+  if (NULL != peer->rps_srh)
+  {
+    GNUNET_RPS_stream_cancel (peer->rps_srh);
+    peer->rps_srh = NULL;
+  }
   GNUNET_assert (NULL != peer);
   GNUNET_RPS_disconnect (h);
   peer->rps_handle = NULL;
@@ -1547,17 +1557,35 @@ churn_test_cb (struct RPSPeer *rps_peer)
  * SUB
 ***********************************/
 
-void sub_post (struct RPSPeer *rps_peer)
+static void
+got_stream_peer_cb (void *cls,
+                    uint64_t num_peers,
+                    const struct GNUNET_PeerIdentity *peers)
 {
-  GNUNET_RPS_sub_stop (rps_peer->rps_handle, "test");
+  const struct RPSPeer *rps_peer = cls;
+
+  for (uint64_t i = 0; i < num_peers; i++)
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                "Peer %" PRIu32 " received [%s] from stream.\n",
+                rps_peer->index,
+                GNUNET_i2s (&peers[i]));
+    if (0 != rps_peer->index &&
+        0 == memcmp (&peers[i],
+                     &rps_peers[0].peer_id,
+                     sizeof (struct GNUNET_PeerIdentity)))
+    {
+      GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Received a peer id outside 
sub\n");
+      ok = 1;
+    }
+  }
 }
 
+
 static void
-sub_stop_op (void *cls)
+sub_post (struct RPSPeer *rps_peer)
 {
-  struct GNUNET_RPS_Handle *h = cls;
-
-  GNUNET_RPS_sub_stop (h, "test");
+  if (0 != rps_peer->index) GNUNET_RPS_sub_stop (rps_peer->rps_handle, "test");
 }
 
 static void
@@ -1565,7 +1593,11 @@ sub_pre (struct RPSPeer *rps_peer, struct 
GNUNET_RPS_Handle *h)
 {
   (void) rps_peer;
 
-  GNUNET_RPS_sub_start (h, "test");
+  if (0 != rps_peer->index) GNUNET_RPS_sub_start (h, "test");
+  rps_peer->rps_srh = GNUNET_RPS_stream_request (h,
+                                                 0,
+                                                 &got_stream_peer_cb,
+                                                 rps_peer);
 }
 
 /***********************************
@@ -2986,7 +3018,7 @@ main (int argc, char *argv[])
   }
 
   ret_value = cur_test_run.eval_cb();
-  
+
   if (NO_COLLECT_VIEW == cur_test_run.have_collect_view)
   {
     GNUNET_array_grow (rps_peers->cur_view,
@@ -2999,4 +3031,5 @@ main (int argc, char *argv[])
   return ret_value;
 }
 
+
 /* end of test_rps.c */

-- 
To stop receiving notification emails like this one, please contact
address@hidden



reply via email to

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