/*
This file is part of GNUnet.
- Copyright (C) 2013 Christian Grothoff (and other contributing authors)
+ Copyright (C) 2013 GNUnet e.V.
GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
You should have received a copy of the GNU General Public License
along with GNUnet; see the file COPYING. If not, write to the
- Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA.
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
*/
#include "gnunet-service-cadet_peer.h"
#define LOG(level, ...) GNUNET_log_from(level,"cadet-chn",__VA_ARGS__)
+#define LOG2(level, ...) GNUNET_log_from_nocheck(level,"cadet-chn",__VA_ARGS__)
#define CADET_RETRANSMIT_TIME GNUNET_TIME_relative_multiply(\
GNUNET_TIME_UNIT_MILLISECONDS, 250)
/**
* Double linked list, FIFO style
*/
- struct CadetReliableMessage *next;
- struct CadetReliableMessage *prev;
+ struct CadetReliableMessage *next;
+ struct CadetReliableMessage *prev;
/**
* Type of message (payload, channel management).
*/
- int16_t type;
+ int16_t type;
/**
* Tunnel Reliability queue this message is in.
*/
- struct CadetChannelReliability *rel;
+ struct CadetChannelReliability *rel;
/**
* ID of the message (ACK needed to free)
/**
* Tunnel Queue.
*/
- struct CadetChannelQueue *chq;
+ struct CadetChannelQueue *chq;
/**
* When was this message issued (to calculate ACK delay)
mid = ntohl (msg->mid);
- LOG (GNUNET_ERROR_TYPE_DEBUG, "add_buffered_data %u\n", mid);
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "add_buffered_data MID %u (%u)\n",
+ mid, rel->n_recv);
rel->n_recv++;
if (prev->mid == mid)
{
LOG (GNUNET_ERROR_TYPE_DEBUG, " already there!\n");
+ rel->n_recv--;
return;
}
else if (GC_is_pid_bigger (prev->mid, mid))
}
}
copy = copy_message (msg, mid, rel);
- LOG (GNUNET_ERROR_TYPE_DEBUG, " insert at tail!\n");
+ LOG (GNUNET_ERROR_TYPE_DEBUG, " insert at tail! (now: %u)\n", rel->n_recv);
GNUNET_CONTAINER_DLL_insert_tail (rel->head_recv, rel->tail_recv, copy);
LOG (GNUNET_ERROR_TYPE_DEBUG, "add_buffered_data END\n");
}
send_client_data (ch, msg, fwd);
rel->n_recv--;
GNUNET_CONTAINER_DLL_remove (rel->head_recv, rel->tail_recv, copy);
- LOG (GNUNET_ERROR_TYPE_DEBUG, " COPYFREE RECV %p\n", copy);
+ LOG (GNUNET_ERROR_TYPE_DEBUG, " free copy recv MID %u (%p), %u left\n",
+ copy->mid, copy, rel->n_recv);
GNUNET_free (copy);
GCCH_send_data_ack (ch, fwd);
}
* We haven't received an ACK after a certain time: restransmit the message.
*
* @param cls Closure (CadetChannelReliability with the message to restransmit)
- * @param tc TaskContext.
*/
static void
-channel_retransmit_message (void *cls,
- const struct GNUNET_SCHEDULER_TaskContext *tc)
+channel_retransmit_message (void *cls)
{
struct CadetChannelReliability *rel = cls;
struct CadetReliableMessage *copy;
int fwd;
rel->retry_task = NULL;
- if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
- return;
-
ch = rel->ch;
copy = rel->head_sent;
if (NULL == copy)
fwd = (rel == ch->root_rel);
/* Message not found in the queue that we are going to use. */
- LOG (GNUNET_ERROR_TYPE_DEBUG, "!!! RETRANSMIT %u\n", copy->mid);
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "RETRANSMIT MID %u\n", copy->mid);
GCCH_send_prebuilt_message (&payload->header, ch, fwd, copy);
GNUNET_STATISTICS_update (stats, "# data retransmitted", 1, GNUNET_NO);
* We haven't received an Channel ACK after a certain time: resend the CREATE.
*
* @param cls Closure (CadetChannelReliability of the channel to recreate)
- * @param tc TaskContext.
*/
static void
-channel_recreate (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+channel_recreate (void *cls)
{
struct CadetChannelReliability *rel = cls;
rel->retry_task = NULL;
- if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
- return;
-
- LOG (GNUNET_ERROR_TYPE_DEBUG, "!!! RE-CREATE\n");
- GNUNET_STATISTICS_update (stats, "# data retransmitted", 1, GNUNET_NO);
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "RE-CREATE\n");
+ GNUNET_STATISTICS_update (stats,
+ "# data retransmitted", 1, GNUNET_NO);
if (rel == rel->ch->root_rel)
{
{
GNUNET_break (0);
}
-
}
struct CadetReliableMessage *copy = chq->copy;
struct CadetChannelReliability *rel;
- LOG (GNUNET_ERROR_TYPE_DEBUG, "channel message sent callback %s\n",
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "channel_message_sent callback %s\n",
GC_m2s (chq->type));
switch (chq->type)
{
case GNUNET_MESSAGE_TYPE_CADET_DATA:
- LOG (GNUNET_ERROR_TYPE_DEBUG, "!!! SENT DATA MID %u\n", copy->mid);
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "data MID %u sent\n", copy->mid);
GNUNET_assert (chq == copy->chq);
copy->timestamp = GNUNET_TIME_absolute_get ();
rel = copy->rel;
if (NULL == rel->retry_task)
{
- LOG (GNUNET_ERROR_TYPE_DEBUG, "!! scheduling retry in 4 * %s\n",
+ LOG (GNUNET_ERROR_TYPE_DEBUG, " scheduling retry in %d * %s\n",
+ CADET_RETRANSMIT_MARGIN,
GNUNET_STRINGS_relative_time_to_string (rel->expected_delay,
GNUNET_YES));
if (0 != rel->expected_delay.rel_value_us)
{
- LOG (GNUNET_ERROR_TYPE_DEBUG, "!! delay != 0\n");
rel->retry_timer =
- GNUNET_TIME_relative_multiply (rel->expected_delay,
- CADET_RETRANSMIT_MARGIN);
+ GNUNET_TIME_relative_multiply (rel->expected_delay,
+ CADET_RETRANSMIT_MARGIN);
}
else
{
- LOG (GNUNET_ERROR_TYPE_DEBUG, "!! delay reset\n");
rel->retry_timer = CADET_RETRANSMIT_TIME;
}
- LOG (GNUNET_ERROR_TYPE_DEBUG, "!! using delay %s\n",
+ LOG (GNUNET_ERROR_TYPE_DEBUG, " using delay %s\n",
GNUNET_STRINGS_relative_time_to_string (rel->retry_timer,
GNUNET_NO));
rel->retry_task =
}
else
{
- LOG (GNUNET_ERROR_TYPE_DEBUG, "!! retry task %u\n", rel->retry_task);
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "retry running %p\n", rel->retry_task);
}
copy->chq = NULL;
break;
case GNUNET_MESSAGE_TYPE_CADET_DATA_ACK:
case GNUNET_MESSAGE_TYPE_CADET_CHANNEL_CREATE:
case GNUNET_MESSAGE_TYPE_CADET_CHANNEL_ACK:
- LOG (GNUNET_ERROR_TYPE_DEBUG, "!!! SENT %s\n", GC_m2s (chq->type));
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "sent %s\n", GC_m2s (chq->type));
rel = chq->rel;
GNUNET_assert (rel->uniq == chq);
rel->uniq = NULL;
&& GNUNET_NO == rel->ch->destroy)
{
GNUNET_assert (NULL == rel->retry_task);
- LOG (GNUNET_ERROR_TYPE_DEBUG, "!!! STD BACKOFF %s\n",
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "STD BACKOFF %s\n",
GNUNET_STRINGS_relative_time_to_string (rel->retry_timer,
GNUNET_NO));
rel->retry_timer = GNUNET_TIME_STD_BACKOFF (rel->retry_timer);
{
next = copy->next;
GNUNET_CONTAINER_DLL_remove (rel->head_recv, rel->tail_recv, copy);
- LOG (GNUNET_ERROR_TYPE_DEBUG, " COPYFREE BATCH RECV %p\n", copy);
+ LOG (GNUNET_ERROR_TYPE_DEBUG, " COPYFREE ALL RECV %p\n", copy);
GNUNET_break (NULL == copy->chq);
GNUNET_free (copy);
}
{
next = copy->next;
GNUNET_CONTAINER_DLL_remove (rel->head_sent, rel->tail_sent, copy);
- LOG (GNUNET_ERROR_TYPE_DEBUG, " COPYFREE BATCH %p\n", copy);
+ LOG (GNUNET_ERROR_TYPE_DEBUG, " COPYFREE ALL SEND %p\n", copy);
if (NULL != copy->chq)
{
if (NULL != copy->chq->tq)
*
* @param rel Reliability data.
* @param msg DataACK message with a bitfield of future ACK'd messages.
+ *
+ * @return How many messages have been freed.
*/
-static void
+static unsigned int
channel_rel_free_sent (struct CadetChannelReliability *rel,
const struct GNUNET_CADET_DataACK *msg)
{
uint32_t mid;
uint32_t target;
unsigned int i;
+ unsigned int r;
bitfield = msg->futures;
mid = ntohl (msg->mid);
- LOG (GNUNET_ERROR_TYPE_DEBUG, "free_sent_reliable %u %llX\n", mid, bitfield);
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "free_sent_reliable %u %lX\n", mid, bitfield);
LOG (GNUNET_ERROR_TYPE_DEBUG, " rel %p, head %p\n", rel, rel->head_sent);
- for (i = 0, copy = rel->head_sent;
+ for (i = 0, r = 0, copy = rel->head_sent;
i < 64 && NULL != copy && 0 != bitfield;
i++)
{
if (NULL == copy)
{
LOG (GNUNET_ERROR_TYPE_DEBUG, "run out of copies...\n");
- return;
+ return r;
}
/* Did we overshoot the target? (previously freed, it's ok) */
/* Now copy->mid == target, free it */
next = copy->next;
GNUNET_break (GNUNET_YES != rel_message_free (copy, GNUNET_YES));
+ r++;
copy = next;
}
LOG (GNUNET_ERROR_TYPE_DEBUG, "free_sent_reliable END\n");
+ return r;
}
struct GNUNET_TIME_Relative time;
rel = copy->rel;
- LOG (GNUNET_ERROR_TYPE_DEBUG, "!!! Freeing %u\n", copy->mid);
- if (update_time)
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Freeing %u\n", copy->mid);
+ if (GNUNET_YES == update_time)
{
time = GNUNET_TIME_absolute_get_duration (copy->timestamp);
if (0 == rel->expected_delay.rel_value_us)
rel->expected_delay.rel_value_us += time.rel_value_us;
rel->expected_delay.rel_value_us /= 8;
}
- LOG (GNUNET_ERROR_TYPE_INFO, "!!! took %s, new delay %s\n",
- GNUNET_STRINGS_relative_time_to_string (time, GNUNET_NO),
+ LOG (GNUNET_ERROR_TYPE_DEBUG, " message time %12s\n",
+ GNUNET_STRINGS_relative_time_to_string (time, GNUNET_NO));
+ LOG (GNUNET_ERROR_TYPE_DEBUG, " new delay %12s\n",
GNUNET_STRINGS_relative_time_to_string (rel->expected_delay,
GNUNET_NO));
rel->retry_timer = rel->expected_delay;
}
else
{
- LOG (GNUNET_ERROR_TYPE_INFO, "!!! batch free, ignoring timing\n");
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "batch free, ignoring timing\n");
}
rel->ch->pending_messages--;
if (NULL != copy->chq)
/* copy->q is set to NULL by ch_message_sent */
}
GNUNET_CONTAINER_DLL_remove (rel->head_sent, rel->tail_sent, copy);
- LOG (GNUNET_ERROR_TYPE_DEBUG, " COPYFREE %p\n", copy);
+ LOG (GNUNET_ERROR_TYPE_DEBUG, " free send copy MID %u at %p\n",
+ copy->mid, copy);
GNUNET_free (copy);
if (GNUNET_NO != rel->ch->destroy && 0 == rel->ch->pending_messages)
{
rel->client_ready = GNUNET_YES;
rel->expected_delay = rel->retry_timer;
- LOG (GNUNET_ERROR_TYPE_DEBUG, " !! retry timer confirm %s\n",
+ LOG (GNUNET_ERROR_TYPE_DEBUG, " confirm retry timer %s\n",
GNUNET_STRINGS_relative_time_to_string (rel->retry_timer, GNUNET_NO));
if (GCT_get_connections_buffer (ch->t) > 0 || GCT_is_loopback (ch->t))
send_client_ack (ch, fwd);
type = ntohs (msg->type);
size = ntohs (msg->size);
- LOG (GNUNET_ERROR_TYPE_DEBUG, "!!! SAVE %u %s\n", mid, GC_m2s (type));
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "save MID %u %s\n", mid, GC_m2s (type));
copy = GNUNET_malloc (sizeof (struct CadetReliableMessage) + size);
LOG (GNUNET_ERROR_TYPE_DEBUG, " at %p\n", copy);
copy->mid = mid;
{
case GNUNET_MESSAGE_TYPE_CADET_DATA:
/* Don't send hop ACK, wait for client to ACK */
- LOG (GNUNET_ERROR_TYPE_DEBUG, "!!! SEND loopback %u (%u)\n",
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "SEND loopback %u (%u)\n",
ntohl (((struct GNUNET_CADET_Data *) msgh)->mid), ntohs (msgh->size));
GCCH_handle_data (ch, (struct GNUNET_CADET_Data *) msgh, fwd);
break;
LOG (GNUNET_ERROR_TYPE_DEBUG, "destroying channel %s:%u\n",
GCT_2s (ch->t), ch->gid);
- GCCH_debug (ch);
+ GCCH_debug (ch, GNUNET_ERROR_TYPE_DEBUG);
c = ch->root;
if (NULL != c)
rel = fwd ? ch->dest_rel : ch->root_rel;
LOG (GNUNET_ERROR_TYPE_DEBUG, " get buffer, channel %s\n", GCCH_2s (ch));
- GCCH_debug (ch);
+ GCCH_debug (ch, GNUNET_ERROR_TYPE_DEBUG);
/* If rel is NULL it means that the end is not yet created,
* most probably is a loopback channel at the point of sending
* the ChannelCreate to itself.
return 64;
}
+ LOG (GNUNET_ERROR_TYPE_DEBUG, " n_recv %d\n", rel->n_recv);
return (64 - rel->n_recv);
}
mask = 0x1LL << delta;
msg.futures |= mask;
LOG (GNUNET_ERROR_TYPE_DEBUG,
- " setting bit for %u (delta %u) (%llX) -> %llX\n",
+ " setting bit for %u (delta %u) (%lX) -> %lX\n",
copy->mid, delta, mask, msg.futures);
}
- LOG (GNUNET_ERROR_TYPE_INFO, "===> DATA_ACK for %u + %llX\n",
- ack, msg.futures);
GCCH_send_prebuilt_message (&msg.header, ch, !fwd, NULL);
LOG (GNUNET_ERROR_TYPE_DEBUG, "send_data_ack END\n");
struct CadetReliableMessage *aux;
for (aux = rel->head_sent; NULL != aux; aux = aux->next)
{
- LOG (GNUNET_ERROR_TYPE_DEBUG, " - sent MID %u\n", aux->mid);
+ LOG (GNUNET_ERROR_TYPE_DEBUG, " - sent mid %u\n", aux->mid);
}
}
}
* Log channel info.
*
* @param ch Channel.
+ * @param level Debug level to use.
*/
void
-GCCH_debug (struct CadetChannel *ch)
+GCCH_debug (struct CadetChannel *ch, enum GNUNET_ErrorType level)
{
+ int do_log;
+
+ do_log = GNUNET_get_log_call_status (level & (~GNUNET_ERROR_TYPE_BULK),
+ "cadet-chn",
+ __FILE__, __FUNCTION__, __LINE__);
+ if (0 == do_log)
+ return;
+
if (NULL == ch)
{
- LOG (GNUNET_ERROR_TYPE_DEBUG, "*** DEBUG NULL CHANNEL ***\n");
+ LOG2 (level, "CHN *** DEBUG NULL CHANNEL ***\n");
return;
}
- LOG (GNUNET_ERROR_TYPE_DEBUG, "Channel %s:%X (%p)\n",
- GCT_2s (ch->t), ch->gid, ch);
- LOG (GNUNET_ERROR_TYPE_DEBUG, " root %p/%p\n",
- ch->root, ch->root_rel);
+ LOG2 (level, "CHN Channel %s:%X (%p)\n", GCT_2s (ch->t), ch->gid, ch);
+ LOG2 (level, "CHN root %p/%p\n", ch->root, ch->root_rel);
if (NULL != ch->root)
{
- LOG (GNUNET_ERROR_TYPE_DEBUG, " cli %s\n", GML_2s (ch->root));
- LOG (GNUNET_ERROR_TYPE_DEBUG, " ready %s\n",
- ch->root_rel->client_ready ? "YES" : "NO");
- LOG (GNUNET_ERROR_TYPE_DEBUG, " id %X\n", ch->lid_root);
+ LOG2 (level, "CHN cli %s\n", GML_2s (ch->root));
+ LOG2 (level, "CHN ready %s\n", ch->root_rel->client_ready ? "YES" : "NO");
+ LOG2 (level, "CHN id %X\n", ch->lid_root);
+ LOG2 (level, "CHN recv %d\n", ch->root_rel->n_recv);
+ LOG2 (level, "CHN MID r: %d, s: %d\n",
+ ch->root_rel->mid_recv, ch->root_rel->mid_send);
}
- LOG (GNUNET_ERROR_TYPE_DEBUG, " dest %p/%p\n",
+ LOG2 (level, "CHN dest %p/%p\n",
ch->dest, ch->dest_rel);
if (NULL != ch->dest)
{
- LOG (GNUNET_ERROR_TYPE_DEBUG, " cli %s\n", GML_2s (ch->dest));
- LOG (GNUNET_ERROR_TYPE_DEBUG, " ready %s\n",
- ch->dest_rel->client_ready ? "YES" : "NO");
- LOG (GNUNET_ERROR_TYPE_DEBUG, " id %X\n", ch->lid_dest);
+ LOG2 (level, "CHN cli %s\n", GML_2s (ch->dest));
+ LOG2 (level, "CHN ready %s\n", ch->dest_rel->client_ready ? "YES" : "NO");
+ LOG2 (level, "CHN id %X\n", ch->lid_dest);
+ LOG2 (level, "CHN recv %d\n", ch->dest_rel->n_recv);
+ LOG2 (level, "CHN MID r: %d, s: %d\n",
+ ch->dest_rel->mid_recv, ch->dest_rel->mid_send);
+
}
}
struct GNUNET_CADET_Data *payload;
uint16_t p2p_size = sizeof(struct GNUNET_CADET_Data) + size;
unsigned char cbuf[p2p_size];
+ unsigned char buffer;
/* Is the client in the channel? */
if ( !( (fwd &&
GCCH_send_prebuilt_message (&payload->header, ch, fwd, NULL);
if (is_loopback (ch))
- {
- if (GCCH_get_buffer (ch, fwd) > 0)
- GCCH_allow_client (ch, fwd);
-
- return GNUNET_OK;
- }
+ buffer = GCCH_get_buffer (ch, fwd);
+ else
+ buffer = GCT_get_connections_buffer (ch->t);
- if (GCT_get_connections_buffer (ch->t) > 0)
- {
+ if (0 < buffer)
GCCH_allow_client (ch, fwd);
- }
return GNUNET_OK;
}
CADET_ChannelNumber chid;
LOG (GNUNET_ERROR_TYPE_DEBUG, " towards %s:%u\n",
- GNUNET_i2s (&msg->peer), ntohl (msg->port));
+ GNUNET_i2s (&msg->peer), ntohl (msg->port));
chid = ntohl (msg->channel_id);
/* Sanity check for duplicate channel IDs */
return GNUNET_SYSERR;
}
- peer = GCP_get (&msg->peer);
+ peer = GCP_get (&msg->peer, GNUNET_YES);
GCP_add_tunnel (peer);
t = GCP_get_tunnel (peer);
{
struct CadetChannelReliability *rel;
struct CadetClient *c;
+ struct GNUNET_MessageHeader *payload_msg;
uint32_t mid;
+ uint16_t payload_type;
+ uint16_t payload_size;
/* If this is a remote (non-loopback) channel, find 'fwd'. */
if (GNUNET_SYSERR == fwd)
channel_confirm (ch, GNUNET_NO);
}
- GNUNET_STATISTICS_update (stats, "# data received", 1, GNUNET_NO);
+ payload_msg = (struct GNUNET_MessageHeader *) &msg[1];
+ payload_type = ntohs (payload_msg->type);
+ payload_size = ntohs (payload_msg->size);
+
+ GNUNET_STATISTICS_update (stats, "# messages received", 1, GNUNET_NO);
+ GNUNET_STATISTICS_update (stats, "# bytes received", payload_size, GNUNET_NO);
mid = ntohl (msg->mid);
- LOG (GNUNET_ERROR_TYPE_INFO, "<=== DATA %u %s on channel %s\n",
- mid, GC_f2s (fwd), GCCH_2s (ch));
+ LOG (GNUNET_ERROR_TYPE_INFO, "<== %s (%s %4u) on chan %s (%p) %s [%5u]\n",
+ GC_m2s (GNUNET_MESSAGE_TYPE_CADET_DATA), GC_m2s (payload_type), mid,
+ GCCH_2s (ch), ch, GC_f2s (fwd), ntohs (msg->header.size));
if (GNUNET_NO == ch->reliable ||
( !GC_is_pid_bigger (rel->mid_recv, mid) &&
GC_is_pid_bigger (rel->mid_recv + 64, mid) ) )
{
- LOG (GNUNET_ERROR_TYPE_DEBUG, "RECV %u (%u)\n",
- mid, ntohs (msg->header.size));
if (GNUNET_YES == ch->reliable)
{
/* Is this the exact next expected messasge? */
}
else
{
+ GNUNET_STATISTICS_update (stats, "# duplicate MID", 1, GNUNET_NO);
if (GC_is_pid_bigger (rel->mid_recv, mid))
{
GNUNET_break_op (0);
- LOG (GNUNET_ERROR_TYPE_WARNING,
- "MID %u on channel %s not expected (window: %u - %u). Dropping!\n",
- mid, GCCH_2s (ch), rel->mid_recv, rel->mid_recv + 63);
+ LOG (GNUNET_ERROR_TYPE_INFO,
+ "MID %u on channel %s not expected (window: %u - %u). Dropping!\n",
+ mid, GCCH_2s (ch), rel->mid_recv, rel->mid_recv + 63);
}
else
{
- LOG (GNUNET_ERROR_TYPE_WARNING,
+ LOG (GNUNET_ERROR_TYPE_INFO,
"Duplicate MID %u, channel %s (expecting MID %u). Re-sending ACK!\n",
mid, GCCH_2s (ch), rel->mid_recv);
if (NULL != rel->uniq)
{
LOG (GNUNET_ERROR_TYPE_WARNING,
- "We are trying to send an ACK, but don't seem have the "
- "bandwidth. Try to increase your ats QUOTA in you config file\n");
+ "We are trying to send an ACK, but don't seem have the "
+ "bandwidth. Have you set enough [ats] QUOTA in your config?\n");
}
}
}
ack = ntohl (msg->mid);
- LOG (GNUNET_ERROR_TYPE_INFO, "<=== %s ACK %u + %llX\n",
- GC_f2s (fwd), ack, msg->futures);
+ LOG (GNUNET_ERROR_TYPE_INFO,
+ "<== %s (0x%010lX %4u) on chan %s (%p) %s [%5u]\n",
+ GC_m2s (GNUNET_MESSAGE_TYPE_CADET_DATA_ACK), msg->futures, ack,
+ GCCH_2s (ch), ch, GC_f2s (fwd), ntohs (msg->header.size));
if (GNUNET_YES == fwd)
- {
rel = ch->root_rel;
- }
else
- {
rel = ch->dest_rel;
- }
+
if (NULL == rel)
{
- GNUNET_break_op (GNUNET_NO != ch->destroy);
+ GNUNET_break (GNUNET_NO != ch->destroy);
return;
}
if (GC_is_pid_bigger (copy->mid, ack))
{
LOG (GNUNET_ERROR_TYPE_DEBUG, " head %u, out!\n", copy->mid);
- channel_rel_free_sent (rel, msg);
+ if (0 < channel_rel_free_sent (rel, msg))
+ work = GNUNET_YES;
break;
}
work = GNUNET_YES;
LOG (GNUNET_ERROR_TYPE_DEBUG, " id %u\n", copy->mid);
next = copy->next;
if (GNUNET_YES == rel_message_free (copy, GNUNET_YES))
+ {
+ LOG (GNUNET_ERROR_TYPE_DEBUG, " channel destoyed\n");
return;
+ }
}
/* ACK client if needed and possible */
}
else
{
- /* Work was done but no task was pending? Shouldn't happen! */
- GNUNET_break (0);
+ /* Work was done but no task was pending.
+ * Task was cancelled by a retransmission that is sitting in the queue.
+ */
+ // FIXME add test to make sure this is the case, probably add return
+ // value to GCCH_send_prebuilt_message
}
}
}
struct CadetChannel *ch;
struct CadetClient *c;
int new_channel;
+ uint32_t port;
chid = ntohl (msg->chid);
+
ch = GCT_get_channel (t, chid);
if (NULL == ch)
{
{
new_channel = GNUNET_NO;
}
+ port = ntohl (msg->port);
+
+ LOG (GNUNET_ERROR_TYPE_INFO,
+ "<== %s ( 0x%08X %4u) on chan %s (%p) %s [%5u]\n",
+ GC_m2s (GNUNET_MESSAGE_TYPE_CADET_CHANNEL_CREATE), chid, port,
+ GCCH_2s (ch), ch, GC_f2s (GNUNET_YES), ntohs (msg->header.size));
if (GNUNET_YES == new_channel || GCT_is_loopback (t))
{
/* Find a destination client */
- ch->port = ntohl (msg->port);
+ ch->port = port;
LOG (GNUNET_ERROR_TYPE_DEBUG, " port %u\n", ch->port);
c = GML_client_get_by_port (ch->port);
if (NULL == c)
add_destination (ch, c);
if (GNUNET_YES == ch->reliable)
- LOG (GNUNET_ERROR_TYPE_DEBUG, "!!! Reliable\n");
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Reliable\n");
else
- LOG (GNUNET_ERROR_TYPE_DEBUG, "!!! Not Reliable\n");
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Not Reliable\n");
send_client_create (ch);
ch->state = CADET_CHANNEL_SENT;
void
GCCH_handle_nack (struct CadetChannel *ch)
{
+ LOG (GNUNET_ERROR_TYPE_INFO,
+ "<== %s ( 0x%08X %4u) on chan %s (%p) %s [%5u]\n",
+ GC_m2s (GNUNET_MESSAGE_TYPE_CADET_CHANNEL_NACK), ch->gid, 0,
+ GCCH_2s (ch), ch, "---", 0);
+
send_client_nack (ch);
GCCH_destroy (ch);
}
const struct GNUNET_CADET_ChannelManage *msg,
int fwd)
{
+ LOG (GNUNET_ERROR_TYPE_INFO,
+ "<== %s ( 0x%08X %4u) on chan %s (%p) %s [%5u]\n",
+ GC_m2s (GNUNET_MESSAGE_TYPE_CADET_CHANNEL_ACK), ch->gid, 0,
+ GCCH_2s (ch), ch, GC_f2s (fwd), ntohs (msg->header.size));
+
/* If this is a remote (non-loopback) channel, find 'fwd'. */
if (GNUNET_SYSERR == fwd)
{
{
struct CadetChannelReliability *rel;
+ LOG (GNUNET_ERROR_TYPE_INFO,
+ "<== %s ( 0x%08X %4u) on chan %s (%p) %s [%5u]\n",
+ GC_m2s (GNUNET_MESSAGE_TYPE_CADET_CHANNEL_DESTROY), ch->gid, 0,
+ GCCH_2s (ch), ch, GC_f2s (fwd), ntohs (msg->header.size));
+
/* If this is a remote (non-loopback) channel, find 'fwd'. */
if (GNUNET_SYSERR == fwd)
{
fwd = (NULL != ch->dest) ? GNUNET_YES : GNUNET_NO;
}
- GCCH_debug (ch);
+ GCCH_debug (ch, GNUNET_ERROR_TYPE_DEBUG);
if ( (fwd && NULL == ch->dest) || (!fwd && NULL == ch->root) )
{
/* Not for us (don't destroy twice a half-open loopback channel) */
void *existing_copy)
{
struct CadetChannelQueue *chq;
+ uint32_t data_id;
uint16_t type;
+ uint16_t size;
+ char info[32];
type = ntohs (message->type);
- LOG (GNUNET_ERROR_TYPE_INFO, "===> %s %s on channel %s\n",
- GC_m2s (type), GC_f2s (fwd), GCCH_2s (ch));
+ size = ntohs (message->size);
+
+ switch (type)
+ {
+ case GNUNET_MESSAGE_TYPE_CADET_DATA:
+ {
+ struct GNUNET_CADET_Data *data_msg;
+ struct GNUNET_MessageHeader *payload_msg;
+ uint16_t payload_type;
+
+ data_msg = (struct GNUNET_CADET_Data *) message;
+ data_id = ntohl (data_msg->mid);
+ payload_msg = (struct GNUNET_MessageHeader *) &data_msg[1];
+ payload_type = ntohs (payload_msg->type);
+ strncpy (info, GC_m2s (payload_type), 31);
+ info[31] = '\0';
+ break;
+ }
+ case GNUNET_MESSAGE_TYPE_CADET_DATA_ACK:
+ {
+ struct GNUNET_CADET_DataACK *ack_msg;
+ ack_msg = (struct GNUNET_CADET_DataACK *) message;
+ data_id = ntohl (ack_msg->mid);
+ SPRINTF (info, "0x%010lX", ack_msg->futures);
+ break;
+ }
+ case GNUNET_MESSAGE_TYPE_CADET_CHANNEL_CREATE:
+ {
+ struct GNUNET_CADET_ChannelCreate *cc_msg;
+ cc_msg = (struct GNUNET_CADET_ChannelCreate *) message;
+ data_id = ntohl (cc_msg->port);
+ SPRINTF (info, " 0x%08X", ntohl (cc_msg->chid));
+ break;
+ }
+ case GNUNET_MESSAGE_TYPE_CADET_CHANNEL_ACK:
+ case GNUNET_MESSAGE_TYPE_CADET_CHANNEL_NACK:
+ case GNUNET_MESSAGE_TYPE_CADET_CHANNEL_DESTROY:
+ {
+ struct GNUNET_CADET_ChannelManage *m_msg;
+ m_msg = (struct GNUNET_CADET_ChannelManage *) message;
+ data_id = 0;
+ SPRINTF (info, " 0x%08X", ntohl (m_msg->chid));
+ break;
+ }
+ default:
+ data_id = 0;
+ info[0] = '\0';
+ }
+ LOG (GNUNET_ERROR_TYPE_INFO,
+ "==> %s (%12s %4u) on chan %s (%p) %s [%5u]\n",
+ GC_m2s (type), info, data_id,
+ GCCH_2s (ch), ch, GC_f2s (fwd), size);
if (GCT_is_loopback (ch->t))
{
switch (type)
{
- struct GNUNET_CADET_Data *payload;
case GNUNET_MESSAGE_TYPE_CADET_DATA:
-
- payload = (struct GNUNET_CADET_Data *) message;
- LOG (GNUNET_ERROR_TYPE_INFO, "===> %s %u\n",
- GC_m2s (type), ntohl (payload->mid));
if (GNUNET_YES == ch->reliable)
{
chq = GNUNET_new (struct CadetChannelQueue);
default:
GNUNET_break (0);
- LOG (GNUNET_ERROR_TYPE_DEBUG, "type %s unknown!\n", GC_m2s (type));
+ LOG (GNUNET_ERROR_TYPE_WARNING, "type %s unknown!\n", GC_m2s (type));
fire_and_forget (message, ch, GNUNET_YES);
}
}