[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r33995 - gnunet/src/cadet
From: |
gnunet |
Subject: |
[GNUnet-SVN] r33995 - gnunet/src/cadet |
Date: |
Mon, 21 Jul 2014 02:15:22 +0200 |
Author: bartpolot
Date: 2014-07-21 02:15:22 +0200 (Mon, 21 Jul 2014)
New Revision: 33995
Modified:
gnunet/src/cadet/gnunet-service-cadet_connection.c
gnunet/src/cadet/gnunet-service-cadet_peer.c
gnunet/src/cadet/gnunet-service-cadet_peer.h
Log:
- notify about deleted messages when popping messages from a connection,
allowing to keep a count and make sure the connection is destroyed
Modified: gnunet/src/cadet/gnunet-service-cadet_connection.c
===================================================================
--- gnunet/src/cadet/gnunet-service-cadet_connection.c 2014-07-21 00:15:21 UTC
(rev 33994)
+++ gnunet/src/cadet/gnunet-service-cadet_connection.c 2014-07-21 00:15:22 UTC
(rev 33995)
@@ -379,6 +379,8 @@
case CADET_CONNECTION_DESTROYED:
return "CADET_CONNECTION_DESTROYED";
default:
+ GNUNET_break (0);
+ LOG (GNUNET_ERROR_TYPE_ERROR, " conn state %u unknown!\n", s);
return "CADET_CONNECTION_STATE_ERROR";
}
}
@@ -1406,7 +1408,7 @@
if (GNUNET_OK != GCP_remove_connection (peer, c))
{
GNUNET_assert (CADET_CONNECTION_NEW == c->state
- || CADET_CONNECTION_DESTROYED == c->state);
+ || CADET_CONNECTION_DESTROYED == c->state);
LOG (GNUNET_ERROR_TYPE_DEBUG, " cstate: %u\n", c->state);
if (NULL != c->t) GCT_debug (c->t, GNUNET_ERROR_TYPE_DEBUG);
}
@@ -1415,7 +1417,7 @@
if (GNUNET_OK != GCP_remove_connection (peer, c))
{
GNUNET_assert (CADET_CONNECTION_NEW == c->state
- || CADET_CONNECTION_DESTROYED == c->state);
+ || CADET_CONNECTION_DESTROYED == c->state);
LOG (GNUNET_ERROR_TYPE_DEBUG, " cstate: %u\n", c->state);
if (NULL != c->t) GCT_debug (c->t, GNUNET_ERROR_TYPE_DEBUG);
}
@@ -1795,6 +1797,8 @@
struct GNUNET_CADET_ConnectionBroken *msg;
struct CadetConnection *c;
struct CadetTunnel *t;
+ unsigned int del;
+ int pending;
int fwd;
msg = (struct GNUNET_CADET_ConnectionBroken *) message;
@@ -1831,15 +1835,26 @@
c->state = CADET_CONNECTION_DESTROYED;
GCT_remove_connection (t, c);
c->t = NULL;
+ pending = c->pending_messages;
/* GCP_connection_pop will destroy the connection when the last message
* is popped! Do not use 'c' after the call. */
- while (NULL != (out_msg = GCP_connection_pop (neighbor, c)))
+ while (NULL != (out_msg = GCP_connection_pop (neighbor, c, &del)))
{
+ pending -= del + 1;
GCT_resend_message (out_msg, t);
}
/* All pending messages should have been popped,
* and the connection destroyed by the continuation. */
+ if (0 < pending)
+ {
+ GNUNET_break (0);
+ GCC_destroy (c);
+ }
+ else
+ {
+ GNUNET_break (0 == pending_msgs); /* If negative: counter error! */
+ }
}
else
{
Modified: gnunet/src/cadet/gnunet-service-cadet_peer.c
===================================================================
--- gnunet/src/cadet/gnunet-service-cadet_peer.c 2014-07-21 00:15:21 UTC
(rev 33994)
+++ gnunet/src/cadet/gnunet-service-cadet_peer.c 2014-07-21 00:15:22 UTC
(rev 33995)
@@ -1133,11 +1133,10 @@
struct CadetPeer *peer;
peer = queue->peer;
-
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "queue destroy %s\n", GC_m2s (queue->type));
if (GNUNET_YES == clear_cls)
{
- LOG (GNUNET_ERROR_TYPE_DEBUG, "queue destroy type %s\n",
- GC_m2s (queue->type));
+ LOG (GNUNET_ERROR_TYPE_DEBUG, " free cls\n");
switch (queue->type)
{
case GNUNET_MESSAGE_TYPE_CADET_CONNECTION_DESTROY:
@@ -1384,18 +1383,26 @@
/**
* Get the first message for a connection and unqueue it.
*
+ * Only tunnel (or higher) level messages are unqueued. Connection specific
+ * messages are destroyed and the count given to the caller.
+ *
* @param peer Neighboring peer.
* @param c Connection.
+ * @param del[out] How many messages have been deleted without returning.
+ * Can be NULL.
*
* @return First message for this connection.
*/
struct GNUNET_MessageHeader *
-GCP_connection_pop (struct CadetPeer *peer, struct CadetConnection *c)
+GCP_connection_pop (struct CadetPeer *peer,
+ struct CadetConnection *c,
+ unsigned int *del)
{
struct CadetPeerQueue *q;
struct CadetPeerQueue *next;
struct GNUNET_MessageHeader *msg;
+ if (NULL != del) *del = 0;
LOG (GNUNET_ERROR_TYPE_DEBUG, "Connection pop on connection %p\n", c);
for (q = peer->queue_head; NULL != q; q = next)
{
@@ -1411,6 +1418,7 @@
case GNUNET_MESSAGE_TYPE_CADET_ACK:
case GNUNET_MESSAGE_TYPE_CADET_POLL:
GCP_queue_destroy (q, GNUNET_YES, GNUNET_NO, 0);
+ if (NULL != del) *del = *del + 1;
continue;
case GNUNET_MESSAGE_TYPE_CADET_KX:
Modified: gnunet/src/cadet/gnunet-service-cadet_peer.h
===================================================================
--- gnunet/src/cadet/gnunet-service-cadet_peer.h 2014-07-21 00:15:21 UTC
(rev 33994)
+++ gnunet/src/cadet/gnunet-service-cadet_peer.h 2014-07-21 00:15:22 UTC
(rev 33995)
@@ -169,17 +169,20 @@
/**
* Get the first message for a connection and unqueue it.
*
- * If the message was the last in the connection and the destruction flag
- * was set, the connection will be freed by the continuation called by this
- * function, and @c c will be INVALID after the call.
+ * Only tunnel (or higher) level messages are unqueued. Connection specific
+ * messages are destroyed and the count given to the caller.
*
* @param peer Neighboring peer.
* @param c Connection.
+ * @param del[out] How many messages have been deleted without returning.
+ * Can be NULL.
*
* @return First message for this connection.
*/
struct GNUNET_MessageHeader *
-GCP_connection_pop (struct CadetPeer *peer, struct CadetConnection *c);
+GCP_connection_pop (struct CadetPeer *peer,
+ struct CadetConnection *c,
+ unsigned int *del);
/**
* Unlock a possibly locked queue for a connection.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r33995 - gnunet/src/cadet,
gnunet <=