|
Lines 543-571
Link Here
|
| 543 |
} |
543 |
} |
| 544 |
|
544 |
|
| 545 |
/* |
545 |
/* |
| 546 |
* Compare available window to amount of window |
546 |
* Sending of standalone window updates. |
| 547 |
* known to peer (as advertised window less |
547 |
* |
| 548 |
* next expected input). If the difference is at least two |
548 |
* Window updates important when we close our window |
| 549 |
* max size segments, or at least 50% of the maximum possible |
549 |
* due to a full socket buffer and are opening it again |
| 550 |
* window, then want to send a window update to peer. |
550 |
* after the application reads data from it. Once the |
| 551 |
* Skip this if the connection is in T/TCP half-open state. |
551 |
* window has opened again and the remote end starts to |
| 552 |
* Don't send pure window updates when the peer has closed |
552 |
* send again the ACK clock takes over and provides the |
| 553 |
* the connection and won't ever send more data. |
553 |
* most current window information. |
|
|
554 |
* |
| 555 |
* We must avoid to the silly window syndrome whereas |
| 556 |
* every read from the receive buffer, no matter how |
| 557 |
* small, causes a window update to be sent. We also |
| 558 |
* should avoid sending a flurry of window updates when |
| 559 |
* the socket buffer had queued a lot of data and the |
| 560 |
* application is doing small reads. |
| 561 |
* |
| 562 |
* Don't send an independent window update if a delayed |
| 563 |
* ACK is pending (it will get piggy-backed on it) or the |
| 564 |
* remote side already has done a half-close and won't send |
| 565 |
* more data. Skip this if the connection is in T/TCP |
| 566 |
* half-open state. |
| 554 |
*/ |
567 |
*/ |
| 555 |
if (recwin > 0 && !(tp->t_flags & TF_NEEDSYN) && |
568 |
if (recwin > 0 && !(tp->t_flags & TF_NEEDSYN) && |
|
|
569 |
!(tp->t_flags & TF_DELACK) && |
| 556 |
!TCPS_HAVERCVDFIN(tp->t_state)) { |
570 |
!TCPS_HAVERCVDFIN(tp->t_state)) { |
| 557 |
/* |
571 |
/* |
| 558 |
* "adv" is the amount we can increase the window, |
572 |
* "adv" is the amount we can increase the window, |
| 559 |
* taking into account that we are limited by |
573 |
* taking into account that we are limited by |
| 560 |
* TCP_MAXWIN << tp->rcv_scale. |
574 |
* TCP_MAXWIN << tp->rcv_scale. |
| 561 |
*/ |
575 |
*/ |
| 562 |
long adv = min(recwin, (long)TCP_MAXWIN << tp->rcv_scale) - |
576 |
u_int adv = min(recwin, ((u_int)TCP_MAXWIN << tp->rcv_scale) - |
| 563 |
(tp->rcv_adv - tp->rcv_nxt); |
577 |
(tp->rcv_adv - tp->rcv_nxt)); |
| 564 |
|
578 |
|
| 565 |
if (adv >= (long) (2 * tp->t_maxseg)) |
579 |
/* |
|
|
580 |
* Send an update when we can increase by more than |
| 581 |
* 1/4th of the socket buffer capacity. |
| 582 |
* When the buffer is getting full or is very small |
| 583 |
* be more aggressive and send an update whenever |
| 584 |
* we can increase by two mss sized segments. |
| 585 |
* In all other situations the ACK's to new incoming |
| 586 |
* data will carry further increases. |
| 587 |
*/ |
| 588 |
if (adv >= 2 * tp->t_maxseg && |
| 589 |
(adv >= so->so_rcv.sb_hiwat / 4 || |
| 590 |
recwin <= so->so_rcv.sb_hiwat / 8 || |
| 591 |
so->so_rcv.sb_hiwat <= 8 * tp->t_maxopd)) |
| 566 |
goto send; |
592 |
goto send; |
| 567 |
if (2 * adv >= (long) so->so_rcv.sb_hiwat) |
|
|
| 568 |
goto send; |
| 569 |
} |
593 |
} |
| 570 |
|
594 |
|
| 571 |
/* |
595 |
/* |