tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: KASSERT() in kern_timeout.c



On Mon, Apr 19, 2010 at 04:22:29PM +0100, Mindaugas Rasiukevicius wrote:
> Manuel Bouyer <bouyer%antioche.eu.org@localhost> wrote:
> > On Mon, Apr 19, 2010 at 04:10:15PM +0100, Mindaugas Rasiukevicius wrote:
> > > To answer your previous question - yes, that is what I meant, plus other
> > > amendments you have already made.  Note: it might also be useful to
> > > manually trigger callout in syn_cache_put() to speed-up the destruction.
> > 
> > How would you do that ? callout_reset(&(sc)->sc_timer, 1, ...) ?
> > 
> 
> Right, except callout_schedule() should be enough.  Also, you have removed
> callout_stop() from syn_cache_rm().  In such case it is unsafe, you need
> to keep it.

OK, so I modified the patch as attached. This seems to work well with
my test setup.

-- 
Manuel Bouyer <bouyer%antioche.eu.org@localhost>
     NetBSD: 26 ans d'experience feront toujours la difference
--
Index: tcp_input.c
===================================================================
RCS file: /cvsroot/src/sys/netinet/tcp_input.c,v
retrieving revision 1.291.4.2
diff -u -p -u -r1.291.4.2 tcp_input.c
--- tcp_input.c 26 Sep 2009 18:34:29 -0000      1.291.4.2
+++ tcp_input.c 19 Apr 2010 15:44:51 -0000
@@ -3343,12 +3343,9 @@ syn_cache_put(struct syn_cache *sc)
        if (sc->sc_ipopts)
                (void) m_free(sc->sc_ipopts);
        rtcache_free(&sc->sc_route);
-       if (callout_invoking(&sc->sc_timer))
-               sc->sc_flags |= SCF_DEAD;
-       else {
-               callout_destroy(&sc->sc_timer);
-               pool_put(&syn_cache_pool, sc);
-       }
+       sc->sc_flags |= SCF_DEAD;
+       if (!callout_invoking(&sc->sc_timer))
+               callout_schedule(&(sc)->sc_timer, 1);
 }
 
 void
@@ -3509,7 +3506,11 @@ syn_cache_timer(void *arg)
  dropit:
        TCP_STATINC(TCP_STAT_SC_TIMED_OUT);
        syn_cache_rm(sc);
-       syn_cache_put(sc);      /* calls pool_put but see spl above */
+       if (sc->sc_ipopts)
+               (void) m_free(sc->sc_ipopts);
+       rtcache_free(&sc->sc_route);
+       callout_destroy(&sc->sc_timer);
+       pool_put(&syn_cache_pool, sc);
        KERNEL_UNLOCK_ONE(NULL);
        mutex_exit(softnet_lock);
 }


Home | Main Index | Thread Index | Old Index