gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] [gnunet] branch master updated (4438597b9 -> b197aa198)


From: gnunet
Subject: [GNUnet-SVN] [gnunet] branch master updated (4438597b9 -> b197aa198)
Date: Fri, 13 Jul 2018 01:16: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 4438597b9 Changed decription of GNUNET_CRYPTO_EddsaPublicKey.
     new f5164502b rps profiler: proper disconnect from service
     new 330bb7242 restructure rps service: start keeping track of channels
     new b197aa198 rps service: check return value when opening cadet port

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/rps/gnunet-rps-profiler.c | 19 ++++++-------
 src/rps/gnunet-service-rps.c  | 62 +++++++++++++++++++++++++++++++++++++------
 2 files changed, 64 insertions(+), 17 deletions(-)

diff --git a/src/rps/gnunet-rps-profiler.c b/src/rps/gnunet-rps-profiler.c
index 02259d628..a06598764 100644
--- a/src/rps/gnunet-rps-profiler.c
+++ b/src/rps/gnunet-rps-profiler.c
@@ -883,6 +883,9 @@ static int check_statistics_collect_completed ()
   return GNUNET_YES;
 }
 
+static void
+rps_disconnect_adapter (void *cls,
+                        void *op_result);
 
 static void
 cancel_pending_req (struct PendingRequest *pending_req)
@@ -928,15 +931,8 @@ clean_peer (unsigned peer_index)
     cancel_request (pending_rep);
   }
   pending_req = rps_peers[peer_index].pending_req_head;
-  while (NULL != (pending_req = rps_peers[peer_index].pending_req_head))
-  {
-    cancel_pending_req (pending_req);
-  }
-  if (NULL != rps_peers[peer_index].rps_handle)
-  {
-    GNUNET_RPS_disconnect (rps_peers[peer_index].rps_handle);
-    rps_peers[peer_index].rps_handle = NULL;
-  }
+  rps_disconnect_adapter (&rps_peers[peer_index],
+                          &rps_peers[peer_index].rps_handle);
   for (unsigned stat_type = STAT_TYPE_ROUNDS;
        stat_type < STAT_TYPE_MAX;
        stat_type++)
