aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2017-01-09 17:50:10 +0100
committerChristian Grothoff <christian@grothoff.org>2017-01-09 21:19:01 +0100
commitaae0e990d75448c3260ed74427a6a1e1658f8f0a (patch)
treed8dcbae16108367798c674d57309c697d14e4d67 /src
parente80db2f143f1ee65d8d62d52a3821d797b21bdde (diff)
downloadgnunet-aae0e990d75448c3260ed74427a6a1e1658f8f0a.tar.gz
gnunet-aae0e990d75448c3260ed74427a6a1e1658f8f0a.zip
cosmetics
Diffstat (limited to 'src')
-rw-r--r--src/cadet/gnunet-service-cadet_channel.c14
-rw-r--r--src/cadet/gnunet-service-cadet_connection.c28
-rw-r--r--src/cadet/gnunet-service-cadet_peer.c3
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,
1969 GC_m2s (GNUNET_MESSAGE_TYPE_CADET_DATA), GC_m2s (payload_type), mid, 1969 GC_m2s (GNUNET_MESSAGE_TYPE_CADET_DATA), GC_m2s (payload_type), mid,
1970 GCCH_2s (ch), ch, GC_f2s (fwd), ntohs (msg->header.size)); 1970 GCCH_2s (ch), ch, GC_f2s (fwd), ntohs (msg->header.size));
1971 1971
1972 if (GNUNET_NO == ch->reliable || 1972 if ( (GNUNET_NO == ch->reliable) ||
1973 ( !GC_is_pid_bigger (rel->mid_recv, mid) && 1973 ( (! GC_is_pid_bigger (rel->mid_recv, mid)) &&
1974 GC_is_pid_bigger (rel->mid_recv + 64, mid) ) ) 1974 GC_is_pid_bigger (rel->mid_recv + 64, mid) ) )
1975 { 1975 {
1976 if (GNUNET_YES == ch->reliable) 1976 if (GNUNET_YES == ch->reliable)
1977 { 1977 {
1978 /* Is this the exact next expected messasge? */ 1978 /* Is this the exact next expected messasge? */
1979 if (mid == rel->mid_recv) 1979 if (mid == rel->mid_recv)
1980 { 1980 {
1981 LOG (GNUNET_ERROR_TYPE_DEBUG, "as expected, sending to client\n"); 1981 LOG (GNUNET_ERROR_TYPE_DEBUG,
1982 "as expected, sending to client\n");
1982 send_client_data (ch, msg, fwd); 1983 send_client_data (ch, msg, fwd);
1983 } 1984 }
1984 else 1985 else
1985 { 1986 {
1986 LOG (GNUNET_ERROR_TYPE_DEBUG, "save for later\n"); 1987 LOG (GNUNET_ERROR_TYPE_DEBUG,
1988 "save for later\n");
1987 add_buffered_data (msg, rel); 1989 add_buffered_data (msg, rel);
1988 } 1990 }
1989 } 1991 }
@@ -2001,7 +2003,7 @@ GCCH_handle_data (struct CadetChannel *ch,
2001 if (GC_is_pid_bigger (rel->mid_recv, mid)) 2003 if (GC_is_pid_bigger (rel->mid_recv, mid))
2002 { 2004 {
2003 GNUNET_break_op (0); 2005 GNUNET_break_op (0);
2004 LOG (GNUNET_ERROR_TYPE_INFO, 2006 LOG (GNUNET_ERROR_TYPE_WARNING,
2005 "MID %u on channel %s not expected (window: %u - %u). Dropping!\n", 2007 "MID %u on channel %s not expected (window: %u - %u). Dropping!\n",
2006 mid, GCCH_2s (ch), rel->mid_recv, rel->mid_recv + 63); 2008 mid, GCCH_2s (ch), rel->mid_recv, rel->mid_recv + 63);
2007 } 2009 }
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
132 uint32_t recv_bitmap; 132 uint32_t recv_bitmap;
133 133
134 /** 134 /**
135 * Last ACK sent to the peer (peer can't send more than this PID). 135 * Last ACK sent to the peer (peer is not allowed to send
136 * messages with PIDs higher than this value).
136 */ 137 */
137 uint32_t last_ack_sent; 138 uint32_t last_ack_sent;
138 139
@@ -540,7 +541,10 @@ send_poll (void *cls);
540 * @param force Don't optimize out. 541 * @param force Don't optimize out.
541 */ 542 */
542static void 543static void
543send_ack (struct CadetConnection *c, unsigned int buffer, int fwd, int force) 544send_ack (struct CadetConnection *c,
545 unsigned int buffer,
546 int fwd,
547 int force)
544{ 548{
545 struct CadetFlowControl *next_fc; 549 struct CadetFlowControl *next_fc;
546 struct CadetFlowControl *prev_fc; 550 struct CadetFlowControl *prev_fc;
@@ -598,7 +602,8 @@ send_ack (struct CadetConnection *c, unsigned int buffer, int fwd, int force)
598 return; 602 return;
599 } 603 }
600 } 604 }
601 605 GNUNET_break (GC_is_pid_bigger (ack,
606 prev_fc->last_ack_sent));
602 prev_fc->last_ack_sent = ack; 607 prev_fc->last_ack_sent = ack;
603 608
604 /* Build ACK message and send on conn */ 609 /* Build ACK message and send on conn */
@@ -607,7 +612,9 @@ send_ack (struct CadetConnection *c, unsigned int buffer, int fwd, int force)
607 msg.ack = htonl (ack); 612 msg.ack = htonl (ack);
608 msg.cid = c->id; 613 msg.cid = c->id;
609 614
610 prev_fc->ack_msg = GCC_send_prebuilt_message (&msg.header, UINT16_MAX, ack, 615 prev_fc->ack_msg = GCC_send_prebuilt_message (&msg.header,
616 UINT16_MAX,
617 ack,
611 c, !fwd, GNUNET_YES, 618 c, !fwd, GNUNET_YES,
612 NULL, NULL); 619 NULL, NULL);
613 GNUNET_assert (NULL != prev_fc->ack_msg); 620 GNUNET_assert (NULL != prev_fc->ack_msg);
@@ -2310,8 +2317,8 @@ GCC_handle_ack (struct CadetPeer *peer,
2310 fc->last_ack_recv = ack; 2317 fc->last_ack_recv = ack;
2311 2318
2312 /* Cancel polling if the ACK is big enough. */ 2319 /* Cancel polling if the ACK is big enough. */
2313 if (NULL != fc->poll_task && 2320 if ( (NULL != fc->poll_task) &
2314 GC_is_pid_bigger (fc->last_ack_recv, fc->last_pid_sent)) 2321 GC_is_pid_bigger (fc->last_ack_recv, fc->last_pid_sent))
2315 { 2322 {
2316 LOG (GNUNET_ERROR_TYPE_DEBUG, " Cancel poll\n"); 2323 LOG (GNUNET_ERROR_TYPE_DEBUG, " Cancel poll\n");
2317 GNUNET_SCHEDULER_cancel (fc->poll_task); 2324 GNUNET_SCHEDULER_cancel (fc->poll_task);
@@ -2458,7 +2465,9 @@ check_message (const struct GNUNET_MessageHeader *message,
2458 { 2465 {
2459 fc = fwd ? &c->bck_fc : &c->fwd_fc; 2466 fc = fwd ? &c->bck_fc : &c->fwd_fc;
2460 LOG (GNUNET_ERROR_TYPE_DEBUG, " PID %u (expected %u - %u)\n", 2467 LOG (GNUNET_ERROR_TYPE_DEBUG, " PID %u (expected %u - %u)\n",
2461 pid, fc->last_pid_recv + 1, fc->last_ack_sent); 2468 pid,
2469 fc->last_pid_recv + 1,
2470 fc->last_ack_sent);
2462 if (GC_is_pid_bigger (pid, fc->last_ack_sent)) 2471 if (GC_is_pid_bigger (pid, fc->last_ack_sent))
2463 { 2472 {
2464 GNUNET_STATISTICS_update (stats, 2473 GNUNET_STATISTICS_update (stats,
@@ -2963,8 +2972,9 @@ GCC_get_allowed (struct CadetConnection *c, int fwd)
2963 struct CadetFlowControl *fc; 2972 struct CadetFlowControl *fc;
2964 2973
2965 fc = fwd ? &c->fwd_fc : &c->bck_fc; 2974 fc = fwd ? &c->fwd_fc : &c->bck_fc;
2966 if (CADET_CONNECTION_READY != c->state 2975 if ( (CADET_CONNECTION_READY != c->state) ||
2967 || GC_is_pid_bigger (fc->last_pid_recv, fc->last_ack_sent)) 2976 GC_is_pid_bigger (fc->last_pid_recv,
2977 fc->last_ack_sent) )
2968 { 2978 {
2969 return 0; 2979 return 0;
2970 } 2980 }
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,
1224 { 1224 {
1225 if (GNUNET_YES == should_I_drop ()) 1225 if (GNUNET_YES == should_I_drop ())
1226 { 1226 {
1227 LOG (GNUNET_ERROR_TYPE_WARNING, "DD %s (%s %u) on conn %s %s\n", 1227 LOG (GNUNET_ERROR_TYPE_WARNING,
1228 "DD %s (%s %u) on conn %s %s (random drop for testing)\n",
1228 GC_m2s (q->type), GC_m2s (q->payload_type), 1229 GC_m2s (q->type), GC_m2s (q->payload_type),
1229 q->payload_id, GCC_2s (c), GC_f2s (q->c_fwd)); 1230 q->payload_id, GCC_2s (c), GC_f2s (q->c_fwd));
1230 q->drop_task = GNUNET_SCHEDULER_add_now (&drop_cb, 1231 q->drop_task = GNUNET_SCHEDULER_add_now (&drop_cb,