aboutsummaryrefslogtreecommitdiff
path: root/src/cadet/cadet_api.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2017-01-23 11:13:55 +0100
committerChristian Grothoff <christian@grothoff.org>2017-01-23 11:13:55 +0100
commit64f3755912bb85593f92a7e2e63810dbb3ab98ea (patch)
tree467eb6b83dcad349817b9d65a663370258cec6ea /src/cadet/cadet_api.c
parent52255b0df008cd1c2db056def973d67cf51885a4 (diff)
downloadgnunet-64f3755912bb85593f92a7e2e63810dbb3ab98ea.tar.gz
gnunet-64f3755912bb85593f92a7e2e63810dbb3ab98ea.zip
allow more than one ACK being given to us at a time
Diffstat (limited to 'src/cadet/cadet_api.c')
-rw-r--r--src/cadet/cadet_api.c24
1 files changed, 13 insertions, 11 deletions
diff --git a/src/cadet/cadet_api.c b/src/cadet/cadet_api.c
index 750e70e29..872d414a7 100644
--- a/src/cadet/cadet_api.c
+++ b/src/cadet/cadet_api.c
@@ -268,7 +268,7 @@ struct GNUNET_CADET_Channel
268 /** 268 /**
269 * Are we allowed to send to the service? 269 * Are we allowed to send to the service?
270 */ 270 */
271 int allow_send; 271 unsigned int allow_send;
272 272
273}; 273};
274 274
@@ -413,7 +413,6 @@ create_channel (struct GNUNET_CADET_Handle *h,
413 { 413 {
414 ch->ccn = ccn; 414 ch->ccn = ccn;
415 } 415 }
416 ch->allow_send = GNUNET_NO;
417 return ch; 416 return ch;
418} 417}
419 418
@@ -568,8 +567,10 @@ request_data (void *cls)
568 "Requesting Data: %u bytes\n", 567 "Requesting Data: %u bytes\n",
569 th->size); 568 th->size);
570 569
571 GNUNET_assert (GNUNET_YES == th->channel->allow_send); 570 GNUNET_assert (0 < th->channel->allow_send);
572 th->channel->allow_send = GNUNET_NO; 571 th->channel->allow_send--;
572 /* NOTE: we may be allowed to send another packet immediately,
573 albeit the current logic waits for the ACK. */
573 th->request_data_task = NULL; 574 th->request_data_task = NULL;
574 th->channel->packet_size = 0; 575 th->channel->packet_size = 0;
575 remove_from_queue (th); 576 remove_from_queue (th);
@@ -621,7 +622,6 @@ handle_channel_created (void *cls,
621 void *ctx; 622 void *ctx;
622 623
623 ch = create_channel (h, ccn); 624 ch = create_channel (h, ccn);
624 ch->allow_send = GNUNET_NO;
625 ch->peer = GNUNET_PEER_intern (&msg->peer); 625 ch->peer = GNUNET_PEER_intern (&msg->peer);
626 ch->cadet = h; 626 ch->cadet = h;
627 ch->ccn = ccn; 627 ch->ccn = ccn;
@@ -801,21 +801,24 @@ handle_local_ack (void *cls,
801 LOG (GNUNET_ERROR_TYPE_DEBUG, 801 LOG (GNUNET_ERROR_TYPE_DEBUG,
802 "Got an ACK on channel %X!\n", 802 "Got an ACK on channel %X!\n",
803 ntohl (ch->ccn.channel_of_client)); 803 ntohl (ch->ccn.channel_of_client));
804 ch->allow_send = GNUNET_YES; 804 ch->allow_send++;
805 if (0 < ch->packet_size) 805 if (0 < ch->packet_size)
806 { 806 {
807 struct GNUNET_CADET_TransmitHandle *th; 807 struct GNUNET_CADET_TransmitHandle *th;
808 struct GNUNET_CADET_TransmitHandle *next; 808 struct GNUNET_CADET_TransmitHandle *next;
809
809 LOG (GNUNET_ERROR_TYPE_DEBUG, 810 LOG (GNUNET_ERROR_TYPE_DEBUG,
810 " pending data, sending %u bytes!\n", 811 " pending data, sending %u bytes!\n",
811 ch->packet_size); 812 ch->packet_size);
812 for (th = h->th_head; NULL != th; th = next) 813 for (th = h->th_head; NULL != th; th = next)
813 { 814 {
814 next = th->next; 815 next = th->next;
815 if (th->channel == ch) 816 if ( (th->channel == ch) &&
817 (NULL == th->request_data_task) )
816 { 818 {
817 GNUNET_assert (NULL == th->request_data_task); 819 th->request_data_task
818 th->request_data_task = GNUNET_SCHEDULER_add_now (&request_data, th); 820 = GNUNET_SCHEDULER_add_now (&request_data,
821 th);
819 break; 822 break;
820 } 823 }
821 } 824 }
@@ -1612,7 +1615,6 @@ GNUNET_CADET_channel_create (struct GNUNET_CADET_Handle *h,
1612 msg->port = *port; 1615 msg->port = *port;
1613 msg->peer = *peer; 1616 msg->peer = *peer;
1614 msg->opt = htonl (options); 1617 msg->opt = htonl (options);
1615 ch->allow_send = GNUNET_NO;
1616 GNUNET_MQ_send (h->mq, 1618 GNUNET_MQ_send (h->mq,
1617 env); 1619 env);
1618 return ch; 1620 return ch;
@@ -1741,7 +1743,7 @@ GNUNET_CADET_notify_transmit_ready (struct GNUNET_CADET_Channel *channel,
1741 LOG (GNUNET_ERROR_TYPE_DEBUG, " total size %u\n", th->size); 1743 LOG (GNUNET_ERROR_TYPE_DEBUG, " total size %u\n", th->size);
1742 th->notify = notify; 1744 th->notify = notify;
1743 th->notify_cls = notify_cls; 1745 th->notify_cls = notify_cls;
1744 if (GNUNET_YES == channel->allow_send) 1746 if (0 != channel->allow_send)
1745 th->request_data_task = GNUNET_SCHEDULER_add_now (&request_data, th); 1747 th->request_data_task = GNUNET_SCHEDULER_add_now (&request_data, th);
1746 else 1748 else
1747 add_to_queue (channel->cadet, th); 1749 add_to_queue (channel->cadet, th);