[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r25307 - gnunet/src/mesh
From: |
gnunet |
Subject: |
[GNUnet-SVN] r25307 - gnunet/src/mesh |
Date: |
Fri, 7 Dec 2012 14:00:31 +0100 |
Author: bartpolot
Date: 2012-12-07 14:00:31 +0100 (Fri, 07 Dec 2012)
New Revision: 25307
Modified:
gnunet/src/mesh/gnunet-service-mesh.c
Log:
- wip
Modified: gnunet/src/mesh/gnunet-service-mesh.c
===================================================================
--- gnunet/src/mesh/gnunet-service-mesh.c 2012-12-07 11:12:39 UTC (rev
25306)
+++ gnunet/src/mesh/gnunet-service-mesh.c 2012-12-07 13:00:31 UTC (rev
25307)
@@ -923,7 +923,12 @@
*/
static unsigned long long max_msgs_queue;
+/**
+ * How many peers do we want to remember?
+ */
+static unsigned long long max_peers;
+
/*************************** Static global variables
**************************/
/**
@@ -2328,6 +2333,23 @@
/**
+ * Iterator over all the peers to remove the oldest not-used entry.
+ *
+ * @param cls Closure (unsued).
+ * @param key ID of the peer.
+ * @param value Peer_Info of the peer.
+ *
+ * FIXME implement
+ */
+static int
+peer_info_timeout (void *cls,
+ const struct GNUNET_HashCode *key,
+ void *value)
+{
+ return GNUNET_YES;
+}
+
+/**
* Retrieve the MeshPeerInfo stucture associated with the peer, create one
* and insert it in the appropiate structures if the peer is not known yet.
*
@@ -2345,10 +2367,17 @@
{
peer_info =
(struct MeshPeerInfo *) GNUNET_malloc (sizeof (struct MeshPeerInfo));
+ if (GNUNET_CONTAINER_multihashmap_size (peers) > max_peers)
+ {
+ GNUNET_CONTAINER_multihashmap_iterate (peers,
+ &peer_info_timeout,
+ NULL);
+ }
GNUNET_CONTAINER_multihashmap_put (peers, &peer->hashPubKey, peer_info,
-
GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY);
+
GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST);
peer_info->id = GNUNET_PEER_intern (peer);
}
+ peer_info->last_contact = GNUNET_TIME_absolute_get();
return peer_info;
}
@@ -8800,6 +8829,16 @@
}
if (GNUNET_OK !=
+ GNUNET_CONFIGURATION_get_value_number (c, "MESH", "MAX_PEERS",
+ &max_peers))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ _("%s service is lacking key configuration settings (%s).
Using default (%u).\n"),
+ "mesh", "max peers", 1000);
+ max_peers = 1000;
+ }
+
+ if (GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_number (c, "MESH",
"DHT_REPLICATION_LEVEL",
&dht_replication_level))
{
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r25307 - gnunet/src/mesh,
gnunet <=