diff options
author | Bart Polot <bart@net.in.tum.de> | 2014-07-02 19:30:45 +0000 |
---|---|---|
committer | Bart Polot <bart@net.in.tum.de> | 2014-07-02 19:30:45 +0000 |
commit | f5102e55512718ae21b996ae31ba13f02cae5d7c (patch) | |
tree | 53a572fbb791f5d41bac16ee57f937e4ebd5bd05 /src/cadet/gnunet-service-cadet_channel.c | |
parent | 0b41ec9e4ca866552554305eef223d5ee9995aca (diff) | |
download | gnunet-f5102e55512718ae21b996ae31ba13f02cae5d7c.tar.gz gnunet-f5102e55512718ae21b996ae31ba13f02cae5d7c.zip |
- don't update ACK based on queued and yet undelivered messages
- send ACK upon delivery of queued messages to client
Diffstat (limited to 'src/cadet/gnunet-service-cadet_channel.c')
-rw-r--r-- | src/cadet/gnunet-service-cadet_channel.c | 44 |
1 files changed, 14 insertions, 30 deletions
diff --git a/src/cadet/gnunet-service-cadet_channel.c b/src/cadet/gnunet-service-cadet_channel.c index 5c2204f99..59dff0335 100644 --- a/src/cadet/gnunet-service-cadet_channel.c +++ b/src/cadet/gnunet-service-cadet_channel.c | |||
@@ -616,22 +616,20 @@ send_client_buffered_data (struct CadetChannel *ch, | |||
616 | { | 616 | { |
617 | struct GNUNET_CADET_Data *msg = (struct GNUNET_CADET_Data *) ©[1]; | 617 | struct GNUNET_CADET_Data *msg = (struct GNUNET_CADET_Data *) ©[1]; |
618 | 618 | ||
619 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 619 | LOG (GNUNET_ERROR_TYPE_DEBUG, " have %u! now expecting %u\n", |
620 | " have %u! now expecting %u\n", | ||
621 | copy->mid, rel->mid_recv + 1); | 620 | copy->mid, rel->mid_recv + 1); |
622 | send_client_data (ch, msg, fwd); | 621 | send_client_data (ch, msg, fwd); |
623 | rel->n_recv--; | 622 | rel->n_recv--; |
624 | rel->mid_recv++; | 623 | rel->mid_recv++; |
624 | GCCH_send_data_ack (ch, fwd); | ||
625 | GNUNET_CONTAINER_DLL_remove (rel->head_recv, rel->tail_recv, copy); | 625 | GNUNET_CONTAINER_DLL_remove (rel->head_recv, rel->tail_recv, copy); |
626 | LOG (GNUNET_ERROR_TYPE_DEBUG, " COPYFREE RECV %p\n", copy); | 626 | LOG (GNUNET_ERROR_TYPE_DEBUG, " COPYFREE RECV %p\n", copy); |
627 | GNUNET_free (copy); | 627 | GNUNET_free (copy); |
628 | } | 628 | } |
629 | else | 629 | else |
630 | { | 630 | { |
631 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 631 | LOG (GNUNET_ERROR_TYPE_DEBUG, " reliable && don't have %u, next is %u\n", |
632 | " reliable && don't have %u, next is %u\n", | 632 | rel->mid_recv, copy->mid); |
633 | rel->mid_recv, | ||
634 | copy->mid); | ||
635 | if (GNUNET_YES == ch->destroy) | 633 | if (GNUNET_YES == ch->destroy) |
636 | { | 634 | { |
637 | /* We don't have the next data piece and the remote peer has closed the | 635 | /* We don't have the next data piece and the remote peer has closed the |
@@ -1028,19 +1026,13 @@ channel_rel_free_sent (struct CadetChannelReliability *rel, | |||
1028 | 1026 | ||
1029 | bitfield = msg->futures; | 1027 | bitfield = msg->futures; |
1030 | mid = ntohl (msg->mid); | 1028 | mid = ntohl (msg->mid); |
1031 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1029 | LOG (GNUNET_ERROR_TYPE_DEBUG, "free_sent_reliable %u %llX\n", mid, bitfield); |
1032 | "!!! free_sent_reliable %u %llX\n", | 1030 | LOG (GNUNET_ERROR_TYPE_DEBUG, " rel %p, head %p\n", rel, rel->head_sent); |
1033 | mid, bitfield); | ||
1034 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
1035 | " rel %p, head %p\n", | ||
1036 | rel, rel->head_sent); | ||
1037 | for (i = 0, copy = rel->head_sent; | 1031 | for (i = 0, copy = rel->head_sent; |
1038 | i < 64 && NULL != copy && 0 != bitfield; | 1032 | i < 64 && NULL != copy && 0 != bitfield; |
1039 | i++) | 1033 | i++) |
1040 | { | 1034 | { |
1041 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1035 | LOG (GNUNET_ERROR_TYPE_DEBUG, " trying bit %u (mid %u)\n", i, mid + i + 1); |
1042 | " trying bit %u (mid %u)\n", | ||
1043 | i, mid + i + 1); | ||
1044 | mask = 0x1LL << i; | 1036 | mask = 0x1LL << i; |
1045 | if (0 == (bitfield & mask)) | 1037 | if (0 == (bitfield & mask)) |
1046 | continue; | 1038 | continue; |
@@ -1519,9 +1511,8 @@ GCCH_send_data_ack (struct CadetChannel *ch, int fwd) | |||
1519 | uint32_t ack; | 1511 | uint32_t ack; |
1520 | 1512 | ||
1521 | if (GNUNET_NO == ch->reliable) | 1513 | if (GNUNET_NO == ch->reliable) |
1522 | { | ||
1523 | return; | 1514 | return; |
1524 | } | 1515 | |
1525 | rel = fwd ? ch->dest_rel : ch->root_rel; | 1516 | rel = fwd ? ch->dest_rel : ch->root_rel; |
1526 | ack = rel->mid_recv - 1; | 1517 | ack = rel->mid_recv - 1; |
1527 | LOG (GNUNET_ERROR_TYPE_INFO, "===> DATA_ACK for %u\n", ack); | 1518 | LOG (GNUNET_ERROR_TYPE_INFO, "===> DATA_ACK for %u\n", ack); |
@@ -1529,34 +1520,27 @@ GCCH_send_data_ack (struct CadetChannel *ch, int fwd) | |||
1529 | msg.header.type = htons (GNUNET_MESSAGE_TYPE_CADET_DATA_ACK); | 1520 | msg.header.type = htons (GNUNET_MESSAGE_TYPE_CADET_DATA_ACK); |
1530 | msg.header.size = htons (sizeof (msg)); | 1521 | msg.header.size = htons (sizeof (msg)); |
1531 | msg.chid = htonl (ch->gid); | 1522 | msg.chid = htonl (ch->gid); |
1523 | msg.mid = htonl (ack); | ||
1524 | |||
1532 | msg.futures = 0; | 1525 | msg.futures = 0; |
1533 | for (copy = rel->head_recv; NULL != copy; copy = copy->next) | 1526 | for (copy = rel->head_recv; NULL != copy; copy = copy->next) |
1534 | { | 1527 | { |
1535 | if (copy->type != GNUNET_MESSAGE_TYPE_CADET_DATA) | 1528 | if (copy->type != GNUNET_MESSAGE_TYPE_CADET_DATA) |
1536 | { | 1529 | { |
1537 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1530 | LOG (GNUNET_ERROR_TYPE_DEBUG, " Type %s, expected DATA\n", |
1538 | "!! Type %s, expected DATA\n", | ||
1539 | GC_m2s (copy->type)); | 1531 | GC_m2s (copy->type)); |
1540 | continue; | 1532 | continue; |
1541 | } | 1533 | } |
1542 | if (copy->mid == ack + 1) | ||
1543 | { | ||
1544 | ack++; | ||
1545 | continue; | ||
1546 | } | ||
1547 | delta = copy->mid - (ack + 1); | 1534 | delta = copy->mid - (ack + 1); |
1548 | if (63 < delta) | 1535 | if (63 < delta) |
1549 | break; | 1536 | break; |
1550 | mask = 0x1LL << delta; | 1537 | mask = 0x1LL << delta; |
1551 | msg.futures |= mask; | 1538 | msg.futures |= mask; |
1552 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1539 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1553 | " !! setting bit for %u (delta %u) (%llX) -> %llX\n", | 1540 | " setting bit for %u (delta %u) (%llX) -> %llX\n", |
1554 | copy->mid, delta, mask, msg.futures); | 1541 | copy->mid, delta, mask, msg.futures); |
1555 | } | 1542 | } |
1556 | msg.mid = htonl (ack); | 1543 | LOG (GNUNET_ERROR_TYPE_DEBUG, " final futures: %llX\n", ack, msg.futures); |
1557 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
1558 | "!!! ACK for %u, futures %llX\n", | ||
1559 | ack, msg.futures); | ||
1560 | 1544 | ||
1561 | GCCH_send_prebuilt_message (&msg.header, ch, !fwd, NULL); | 1545 | GCCH_send_prebuilt_message (&msg.header, ch, !fwd, NULL); |
1562 | LOG (GNUNET_ERROR_TYPE_DEBUG, "send_data_ack END\n"); | 1546 | LOG (GNUNET_ERROR_TYPE_DEBUG, "send_data_ack END\n"); |
@@ -1955,7 +1939,7 @@ GCCH_handle_data (struct CadetChannel *ch, | |||
1955 | /* Is this the exact next expected messasge? */ | 1939 | /* Is this the exact next expected messasge? */ |
1956 | if (mid == rel->mid_recv) | 1940 | if (mid == rel->mid_recv) |
1957 | { | 1941 | { |
1958 | LOG (GNUNET_ERROR_TYPE_DEBUG, "as expected\n"); | 1942 | LOG (GNUNET_ERROR_TYPE_DEBUG, "as expected, sending to client\n"); |
1959 | rel->mid_recv++; | 1943 | rel->mid_recv++; |
1960 | send_client_data (ch, msg, fwd); | 1944 | send_client_data (ch, msg, fwd); |
1961 | } | 1945 | } |