aboutsummaryrefslogtreecommitdiff
path: root/src/cadet/gnunet-service-cadet_connection.c
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/cadet/gnunet-service-cadet_connection.c
parente80db2f143f1ee65d8d62d52a3821d797b21bdde (diff)
downloadgnunet-aae0e990d75448c3260ed74427a6a1e1658f8f0a.tar.gz
gnunet-aae0e990d75448c3260ed74427a6a1e1658f8f0a.zip
cosmetics
Diffstat (limited to 'src/cadet/gnunet-service-cadet_connection.c')
-rw-r--r--src/cadet/gnunet-service-cadet_connection.c28
1 files changed, 19 insertions, 9 deletions
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 }