@@ -1277,6 +1273,7 @@ rps_disconnect_adapter (void *cls,
 {
   struct RPSPeer *peer = cls;
   struct GNUNET_RPS_Handle *h = op_result;
+  struct PendingRequest *pending_req;
 
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "disconnect_adapter (%u)\n",
@@ -1284,6 +1281,10 @@ rps_disconnect_adapter (void *cls,
   GNUNET_assert (NULL != peer);
   if (NULL != peer->rps_handle)
   {
+    while (NULL != (pending_req = peer->pending_req_head))
+    {
+      cancel_pending_req (pending_req);
+    }
     GNUNET_assert (h == peer->rps_handle);
     GNUNET_RPS_disconnect (h);
     peer->rps_handle = NULL;
diff --git a/src/rps/gnunet-service-rps.c b/src/rps/gnunet-service-rps.c
index aef6a72de..5d568dfac 100644
--- a/src/rps/gnunet-service-rps.c
+++ b/src/rps/gnunet-service-rps.c
@@ -265,6 +265,34 @@ struct PeersIteratorCls
 };
 
 /**
+ * @brief Context for a channel
+ */
+struct ChannelCtx
+{
+  /**
+   * @brief Meant to be used in a DLL
+   */
+  struct ChannelCtx *next;
+  struct ChannelCtx *prev;
+
+  /**
+   * @brief The channel itself
+   */
+  struct GNUNET_CADET_Channel *channel;
+
+  /**
+   * @brief The peer context associated with the channel
+   */
+  struct PeerContext *peer_ctx;
+};
+
+/**
+ * @brief The DLL of channel contexts
+ */
+static struct ChannelCtx *channel_ctx_head;
+static struct ChannelCtx *channel_ctx_tail;
+
+/**
  * @brief Hashmap of valid peers.
  */
 static struct GNUNET_CONTAINER_MultiPeerMap *valid_peers;
@@ -1521,6 +1549,7 @@ Peers_handle_inbound_channel (void *cls,
 {
   struct PeerContext *peer_ctx;
   struct GNUNET_PeerIdentity *ctx_peer;
+  struct ChannelCtx *channel_ctx;
 
   LOG (GNUNET_ERROR_TYPE_DEBUG,
       "New channel was established to us (Peer %s).\n",
@@ -1531,6 +1560,10 @@ Peers_handle_inbound_channel (void *cls,
   set_peer_live (peer_ctx);
   ctx_peer = GNUNET_new (struct GNUNET_PeerIdentity);
   *ctx_peer = *initiator;
+  channel_ctx = GNUNET_new (struct ChannelCtx);
+  channel_ctx->peer_ctx = peer_ctx;
+  channel_ctx->channel = channel;
+  GNUNET_CONTAINER_DLL_insert (channel_ctx_head, channel_ctx_tail, 
channel_ctx);
   /* We only accept one incoming channel per peer */
   if (GNUNET_YES == Peers_check_peer_send_intention (initiator))
   {
@@ -1543,10 +1576,10 @@ Peers_handle_inbound_channel (void *cls,
     GNUNET_CADET_channel_destroy (peer_ctx->recv_channel);
     peer_ctx->recv_channel = channel;
     /* return the channel context */
-    return ctx_peer;
+    return channel_ctx;
   }
   peer_ctx->recv_channel = channel;
-  return ctx_peer;
+  return channel_ctx;
 }
 
 
@@ -1658,7 +1691,8 @@ void
 Peers_cleanup_destroyed_channel (void *cls,
                                  const struct GNUNET_CADET_Channel *channel)
 {
-  struct GNUNET_PeerIdentity *peer = cls;
+  struct ChannelCtx *channel_ctx = cls;
+  const struct GNUNET_PeerIdentity *peer = &channel_ctx->peer_ctx->peer_id;
   struct PeerContext *peer_ctx;
   uint32_t *channel_flag;
 
@@ -2670,7 +2704,8 @@ static void
 cleanup_destroyed_channel (void *cls,
                            const struct GNUNET_CADET_Channel *channel)
 {
-  struct GNUNET_PeerIdentity *peer = cls;
+  struct ChannelCtx *channel_ctx = cls; // FIXME: free this context!
+  struct GNUNET_PeerIdentity *peer = &channel_ctx->peer_ctx->peer_id;
   uint32_t *channel_flag;
   struct PeerContext *peer_ctx;
 
@@ -3163,7 +3198,8 @@ static void
 handle_peer_check (void *cls,
                    const struct GNUNET_MessageHeader *msg)
 {
-  const struct GNUNET_PeerIdentity *peer = cls;
+  const struct ChannelCtx *channel_ctx = cls;
+  const struct GNUNET_PeerIdentity *peer = &channel_ctx->peer_ctx->peer_id;
   LOG (GNUNET_ERROR_TYPE_DEBUG,
       "Received CHECK_LIVE (%s)\n", GNUNET_i2s (peer));
 
@@ -3183,7 +3219,8 @@ static void
 handle_peer_push (void *cls,
                   const struct GNUNET_MessageHeader *msg)
 {
-  const struct GNUNET_PeerIdentity *peer = cls;
+  const struct ChannelCtx *channel_ctx = cls;
+  const struct GNUNET_PeerIdentity *peer = &channel_ctx->peer_ctx->peer_id;
 
   // (check the proof of work (?))
 
@@ -3244,7 +3281,8 @@ static void
 handle_peer_pull_request (void *cls,
                           const struct GNUNET_MessageHeader *msg)
 {
-  struct GNUNET_PeerIdentity *peer = cls;
+  const struct ChannelCtx *channel_ctx = cls;
+  const struct GNUNET_PeerIdentity *peer = &channel_ctx->peer_ctx->peer_id;
   const struct GNUNET_PeerIdentity *view_array;
 
   LOG (GNUNET_ERROR_TYPE_DEBUG, "Received PULL REQUEST (%s)\n", GNUNET_i2s 
(peer));
@@ -3324,8 +3362,9 @@ static void
 handle_peer_pull_reply (void *cls,
                         const struct GNUNET_RPS_P2P_PullReplyMessage *msg)
 {
+  const struct ChannelCtx *channel_ctx = cls;
+  const struct GNUNET_PeerIdentity *sender = &channel_ctx->peer_ctx->peer_id;
   const struct GNUNET_PeerIdentity *peers;
-  struct GNUNET_PeerIdentity *sender = cls;
   uint32_t i;
 #ifdef ENABLE_MALICIOUS
   struct AttackedPeer *tmp_att_peer;
@@ -4350,6 +4389,13 @@ run (void *cls,
                                        NULL, /* WindowSize handler */
                                        cleanup_destroyed_channel, /* 
Disconnect handler */
                                        cadet_handlers);
+  if (NULL == cadet_port)
+  {
+    LOG (GNUNET_ERROR_TYPE_ERROR,
+        "Cadet port `%s' is already in use.\n",
+        GNUNET_APPLICATION_PORT_RPS);
+    GNUNET_assert (0);
+  }
 
 
   peerinfo_handle = GNUNET_PEERINFO_connect (cfg);

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



reply via email to

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