Remove tcpcb.tt_msg == NULL tests in tcp_callout_*().
authorSepherosa Ziehau <sephe@dragonflybsd.org>
Tue, 16 Dec 2008 13:40:42 +0000 (21:40 +0800)
committerSepherosa Ziehau <sephe@dragonflybsd.org>
Tue, 16 Dec 2008 14:33:02 +0000 (22:33 +0800)
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@
sys/netinet/tcp_subr.c
sys/netinet/tcp_timer2.h

index f8802e5..2d5a554 100644 (file)
@@ -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);
index ad2ce4c..da2b241 100644 (file)
@@ -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;
        }