From: Sepherosa Ziehau Date: Tue, 16 Dec 2008 13:40:42 +0000 (+0800) Subject: Remove tcpcb.tt_msg == NULL tests in tcp_callout_*(). X-Git-Tag: v2.3.0~239^2~1 X-Git-Url: https://gitweb.dragonflybsd.org/dragonfly.git/commitdiff_plain/2d42d2b0d6f02c8e85ed9abda2f1b19f4eab6e36 Remove tcpcb.tt_msg == NULL tests in tcp_callout_*(). tcpcb.tt_msg == NULL could only happen for TCP listen sockets, while for this kind of sockets, tcp timers should never be used. Suggested-by: dillon@ --- diff --git a/sys/netinet/tcp_subr.c b/sys/netinet/tcp_subr.c index f8802e569d..2d5a554bb2 100644 --- a/sys/netinet/tcp_subr.c +++ b/sys/netinet/tcp_subr.c @@ -861,13 +861,16 @@ tcp_close(struct tcpcb *tp) /* * Make sure that all of our timers are stopped before we - * delete the PCB. + * delete the PCB. For listen TCP socket (tp->tt_msg == NULL), + * timers are never used. */ - tcp_callout_stop(tp, tp->tt_rexmt); - tcp_callout_stop(tp, tp->tt_persist); - tcp_callout_stop(tp, tp->tt_keep); - tcp_callout_stop(tp, tp->tt_2msl); - tcp_callout_stop(tp, tp->tt_delack); + if (tp->tt_msg != NULL) { + tcp_callout_stop(tp, tp->tt_rexmt); + tcp_callout_stop(tp, tp->tt_persist); + tcp_callout_stop(tp, tp->tt_keep); + tcp_callout_stop(tp, tp->tt_2msl); + tcp_callout_stop(tp, tp->tt_delack); + } if (tp->t_flags & TF_ONOUTPUTQ) { KKASSERT(tp->tt_cpu == mycpu->gd_cpuid); diff --git a/sys/netinet/tcp_timer2.h b/sys/netinet/tcp_timer2.h index ad2ce4c933..da2b241249 100644 --- a/sys/netinet/tcp_timer2.h +++ b/sys/netinet/tcp_timer2.h @@ -61,10 +61,8 @@ tcp_callout_stop(struct tcpcb *_tp, struct tcp_callout *_tc) { crit_enter(); callout_stop(&_tc->tc_callout); - if (_tp->tt_msg != NULL) { - _tp->tt_msg->tt_tasks &= ~_tc->tc_task; - _tp->tt_msg->tt_running_tasks &= ~_tc->tc_task; - } + _tp->tt_msg->tt_tasks &= ~_tc->tc_task; + _tp->tt_msg->tt_running_tasks &= ~_tc->tc_task; crit_exit(); } @@ -74,10 +72,8 @@ tcp_callout_reset(struct tcpcb *_tp, struct tcp_callout *_tc, int _to_ticks, { crit_enter(); callout_reset(&_tc->tc_callout, _to_ticks, _func, _tp); - if (_tp->tt_msg != NULL) { - _tp->tt_msg->tt_tasks &= ~_tc->tc_task; - _tp->tt_msg->tt_running_tasks &= ~_tc->tc_task; - } + _tp->tt_msg->tt_tasks &= ~_tc->tc_task; + _tp->tt_msg->tt_running_tasks &= ~_tc->tc_task; crit_exit(); } @@ -88,7 +84,7 @@ tcp_callout_active(struct tcpcb *_tp, struct tcp_callout *_tc) crit_enter(); _act = callout_active(&_tc->tc_callout); - if (!_act && _tp->tt_msg != NULL) { + if (!_act) { _act = (_tp->tt_msg->tt_tasks | _tp->tt_msg->tt_running_tasks) & _tc->tc_task; }