aboutsummaryrefslogtreecommitdiff
path: root/src/cadet/cadet_api.c
diff options
context:
space:
mode:
authorBart Polot <bart.polot+voyager@gmail.com>2017-02-02 18:13:00 +0100
committerBart Polot <bart.polot+voyager@gmail.com>2017-02-02 18:13:00 +0100
commitdc803bb23182bb53c3a89634665592198f5e8d9c (patch)
treec4b9e6c1fec3c81804114bd176410dde5d6cdf7e /src/cadet/cadet_api.c
parent17047b7bcbe3f1756028058a9887416c6afab5d8 (diff)
downloadgnunet-dc803bb23182bb53c3a89634665592198f5e8d9c.tar.gz
gnunet-dc803bb23182bb53c3a89634665592198f5e8d9c.zip
Only call window_size on incrementing size, allow ACK+1 messages to be taken
Diffstat (limited to 'src/cadet/cadet_api.c')
-rw-r--r--src/cadet/cadet_api.c50
1 files changed, 38 insertions, 12 deletions
diff --git a/src/cadet/cadet_api.c b/src/cadet/cadet_api.c
index d3bb1abd6..c07b10f5b 100644
--- a/src/cadet/cadet_api.c
+++ b/src/cadet/cadet_api.c
@@ -296,6 +296,11 @@ struct GNUNET_CADET_Channel
296 struct GNUNET_SCHEDULER_Task *mq_cont; 296 struct GNUNET_SCHEDULER_Task *mq_cont;
297 297
298 /** 298 /**
299 * Pending envelope in case we don't have an ACK from the service.
300 */
301 struct GNUNET_MQ_Envelope *pending_env;
302
303 /**
299 * Window change handler. 304 * Window change handler.
300 */ 305 */
301 GNUNET_CADET_WindowSizeEventHandler window_changes; 306 GNUNET_CADET_WindowSizeEventHandler window_changes;
@@ -552,7 +557,11 @@ destroy_channel (struct GNUNET_CADET_Channel *ch)
552 GNUNET_CONTAINER_DLL_remove (h->channels_head, 557 GNUNET_CONTAINER_DLL_remove (h->channels_head,
553 h->channels_tail, 558 h->channels_tail,
554 ch); 559 ch);
555 560 if (NULL != ch->mq_cont)
561 {
562 GNUNET_SCHEDULER_cancel (ch->mq_cont);
563 ch->mq_cont = NULL;
564 }
556 /* signal channel destruction */ 565 /* signal channel destruction */
557 if (0 != ch->peer) 566 if (0 != ch->peer)
558 { 567 {
@@ -663,6 +672,7 @@ cadet_mq_send_continue (void *cls)
663{ 672{
664 struct GNUNET_CADET_Channel *ch = cls; 673 struct GNUNET_CADET_Channel *ch = cls;
665 674
675 ch->mq_cont = NULL;
666 GNUNET_MQ_impl_send_continue (ch->mq); 676 GNUNET_MQ_impl_send_continue (ch->mq);
667} 677}
668 678
@@ -710,15 +720,21 @@ cadet_mq_send_impl (struct GNUNET_MQ_Handle *mq,
710 GNUNET_MESSAGE_TYPE_CADET_LOCAL_DATA, 720 GNUNET_MESSAGE_TYPE_CADET_LOCAL_DATA,
711 msg); 721 msg);
712 cadet_msg->ccn = ch->ccn; 722 cadet_msg->ccn = ch->ccn;
713 GNUNET_MQ_send (h->mq, env);
714 723
715 GNUNET_assert (0 < ch->allow_send);
716 ch->allow_send--;
717 notify_window_size (ch);
718 if (0 < ch->allow_send) 724 if (0 < ch->allow_send)
719 { 725 {
726 /* Service has allowed this message, just send it and continue accepting */
727 GNUNET_MQ_send (h->mq, env);
728 ch->allow_send--;
720 ch->mq_cont = GNUNET_SCHEDULER_add_now (&cadet_mq_send_continue, ch); 729 ch->mq_cont = GNUNET_SCHEDULER_add_now (&cadet_mq_send_continue, ch);
721 } /* Otherwise it will be called upon ACK receipt. */ 730 // notify_window_size (ch); /* FIXME add "verbose" setting? */
731 }
732 else
733 {
734 /* Service has NOT allowed this message, queue it and wait for an ACK */
735 GNUNET_assert (NULL != ch->pending_env);
736 ch->pending_env = env;
737 }
722} 738}
723 739
724 740
@@ -763,6 +779,7 @@ cadet_mq_error_handler (void *cls,
763 * @param mq message queue 779 * @param mq message queue
764 * @param impl_state state specific to the implementation 780 * @param impl_state state specific to the implementation
765 */ 781 */
782
766static void 783static void
767cadet_mq_cancel_impl (struct GNUNET_MQ_Handle *mq, 784cadet_mq_cancel_impl (struct GNUNET_MQ_Handle *mq,
768 void *impl_state) 785 void *impl_state)
@@ -1070,15 +1087,24 @@ handle_local_ack (void *cls,
1070 return; 1087 return;
1071 } 1088 }
1072 ch->allow_send++; 1089 ch->allow_send++;
1073 LOG (GNUNET_ERROR_TYPE_DEBUG,
1074 "Got an ACK on channel %X, allow send now %u!\n",
1075 ntohl (ch->ccn.channel_of_client),
1076 ch->allow_send);
1077 if (NULL != ch->mq) 1090 if (NULL != ch->mq)
1078 { 1091 {
1079 notify_window_size (ch); 1092 if (NULL == ch->pending_env)
1080 if (1 == ch->allow_send)
1081 { 1093 {
1094 LOG (GNUNET_ERROR_TYPE_DEBUG,
1095 "Got an ACK on mq channel %X, allow send now %u!\n",
1096 ntohl (ch->ccn.channel_of_client),
1097 ch->allow_send);
1098 notify_window_size (ch);
1099 }
1100 else
1101 {
1102 LOG (GNUNET_ERROR_TYPE_DEBUG,
1103 "Got an ACK on channel %X, sending pending message!\n",
1104 ntohl (ch->ccn.channel_of_client));
1105 GNUNET_MQ_send (h->mq, ch->pending_env);
1106 ch->allow_send--;
1107 ch->pending_env = NULL;
1082 ch->mq_cont = GNUNET_SCHEDULER_add_now (&cadet_mq_send_continue, ch); 1108 ch->mq_cont = GNUNET_SCHEDULER_add_now (&cadet_mq_send_continue, ch);
1083 } 1109 }
1084 return; 1110 return;