diff options
author | John Baldwin <jhb@FreeBSD.org> | 2006-08-01 16:27:14 +0000 |
---|---|---|
committer | John Baldwin <jhb@FreeBSD.org> | 2006-08-01 16:27:14 +0000 |
commit | 6cba7f3609eb90e3240054473bb00f85e6756860 (patch) | |
tree | 37dd7fcc8f2e00c87c785f35c3c31843f7eb1b29 /sys/nfsserver/nfs_srvcache.c | |
parent | be698f1e7fc1966386de70e43ae21bf7870632d2 (diff) | |
download | src-6cba7f3609eb90e3240054473bb00f85e6756860.tar.gz src-6cba7f3609eb90e3240054473bb00f85e6756860.zip |
- Add a new function nfsrv_destroycache() to tear down the server request
cache when unloading the nfsserver module. This fixes a memory leak and
a stale pointer.
- Use callout_drain() rather than callout_stop() when unloading the
nfsserver module.
MFC after: 3 days
Notes
Notes:
svn path=/head/; revision=160881
Diffstat (limited to 'sys/nfsserver/nfs_srvcache.c')
-rw-r--r-- | sys/nfsserver/nfs_srvcache.c | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/sys/nfsserver/nfs_srvcache.c b/sys/nfsserver/nfs_srvcache.c index 272534f9c09d..7d0c12639393 100644 --- a/sys/nfsserver/nfs_srvcache.c +++ b/sys/nfsserver/nfs_srvcache.c @@ -65,6 +65,7 @@ static long desirednfsrvcache; static LIST_HEAD(nfsrvhash, nfsrvcache) *nfsrvhashtbl; static TAILQ_HEAD(nfsrvlru, nfsrvcache) nfsrvlruhead; static u_long nfsrvhash; +static eventhandler_tag nfsrv_nmbclusters_tag; #define TRUE 1 #define FALSE 0 @@ -147,8 +148,19 @@ nfsrv_initcache(void) nfsrvcache_size_change(NULL); nfsrvhashtbl = hashinit(desirednfsrvcache, M_NFSD, &nfsrvhash); TAILQ_INIT(&nfsrvlruhead); - EVENTHANDLER_REGISTER(nmbclusters_change, nfsrvcache_size_change, NULL, - EVENTHANDLER_PRI_FIRST); + nfsrv_nmbclusters_tag = EVENTHANDLER_REGISTER(nmbclusters_change, + nfsrvcache_size_change, NULL, EVENTHANDLER_PRI_FIRST); +} + +/* + * Teardown the server request cache list + */ +void +nfsrv_destroycache(void) +{ + KASSERT(TAILQ_EMPTY(&nfsrvlruhead), ("%s: pending requests", __func__)); + EVENTHANDLER_DEREGISTER(nmbclusters_change, nfsrv_nmbclusters_tag); + hashdestroy(nfsrvhashtbl, M_NFSD, nfsrvhash); } /* |