commit 129bc8e9845b4c17e988e0b3ebb3eea5a232e288
parent 48332ff7d4631f9be2a059c2fe150e3be5fb37f6
Author: Christian Grothoff <christian@grothoff.org>
Date: Mon, 30 Jan 2017 14:03:46 +0100
pass connection tunnel identifier to channel when receiving messages, so that performance can be matched
Diffstat:
3 files changed, 52 insertions(+), 11 deletions(-)
diff --git a/src/cadet/gnunet-service-cadet-new_channel.c b/src/cadet/gnunet-service-cadet-new_channel.c
@@ -838,9 +838,11 @@ send_open_ack (void *cls)
* #GNUNET_MESSAGE_TYPE_CADET_CHANNEL_OPEN_ACK.
*
* @param ch channel that got the duplicate open
+ * @param cti identifier of the connection that delivered the message
*/
void
-GCCH_handle_duplicate_open (struct CadetChannel *ch)
+GCCH_handle_duplicate_open (struct CadetChannel *ch,
+ const struct GNUNET_CADET_ConnectionTunnelIdentifier *cti)
{
if (NULL == ch->dest)
{
@@ -955,7 +957,8 @@ GCCH_bind (struct CadetChannel *ch,
if (GNUNET_YES == ch->is_loopback)
{
ch->state = CADET_CHANNEL_OPEN_SENT;
- GCCH_handle_channel_open_ack (ch);
+ GCCH_handle_channel_open_ack (ch,
+ NULL);
}
else
{
@@ -1040,9 +1043,11 @@ GCCH_channel_local_destroy (struct CadetChannel *ch,
* (the port is open on the other side). Begin transmissions.
*
* @param ch channel to destroy
+ * @param cti identifier of the connection that delivered the message
*/
void
-GCCH_handle_channel_open_ack (struct CadetChannel *ch)
+GCCH_handle_channel_open_ack (struct CadetChannel *ch,
+ const struct GNUNET_CADET_ConnectionTunnelIdentifier *cti)
{
switch (ch->state)
{
@@ -1125,10 +1130,12 @@ is_before (void *cls,
* and send an ACK to the other end (once flow control allows it!)
*
* @param ch channel that got data
+ * @param cti identifier of the connection that delivered the message
* @param msg message that was received
*/
void
GCCH_handle_channel_plaintext_data (struct CadetChannel *ch,
+ const struct GNUNET_CADET_ConnectionTunnelIdentifier *cti,
const struct GNUNET_CADET_ChannelAppDataMessage *msg)
{
struct GNUNET_MQ_Envelope *env;
@@ -1402,10 +1409,12 @@ handle_matching_ack (struct CadetChannel *ch,
* Possibly resume transmissions.
*
* @param ch channel that got the ack
+ * @param cti identifier of the connection that delivered the message
* @param ack details about what was received
*/
void
GCCH_handle_channel_plaintext_data_ack (struct CadetChannel *ch,
+ const struct GNUNET_CADET_ConnectionTunnelIdentifier *cti,
const struct GNUNET_CADET_ChannelDataAckMessage *ack)
{
struct CadetReliableMessage *crm;
@@ -1499,9 +1508,12 @@ GCCH_handle_channel_plaintext_data_ack (struct CadetChannel *ch,
* the tunnel.
*
* @param ch channel to destroy
+ * @param cti identifier of the connection that delivered the message,
+ * NULL if we are simulating receiving a destroy due to shutdown
*/
void
-GCCH_handle_remote_destroy (struct CadetChannel *ch)
+GCCH_handle_remote_destroy (struct CadetChannel *ch,
+ const struct GNUNET_CADET_ConnectionTunnelIdentifier *cti)
{
struct CadetChannelClient *ccc;
diff --git a/src/cadet/gnunet-service-cadet-new_channel.h b/src/cadet/gnunet-service-cadet-new_channel.h
@@ -159,19 +159,24 @@ GCCH_channel_incoming_new (struct CadetTunnel *t,
* #GNUNET_MESSAGE_TYPE_CADET_CHANNEL_OPEN_ACK.
*
* @param ch channel that got the duplicate open
+ * @param cti identifier of the connection that delivered the message
*/
void
-GCCH_handle_duplicate_open (struct CadetChannel *ch);
+GCCH_handle_duplicate_open (struct CadetChannel *ch,
+ const struct GNUNET_CADET_ConnectionTunnelIdentifier *cti);
+
/**
* We got payload data for a channel. Pass it on to the client.
*
* @param ch channel that got data
+ * @param cti identifier of the connection that delivered the message
* @param msg message that was received
*/
void
GCCH_handle_channel_plaintext_data (struct CadetChannel *ch,
+ const struct GNUNET_CADET_ConnectionTunnelIdentifier *cti,
const struct GNUNET_CADET_ChannelAppDataMessage *msg);
@@ -180,10 +185,12 @@ GCCH_handle_channel_plaintext_data (struct CadetChannel *ch,
* Possibly resume transmissions.
*
* @param ch channel that got the ack
+ * @param cti identifier of the connection that delivered the message
* @param ack details about what was received
*/
void
GCCH_handle_channel_plaintext_data_ack (struct CadetChannel *ch,
+ const struct GNUNET_CADET_ConnectionTunnelIdentifier *cti,
const struct GNUNET_CADET_ChannelDataAckMessage *ack);
@@ -192,9 +199,12 @@ GCCH_handle_channel_plaintext_data_ack (struct CadetChannel *ch,
* (the port is open on the other side). Begin transmissions.
*
* @param ch channel to destroy
+ * @param cti identifier of the connection that delivered the message,
+ * NULL if the ACK was inferred because we got payload or are on loopback
*/
void
-GCCH_handle_channel_open_ack (struct CadetChannel *ch);
+GCCH_handle_channel_open_ack (struct CadetChannel *ch,
+ const struct GNUNET_CADET_ConnectionTunnelIdentifier *cti);
/**
@@ -210,9 +220,12 @@ GCCH_handle_channel_open_ack (struct CadetChannel *ch);
* us before!
*
* @param ch channel to destroy
+ * @param cti identifier of the connection that delivered the message,
+ * NULL during shutdown
*/
void
-GCCH_handle_remote_destroy (struct CadetChannel *ch);
+GCCH_handle_remote_destroy (struct CadetChannel *ch,
+ const struct GNUNET_CADET_ConnectionTunnelIdentifier *cti);
/**
diff --git a/src/cadet/gnunet-service-cadet-new_tunnels.c b/src/cadet/gnunet-service-cadet-new_tunnels.c
@@ -409,6 +409,13 @@ struct CadetTunnel
struct CadetTunnelQueueEntry *tq_tail;
/**
+ * Identification of the connection from which we are currently processing
+ * a message. Only valid (non-NULL) during #handle_decrypted() and the
+ * handle-*()-functions called from our @e mq during that function.
+ */
+ struct CadetTConnection *current_ct;
+
+ /**
* How long do we wait until we retry the KX?
*/
struct GNUNET_TIME_Relative kx_retry_delay;
@@ -2090,7 +2097,8 @@ destroy_remaining_channels (void *cls,
{
struct CadetChannel *ch = value;
- GCCH_handle_remote_destroy (ch);
+ GCCH_handle_remote_destroy (ch,
+ NULL);
return GNUNET_OK;
}
@@ -2620,6 +2628,7 @@ handle_plaintext_data (void *cls,
return;
}
GCCH_handle_channel_plaintext_data (ch,
+ GCC_get_id (t->current_ct->cc),
msg);
}
@@ -2653,6 +2662,7 @@ handle_plaintext_data_ack (void *cls,
return;
}
GCCH_handle_channel_plaintext_data_ack (ch,
+ GCC_get_id (t->current_ct->cc),
ack);
}
@@ -2680,7 +2690,8 @@ handle_plaintext_channel_open (void *cls,
GNUNET_h2s (&copen->port),
GCT_2s (t),
GCCH_2s (ch));
- GCCH_handle_duplicate_open (ch);
+ GCCH_handle_duplicate_open (ch,
+ GCC_get_id (t->current_ct->cc));
return;
}
LOG (GNUNET_ERROR_TYPE_DEBUG,
@@ -2757,7 +2768,8 @@ handle_plaintext_channel_open_ack (void *cls,
"Received channel OPEN_ACK on channel %s from %s\n",
GCCH_2s (ch),
GCT_2s (t));
- GCCH_handle_channel_open_ack (ch);
+ GCCH_handle_channel_open_ack (ch,
+ GCC_get_id (t->current_ct->cc));
}
@@ -2790,7 +2802,8 @@ handle_plaintext_channel_destroy (void *cls,
"Receicved channel DESTROY on %s from %s\n",
GCCH_2s (ch),
GCT_2s (t));
- GCCH_handle_remote_destroy (ch);
+ GCCH_handle_remote_destroy (ch,
+ GCC_get_id (t->current_ct->cc));
}
@@ -2808,6 +2821,7 @@ handle_decrypted (void *cls,
{
struct CadetTunnel *t = cls;
+ GNUNET_assert (NULL != t->current_ct);
GNUNET_MQ_inject_message (t->mq,
msg);
return GNUNET_OK;
@@ -3094,12 +3108,14 @@ GCT_handle_encrypted (struct CadetTConnection *ct,
}
/* The MST will ultimately call #handle_decrypted() on each message. */
+ t->current_ct = ct;
GNUNET_break_op (GNUNET_OK ==
GNUNET_MST_from_buffer (t->mst,
cbuf,
decrypted_size,
GNUNET_YES,
GNUNET_NO));
+ t->current_ct = NULL;
}