From aae0e990d75448c3260ed74427a6a1e1658f8f0a Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Mon, 9 Jan 2017 17:50:10 +0100 Subject: [PATCH] cosmetics --- src/cadet/gnunet-service-cadet_channel.c | 14 ++++++----- src/cadet/gnunet-service-cadet_connection.c | 28 ++++++++++++++------- src/cadet/gnunet-service-cadet_peer.c | 3 ++- 3 files changed, 29 insertions(+), 16 deletions(-) diff --git a/src/cadet/gnunet-service-cadet_channel.c b/src/cadet/gnunet-service-cadet_channel.c index 11f23d38a..d2d176e83 100644 --- a/src/cadet/gnunet-service-cadet_channel.c +++ b/src/cadet/gnunet-service-cadet_channel.c @@ -1969,21 +1969,23 @@ GCCH_handle_data (struct CadetChannel *ch, 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); } } @@ -2001,7 +2003,7 @@ GCCH_handle_data (struct CadetChannel *ch, 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); } diff --git a/src/cadet/gnunet-service-cadet_connection.c b/src/cadet/gnunet-service-cadet_connection.c index c0ac32b06..343e372b2 100644 --- a/src/cadet/gnunet-service-cadet_connection.c +++ b/src/cadet/gnunet-service-cadet_connection.c @@ -132,7 +132,8 @@ struct CadetFlowControl 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; @@ -540,7 +541,10 @@ send_poll (void *cls); * @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; @@ -598,7 +602,8 @@ send_ack (struct CadetConnection *c, unsigned int buffer, int fwd, int force) 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 */ @@ -607,7 +612,9 @@ send_ack (struct CadetConnection *c, unsigned int buffer, int fwd, int force) 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); @@ -2310,8 +2317,8 @@ GCC_handle_ack (struct CadetPeer *peer, 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); @@ -2458,7 +2465,9 @@ check_message (const struct GNUNET_MessageHeader *message, { 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, @@ -2963,8 +2972,9 @@ GCC_get_allowed (struct CadetConnection *c, int fwd) 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; } diff --git a/src/cadet/gnunet-service-cadet_peer.c b/src/cadet/gnunet-service-cadet_peer.c index c3701a39e..918bf4e0c 100644 --- a/src/cadet/gnunet-service-cadet_peer.c +++ b/src/cadet/gnunet-service-cadet_peer.c @@ -1224,7 +1224,8 @@ GCP_send (struct CadetPeer *peer, { 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, -- 2.25.1