]> git.saurik.com Git - apple/xnu.git/blobdiff - bsd/netinet/tcp_timer.c
xnu-1228.5.20.tar.gz
[apple/xnu.git] / bsd / netinet / tcp_timer.c
index 739e2816bcb1473715ed093075847c90d53d851a..e8de99b71f73b2e6167fd787d3793c638234f177 100644 (file)
@@ -358,7 +358,7 @@ static int bg_cnt = 0;
 void
 tcp_slowtimo()
 {
-       struct inpcb *inp;
+       struct inpcb *inp, *nxt;
        struct tcpcb *tp;
        struct socket *so;
        int i;
@@ -537,12 +537,12 @@ twunlock:
        }
 
 
-       LIST_FOREACH(inp, &tcb, inp_list) {
+       LIST_FOREACH_SAFE(inp, &tcb, inp_list, nxt) {
                tcp_garbage_collect(inp, 0);
        }
 
        /* Now cleanup the time wait ones */
-       LIST_FOREACH(inp, &time_wait_slots[cur_tw_slot], inp_list) {
+       LIST_FOREACH_SAFE(inp, &time_wait_slots[cur_tw_slot], inp_list, nxt) {
                tcp_garbage_collect(inp, 1);
        }
 
@@ -729,15 +729,15 @@ tcp_timers(tp, timer)
                 * growth is 2 mss.  We don't allow the threshhold
                 * to go below this.)
                 */
-               {
-               u_int win = min(tp->snd_wnd, tp->snd_cwnd) / 2 / tp->t_maxseg;
-               if (win < 2)
-                       win = 2;
-               tp->snd_cwnd = tp->t_maxseg;
-               tp->snd_ssthresh = win * tp->t_maxseg;
-               tp->t_bytes_acked = 0;
-               tp->t_dupacks = 0;
-               tp->t_unacksegs = 0;
+               if (tp->t_state >=  TCPS_ESTABLISHED) {
+                       u_int win = min(tp->snd_wnd, tp->snd_cwnd) / 2 / tp->t_maxseg;
+                       if (win < 2)
+                               win = 2;
+                       tp->snd_cwnd = tp->t_maxseg;
+                       tp->snd_ssthresh = win * tp->t_maxseg;
+                       tp->t_bytes_acked = 0;
+                       tp->t_dupacks = 0;
+                       tp->t_unacksegs = 0;
                }
                EXIT_FASTRECOVERY(tp);
                (void) tcp_output(tp);