/*
- * Copyright (c) 2000-2013 Apple Inc. All rights reserved.
+ * Copyright (c) 2000-2014 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
recwin = tcp_sbspace(tp);
+
/*
* If the socket is capable of doing unordered send,
* pull the amount of data that can be sent from the
* If our state indicates that FIN should be sent
* and we have not yet done so, then we need to send.
*/
- if (flags & TH_FIN &&
- ((tp->t_flags & TF_SENTFIN) == 0 || tp->snd_nxt == tp->snd_una))
+ if ((flags & TH_FIN) &&
+ (!(tp->t_flags & TF_SENTFIN) || tp->snd_nxt == tp->snd_una))
goto send;
/*
* In SACK, it is possible for tcp_output to fail to send a segment
if (flags & (TH_SYN|TH_FIN)) {
if (flags & TH_SYN)
tp->snd_nxt++;
- if (flags & TH_FIN) {
+ if ((flags & TH_FIN) &&
+ !(tp->t_flags & TF_SENTFIN)) {
tp->snd_nxt++;
tp->t_flags |= TF_SENTFIN;
}
timer:
if (tp->t_timer[TCPT_REXMT] == 0 &&
((sack_rxmit && tp->snd_nxt != tp->snd_max) ||
- tp->snd_nxt != tp->snd_una)) {
+ tp->snd_nxt != tp->snd_una ||
+ (flags & TH_FIN))) {
if (tp->t_timer[TCPT_PERSIST]) {
tp->t_timer[TCPT_PERSIST] = 0;
tp->t_rxtshift = 0;
int xlen = len;
if (flags & TH_SYN)
++xlen;
- if (flags & TH_FIN) {
+ if ((flags & TH_FIN) &&
+ !(tp->t_flags & TF_SENTFIN)) {
++xlen;
tp->t_flags |= TF_SENTFIN;
}