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) ) )
+ if ( (GNUNET_NO == ch->reliable) ||
+ ( (! GC_is_pid_bigger (rel->mid_recv, mid)) &&
+ GC_is_pid_bigger (rel->mid_recv + 64, mid) ) )
{
if (GNUNET_YES == ch->reliable)
{
/* Is this the exact next expected messasge? */
if (mid == rel->mid_recv)
{
- LOG (GNUNET_ERROR_TYPE_DEBUG, "as expected, sending to client\n");
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "as expected, sending to client\n");
send_client_data (ch, msg, fwd);
}
else
{
- LOG (GNUNET_ERROR_TYPE_DEBUG, "save for later\n");
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "save for later\n");
add_buffered_data (msg, rel);
}
}
if (GC_is_pid_bigger (rel->mid_recv, mid))
{
GNUNET_break_op (0);
- LOG (GNUNET_ERROR_TYPE_INFO,
+ 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);
}
uint32_t recv_bitmap;
/**
- * Last ACK sent to the peer (peer can't send more than this PID).
+ * Last ACK sent to the peer (peer is not allowed to send
+ * messages with PIDs higher than this value).
*/
uint32_t last_ack_sent;
* @param force Don't optimize out.
*/
static void
-send_ack (struct CadetConnection *c, unsigned int buffer, int fwd, int force)
+send_ack (struct CadetConnection *c,
+ unsigned int buffer,
+ int fwd,
+ int force)
{
struct CadetFlowControl *next_fc;
struct CadetFlowControl *prev_fc;
return;
}
}
-
+ GNUNET_break (GC_is_pid_bigger (ack,
+ prev_fc->last_ack_sent));
prev_fc->last_ack_sent = ack;
/* Build ACK message and send on conn */
msg.ack = htonl (ack);
msg.cid = c->id;
- prev_fc->ack_msg = GCC_send_prebuilt_message (&msg.header, UINT16_MAX, ack,
+ prev_fc->ack_msg = GCC_send_prebuilt_message (&msg.header,
+ UINT16_MAX,
+ ack,
c, !fwd, GNUNET_YES,
NULL, NULL);
GNUNET_assert (NULL != prev_fc->ack_msg);
fc->last_ack_recv = ack;
/* Cancel polling if the ACK is big enough. */
- if (NULL != fc->poll_task &&
- GC_is_pid_bigger (fc->last_ack_recv, fc->last_pid_sent))
+ if ( (NULL != fc->poll_task) &
+ GC_is_pid_bigger (fc->last_ack_recv, fc->last_pid_sent))
{
LOG (GNUNET_ERROR_TYPE_DEBUG, " Cancel poll\n");
GNUNET_SCHEDULER_cancel (fc->poll_task);
{
fc = fwd ? &c->bck_fc : &c->fwd_fc;
LOG (GNUNET_ERROR_TYPE_DEBUG, " PID %u (expected %u - %u)\n",
- pid, fc->last_pid_recv + 1, fc->last_ack_sent);
+ pid,
+ fc->last_pid_recv + 1,
+ fc->last_ack_sent);
if (GC_is_pid_bigger (pid, fc->last_ack_sent))
{
GNUNET_STATISTICS_update (stats,
struct CadetFlowControl *fc;
fc = fwd ? &c->fwd_fc : &c->bck_fc;
- if (CADET_CONNECTION_READY != c->state
- || GC_is_pid_bigger (fc->last_pid_recv, fc->last_ack_sent))
+ if ( (CADET_CONNECTION_READY != c->state) ||
+ GC_is_pid_bigger (fc->last_pid_recv,
+ fc->last_ack_sent) )
{
return 0;
}
{
if (GNUNET_YES == should_I_drop ())
{
- LOG (GNUNET_ERROR_TYPE_WARNING, "DD %s (%s %u) on conn %s %s\n",
+ LOG (GNUNET_ERROR_TYPE_WARNING,
+ "DD %s (%s %u) on conn %s %s (random drop for testing)\n",
GC_m2s (q->type), GC_m2s (q->payload_type),
q->payload_id, GCC_2s (c), GC_f2s (q->c_fwd));
q->drop_task = GNUNET_SCHEDULER_add_now (&drop_cb,