[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r31238 - gnunet/src/mesh
From: |
gnunet |
Subject: |
[GNUnet-SVN] r31238 - gnunet/src/mesh |
Date: |
Mon, 9 Dec 2013 20:13:00 +0100 |
Author: bartpolot
Date: 2013-12-09 20:13:00 +0100 (Mon, 09 Dec 2013)
New Revision: 31238
Modified:
gnunet/src/mesh/gnunet-service-mesh_channel.c
gnunet/src/mesh/gnunet-service-mesh_tunnel.c
Log:
- fix handle for tunnel queueing during KX
Modified: gnunet/src/mesh/gnunet-service-mesh_channel.c
===================================================================
--- gnunet/src/mesh/gnunet-service-mesh_channel.c 2013-12-09 18:26:52 UTC
(rev 31237)
+++ gnunet/src/mesh/gnunet-service-mesh_channel.c 2013-12-09 19:13:00 UTC
(rev 31238)
@@ -1285,6 +1285,9 @@
if (NULL == ch)
return;
+ if (2 == ch->destroy)
+ return; /* recursive call */
+ ch->destroy = 2;
LOG (GNUNET_ERROR_TYPE_DEBUG, "destroying channel %s:%u\n",
GMT_2s (ch->t), ch->gid);
Modified: gnunet/src/mesh/gnunet-service-mesh_tunnel.c
===================================================================
--- gnunet/src/mesh/gnunet-service-mesh_tunnel.c 2013-12-09 18:26:52 UTC
(rev 31237)
+++ gnunet/src/mesh/gnunet-service-mesh_tunnel.c 2013-12-09 19:13:00 UTC
(rev 31238)
@@ -158,6 +158,11 @@
struct MeshTunnelDelayed *prev;
/**
+ * Tunnel.
+ */
+ struct MeshTunnel3 *t;
+
+ /**
* Channel.
*/
struct MeshChannel *ch;
@@ -180,6 +185,11 @@
struct MeshConnectionQueue *q;
/**
+ * Handle in case message hasn't been given to a connection yet.
+ */
+ struct MeshTunnelDelayed *tq;
+
+ /**
* Continuation to call once sent.
*/
GMT_sent cont;
@@ -597,7 +607,22 @@
}
+
/**
+ * Delete a queued message: most probably channel was destroyed before the
+ * tunnel's key exchange had a chance to finish.
+ *
+ * @param tq Queue handle.
+ */
+static void
+unqueue_data (struct MeshTunnelDelayed *tq)
+{
+ GNUNET_CONTAINER_DLL_remove (tq->t->tq_head, tq->t->tq_tail, tq);
+ GNUNET_free (tq);
+}
+
+
+/**
* Send all cached messages that we can, tunnel is online.
*
* @param t Tunnel that holds the messages. Cannot be loopback.
@@ -634,12 +659,10 @@
LOG (GNUNET_ERROR_TYPE_DEBUG, " data on channel %s\n", GMCH_2s (tq->ch));
next = tq->next;
room--;
- GNUNET_CONTAINER_DLL_remove (t->tq_head, t->tq_tail, tq);
GMCH_send_prebuilt_message ((struct GNUNET_MessageHeader *) &tq[1],
tq->ch, GMCH_is_origin (tq->ch, GNUNET_YES),
NULL);
-
- GNUNET_free (tq);
+ unqueue_data (tq);
}
LOG (GNUNET_ERROR_TYPE_DEBUG,
"GMT_send_queued_data end\n",
@@ -647,8 +670,6 @@
}
-
-
/**
* Cache a message to be sent once tunnel is online.
*
@@ -656,7 +677,7 @@
* @param ch Channel the message is about.
* @param msg Message itself (copy will be made).
*/
-static void
+static struct MeshTunnelDelayed *
queue_data (struct MeshTunnel3 *t,
struct MeshChannel *ch,
const struct GNUNET_MessageHeader *msg)
@@ -669,14 +690,16 @@
if (GNUNET_YES == is_ready (t))
{
GNUNET_break (0);
- return;
+ return NULL;
}
tq = GNUNET_malloc (sizeof (struct MeshTunnelDelayed) + size);
tq->ch = ch;
+ tq->t = t;
memcpy (&tq[1], msg, size);
GNUNET_CONTAINER_DLL_insert_tail (t->tq_head, t->tq_tail, tq);
+ return tq;
}
@@ -2157,8 +2180,19 @@
void
GMT_cancel (struct MeshTunnel3Queue *q)
{
- GMC_cancel (q->q);
- /* message_sent() will be called and free q */
+ if (NULL != q->q)
+ {
+ GMC_cancel (q->q);
+ /* message_sent() will be called and free q */
+ }
+ else if (NULL != q->tq)
+ {
+ unqueue_data (q->tq);
+ }
+ else
+ {
+ GNUNET_break (0);
+ }
}
@@ -2195,9 +2229,9 @@
if (GNUNET_NO == is_ready (t))
{
- queue_data (t, ch, message);
- /* FIXME */
- return NULL;
+ q = GNUNET_new (struct MeshTunnel3Queue);
+ q->tq = queue_data (t, ch, message);
+ return q;
}
GNUNET_assert (GNUNET_NO == GMT_is_loopback (t));
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r31238 - gnunet/src/mesh,
gnunet <=