1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-23 11:18:54 +00:00

tcp_twstart() need to be called with the TCP protocol lock held to avoid

a race condition with the TCP timer routines.
This commit is contained in:
Jeffrey Hsu 2003-02-24 00:52:03 +00:00
parent 93943fff46
commit 11a20fb8b6
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=111389
2 changed files with 16 additions and 12 deletions

View File

@ -1963,9 +1963,9 @@ tcp_input(m, off0)
case TCPS_CLOSING: case TCPS_CLOSING:
if (ourfinisacked) { if (ourfinisacked) {
KASSERT(headlocked, ("headlocked")); KASSERT(headlocked, ("headlocked"));
tcp_twstart(tp);
INP_INFO_WUNLOCK(&tcbinfo); INP_INFO_WUNLOCK(&tcbinfo);
m_freem(m); m_freem(m);
tcp_twstart(tp);
return; return;
} }
break; break;
@ -2078,8 +2078,10 @@ tcp_input(m, off0)
} }
dodata: /* XXX */ dodata: /* XXX */
KASSERT(headlocked, ("headlocked")); KASSERT(headlocked, ("headlocked"));
INP_INFO_WUNLOCK(&tcbinfo); if (!(thflags & TH_FIN && tp->t_state == TCPS_FIN_WAIT_2)) {
headlocked = 0; INP_INFO_WUNLOCK(&tcbinfo);
headlocked = 0;
}
/* /*
* Process the segment text, merging it into the TCP sequencing queue, * Process the segment text, merging it into the TCP sequencing queue,
* and arranging for acknowledgment of receipt if necessary. * and arranging for acknowledgment of receipt if necessary.
@ -2183,8 +2185,9 @@ tcp_input(m, off0)
* standard timers. * standard timers.
*/ */
case TCPS_FIN_WAIT_2: case TCPS_FIN_WAIT_2:
KASSERT(headlocked == 0, ("headlocked")); KASSERT(headlocked == 1, ("headlocked should be 1"));
tcp_twstart(tp); tcp_twstart(tp);
INP_INFO_WUNLOCK(&tcbinfo);
return; return;
/* /*
@ -2211,11 +2214,10 @@ tcp_input(m, off0)
check_delack: check_delack:
if (tp->t_flags & TF_DELACK) { if (tp->t_flags & TF_DELACK) {
tp->t_flags &= ~TF_DELACK; tp->t_flags &= ~TF_DELACK;
KASSERT(!callout_active(tp->tt_delack),
("delayed ack already active"));
callout_reset(tp->tt_delack, tcp_delacktime, callout_reset(tp->tt_delack, tcp_delacktime,
tcp_timer_delack, tp); tcp_timer_delack, tp);
} }
KASSERT(headlocked == 0, ("headlocked should be 0"));
INP_UNLOCK(inp); INP_UNLOCK(inp);
return; return;

View File

@ -1963,9 +1963,9 @@ tcp_input(m, off0)
case TCPS_CLOSING: case TCPS_CLOSING:
if (ourfinisacked) { if (ourfinisacked) {
KASSERT(headlocked, ("headlocked")); KASSERT(headlocked, ("headlocked"));
tcp_twstart(tp);
INP_INFO_WUNLOCK(&tcbinfo); INP_INFO_WUNLOCK(&tcbinfo);
m_freem(m); m_freem(m);
tcp_twstart(tp);
return; return;
} }
break; break;
@ -2078,8 +2078,10 @@ tcp_input(m, off0)
} }
dodata: /* XXX */ dodata: /* XXX */
KASSERT(headlocked, ("headlocked")); KASSERT(headlocked, ("headlocked"));
INP_INFO_WUNLOCK(&tcbinfo); if (!(thflags & TH_FIN && tp->t_state == TCPS_FIN_WAIT_2)) {
headlocked = 0; INP_INFO_WUNLOCK(&tcbinfo);
headlocked = 0;
}
/* /*
* Process the segment text, merging it into the TCP sequencing queue, * Process the segment text, merging it into the TCP sequencing queue,
* and arranging for acknowledgment of receipt if necessary. * and arranging for acknowledgment of receipt if necessary.
@ -2183,8 +2185,9 @@ tcp_input(m, off0)
* standard timers. * standard timers.
*/ */
case TCPS_FIN_WAIT_2: case TCPS_FIN_WAIT_2:
KASSERT(headlocked == 0, ("headlocked")); KASSERT(headlocked == 1, ("headlocked should be 1"));
tcp_twstart(tp); tcp_twstart(tp);
INP_INFO_WUNLOCK(&tcbinfo);
return; return;
/* /*
@ -2211,11 +2214,10 @@ tcp_input(m, off0)
check_delack: check_delack:
if (tp->t_flags & TF_DELACK) { if (tp->t_flags & TF_DELACK) {
tp->t_flags &= ~TF_DELACK; tp->t_flags &= ~TF_DELACK;
KASSERT(!callout_active(tp->tt_delack),
("delayed ack already active"));
callout_reset(tp->tt_delack, tcp_delacktime, callout_reset(tp->tt_delack, tcp_delacktime,
tcp_timer_delack, tp); tcp_timer_delack, tp);
} }
KASSERT(headlocked == 0, ("headlocked should be 0"));
INP_UNLOCK(inp); INP_UNLOCK(inp);
return; return;