gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] [gnunet] branch master updated (c376dd135 -> eead33d85)


From: gnunet
Subject: [GNUnet-SVN] [gnunet] branch master updated (c376dd135 -> eead33d85)
Date: Thu, 01 Nov 2018 15:25:30 +0100

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

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

    from c376dd135 RPS profiler: Try to avoid assertion on request_cancel
     new e2cb39b4e RPS service: Add datastructs for analysis of pulls
     new 00a6af0c9 CORE: Document peer_cls
     new eead33d85 RPS service: Add more detailed statistics on 
multi/single-hop peers

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_core_service.h |   4 ++
 src/rps/Makefile.am               |   1 +
 src/rps/gnunet-service-rps.c      | 117 ++++++++++++++++++++++++++++++++++++++
 3 files changed, 122 insertions(+)

diff --git a/src/include/gnunet_core_service.h 
b/src/include/gnunet_core_service.h
index b38f38b69..b8172c37d 100644
--- a/src/include/gnunet_core_service.h
+++ b/src/include/gnunet_core_service.h
@@ -88,6 +88,8 @@ struct GNUNET_CORE_Handle;
  *
  * @param cls closure
  * @param peer peer identity this notification is about
+ * @return closure associated with @a peer. given to mq callbacks and
+ *         #GNUNET_CORE_DisconnectEventHandler
  */
 typedef void *
 (*GNUNET_CORE_ConnectEventHandler) (void *cls,
@@ -100,6 +102,8 @@ typedef void *
  *
  * @param cls closure
  * @param peer peer identity this notification is about
+ * @param peer_cls closure associated with peer. given in
+ *        #GNUNET_CORE_ConnectEventHandler
  */
 typedef void
 (*GNUNET_CORE_DisconnectEventHandler) (void *cls,
diff --git a/src/rps/Makefile.am b/src/rps/Makefile.am
index 3b5b1ef3e..a356d3dbc 100644
--- a/src/rps/Makefile.am
+++ b/src/rps/Makefile.am
@@ -72,6 +72,7 @@ gnunet_service_rps_LDADD = \
   $(top_builddir)/src/peerinfo/libgnunetpeerinfo.la \
   $(top_builddir)/src/nse/libgnunetnse.la \
   $(top_builddir)/src/statistics/libgnunetstatistics.la \
+  $(top_builddir)/src/core/libgnunetcore.la \
   $(LIBGCRYPT_LIBS) \
   -lm -lgcrypt \
   $(GN_LIBINTL)
diff --git a/src/rps/gnunet-service-rps.c b/src/rps/gnunet-service-rps.c
index d129ba746..9b6b3b7c6 100644
--- a/src/rps/gnunet-service-rps.c
+++ b/src/rps/gnunet-service-rps.c
@@ -25,6 +25,7 @@
 #include "gnunet_applications.h"
 #include "gnunet_util_lib.h"
 #include "gnunet_cadet_service.h"
+#include "gnunet_core_service.h"
 #include "gnunet_peerinfo_service.h"
 #include "gnunet_nse_service.h"
 #include "gnunet_statistics_service.h"
@@ -447,6 +448,16 @@ struct GNUNET_STATISTICS_Handle *stats;
 struct GNUNET_CADET_Handle *cadet_handle;
 
 /**
+ * Handle to CORE
+ */
+struct GNUNET_CORE_Handle *core_handle;
+
+/**
+ * @brief PeerMap to keep track of connected peers.
+ */
+struct GNUNET_CONTAINER_MultiPeerMap *map_single_hop;
+
+/**
  * Our own identity.
  */
 static struct GNUNET_PeerIdentity own_identity;
@@ -1366,6 +1377,13 @@ mq_notify_sent_cb (void *cls)
       GNUNET_STATISTICS_update(stats, "# pull requests sent", 1, GNUNET_NO);
     if (0 == strncmp ("PUSH", pending_msg->type, 4))
       GNUNET_STATISTICS_update(stats, "# pushes sent", 1, GNUNET_NO);
+    if (0 == strncmp ("PULL REQUEST", pending_msg->type, 12) &&
+        GNUNET_NO == GNUNET_CONTAINER_multipeermap_contains (map_single_hop,
+          &pending_msg->peer_ctx->peer_id))
+      GNUNET_STATISTICS_update(stats,
+                               "# pull requests sent (multi-hop peer)",
+                               1,
+                               GNUNET_NO);
   }
   /* Do not cancle message */
   remove_pending_message (pending_msg, GNUNET_NO);
@@ -2980,6 +2998,73 @@ destroy_sub (struct Sub *sub)
 ***********************************************************************/
 
 
+/***********************************************************************
+ * Core handlers
+***********************************************************************/
+
+/**
+ * @brief Callback on initialisation of Core.
+ *
+ * @param cls - unused
+ * @param my_identity - unused
+ */
+void
+core_init (void *cls,
+           const struct GNUNET_PeerIdentity *my_identity)
+{
+  (void) cls;
+  (void) my_identity;
+
+  map_single_hop = GNUNET_CONTAINER_multipeermap_create (4, GNUNET_NO);
+}
+
+
+/**
+ * @brief Callback for core.
+ * Method called whenever a given peer connects.
+ *
+ * @param cls closure - unused
+ * @param peer peer identity this notification is about
+ * @return closure given to #core_disconnects as peer_cls
+ */
+void *
+core_connects (void *cls,
+               const struct GNUNET_PeerIdentity *peer,
+               struct GNUNET_MQ_Handle *mq)
+{
+  (void) cls;
+  (void) mq;
+
+  GNUNET_CONTAINER_multipeermap_put (map_single_hop, peer, NULL,
+      GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY);
+  return NULL;
+}
+
+
+/**
+ * @brief Callback for core.
+ * Method called whenever a peer disconnects.
+ *
+ * @param cls closure - unused
+ * @param peer peer identity this notification is about
+ * @param peer_cls closure given in #core_connects - unused
+ */
+void
+core_disconnects (void *cls,
+                  const struct GNUNET_PeerIdentity *peer,
+                  void *peer_cls)
+{
+  (void) cls;
+  (void) peer_cls;
+
+  GNUNET_CONTAINER_multipeermap_remove_all (map_single_hop, peer);
+}
+
+/***********************************************************************
+ * /Core handlers
+***********************************************************************/
+
+
 /**
  * @brief Destroy the context for a (connected) client
  *
@@ -3423,6 +3508,14 @@ handle_peer_pull_request (void *cls,
                              "# pull request message received",
                              1,
                              GNUNET_NO);
+    if (GNUNET_NO == GNUNET_CONTAINER_multipeermap_contains (map_single_hop,
+                                                             
&peer_ctx->peer_id))
+    {
+      GNUNET_STATISTICS_update (stats,
+                                "# pull request message received (multi-hop 
peer)",
+                                1,
+                                GNUNET_NO);
+    }
   }
 
   #ifdef ENABLE_MALICIOUS
@@ -3678,6 +3771,14 @@ send_pull_request (struct PeerContext *peer_ctx)
                               "# pull request send issued",
                               1,
                               GNUNET_NO);
+    if (GNUNET_NO == GNUNET_CONTAINER_multipeermap_contains (map_single_hop,
+                                                             
&peer_ctx->peer_id))
+    {
+      GNUNET_STATISTICS_update (stats,
+                                "# pull request send issued (multi-hop peer)",
+                                1,
+                                GNUNET_NO);
+    }
   }
 }
 
@@ -4412,6 +4513,15 @@ shutdown_task (void *cls)
   GNUNET_PEERINFO_disconnect (peerinfo_handle);
   peerinfo_handle = NULL;
   GNUNET_NSE_disconnect (nse);
+  if (NULL != map_single_hop)
+  {
+    /* core_init was called - core was initialised */
+    /* disconnect first, so no callback tries to access missing peermap */
+    GNUNET_CORE_disconnect (core_handle);
+    core_handle = NULL;
+    GNUNET_CONTAINER_multipeermap_destroy (map_single_hop);
+    map_single_hop = NULL;
+  }
 
   if (NULL != stats)
   {
@@ -4566,6 +4676,13 @@ run (void *cls,
 
   cadet_handle = GNUNET_CADET_connect (cfg);
   GNUNET_assert (NULL != cadet_handle);
+  core_handle = GNUNET_CORE_connect (cfg,
+                                     NULL, /* cls */
+                                     core_init, /* init */
+                                     core_connects, /* connects */
+                                     core_disconnects, /* disconnects */
+                                     NULL); /* handlers */
+  GNUNET_assert (NULL != core_handle);
 
 
   alpha = 0.45;

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



reply via email to

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