[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r33030 - gnunet/src/mesh
From: |
gnunet |
Subject: |
[GNUnet-SVN] r33030 - gnunet/src/mesh |
Date: |
Thu, 10 Apr 2014 17:39:21 +0200 |
Author: bartpolot
Date: 2014-04-10 17:39:21 +0200 (Thu, 10 Apr 2014)
New Revision: 33030
Modified:
gnunet/src/mesh/gnunet-service-mesh_connection.c
gnunet/src/mesh/gnunet-service-mesh_connection.h
gnunet/src/mesh/gnunet-service-mesh_tunnel.c
Log:
- don't free connections in the middle of being build.
- fixes #3373, #3361
Modified: gnunet/src/mesh/gnunet-service-mesh_connection.c
===================================================================
--- gnunet/src/mesh/gnunet-service-mesh_connection.c 2014-04-10 15:39:20 UTC
(rev 33029)
+++ gnunet/src/mesh/gnunet-service-mesh_connection.c 2014-04-10 15:39:21 UTC
(rev 33030)
@@ -2799,7 +2799,21 @@
return GNUNET_NO;
}
+
/**
+ * Check if this connection is a direct one (never trim a direct connection).
+ *
+ * @param c Connection.
+ *
+ * @return #GNUNET_YES in case it's a direct connection, #GNUNET_NO otherwise.
+ */
+int
+GMC_is_direct (struct MeshConnection *c)
+{
+ return (c->path->length == 2) ? GNUNET_YES : GNUNET_NO;
+}
+
+/**
* Sends an already built message on a connection, properly registering
* all used resources.
*
Modified: gnunet/src/mesh/gnunet-service-mesh_connection.h
===================================================================
--- gnunet/src/mesh/gnunet-service-mesh_connection.h 2014-04-10 15:39:20 UTC
(rev 33029)
+++ gnunet/src/mesh/gnunet-service-mesh_connection.h 2014-04-10 15:39:21 UTC
(rev 33030)
@@ -445,6 +445,16 @@
GMC_is_sendable (struct MeshConnection *c, int fwd);
/**
+ * Check if this connection is a direct one (never trim a direct connection).
+ *
+ * @param c Connection.
+ *
+ * @return #GNUNET_YES in case it's a direct connection, #GNUNET_NO otherwise.
+ */
+int
+GMC_is_direct (struct MeshConnection *c);
+
+/**
* Cancel a previously sent message while it's in the queue.
*
* ONLY can be called before the continuation given to the send function
Modified: gnunet/src/mesh/gnunet-service-mesh_tunnel.c
===================================================================
--- gnunet/src/mesh/gnunet-service-mesh_tunnel.c 2014-04-10 15:39:20 UTC
(rev 33029)
+++ gnunet/src/mesh/gnunet-service-mesh_tunnel.c 2014-04-10 15:39:21 UTC
(rev 33030)
@@ -1886,35 +1886,52 @@
/**
- * Check that the tunnel doesn't have too many connections,
- * remove one if necessary.
+ * @brief Check if tunnel has too many connections, and remove one if
necessary.
*
- * For the time being, this means the newest connection.
+ * Currently this means the newest connection, unless it is a direct one.
+ * Implemented as a task to avoid freeing a connection that is in the middle
+ * of being created/processed.
*
- * @param t Tunnel to check.
+ * @param cls Closure (Tunnel to check).
+ * @param tc Task context.
*/
static void
-check_connection_count (struct MeshTunnel3 *t)
+trim_connections (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
- if (GMT_count_connections (t) > CONNECTIONS_PER_TUNNEL)
+ struct MeshTunnel3 *t = cls;
+
+ if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
+ return;
+
+ if (GMT_count_connections (t) > 2 * CONNECTIONS_PER_TUNNEL)
{
struct MeshTConnection *iter;
struct MeshTConnection *c;
for (c = iter = t->connection_head; NULL != iter; iter = iter->next)
{
- if (NULL == c || iter->created.abs_value_us > c->created.abs_value_us)
+ if ((NULL == c || iter->created.abs_value_us > c->created.abs_value_us)
+ && GNUNET_NO == GMC_is_direct (iter->c))
{
c = iter;
}
}
if (NULL != c)
+ {
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Too many connections on tunnel %s\n",
+ GMT_2s (t));
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Destroying connection %s\n",
+ GMC_2s (c->c));
GMC_destroy (c->c);
+ }
else
+ {
GNUNET_break (0);
+ }
}
}
+
/**
* Add a connection to a tunnel.
*
@@ -1928,6 +1945,8 @@
GNUNET_assert (NULL != c);
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "add connection %s\n", GMC_2s (c));
+ LOG (GNUNET_ERROR_TYPE_DEBUG, " to tunnel %s\n", GMT_2s (t));
for (aux = t->connection_head; aux != NULL; aux = aux->next)
if (aux->c == c)
return;
@@ -1938,7 +1957,7 @@
GNUNET_CONTAINER_DLL_insert (t->connection_head, t->connection_tail, aux);
- check_connection_count (t);
+ GNUNET_SCHEDULER_add_now (&trim_connections, t);
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r33030 - gnunet/src/mesh,
gnunet <=