diff options
author | David Gwynne <dlg@cvs.openbsd.org> | 2011-09-23 10:08:32 +0000 |
---|---|---|
committer | David Gwynne <dlg@cvs.openbsd.org> | 2011-09-23 10:08:32 +0000 |
commit | 3b29fa588b4d23b80ef3d136be91e39b464419e3 (patch) | |
tree | f0df30213dcc47dc195d9f35caae8fa6f33b15bb /sys/kern/subr_pool.c | |
parent | 2aa00f0963c3c8e39b48381395c207ced255e745 (diff) |
touching pr_nput and pr_nget outside the lock might be racy since ++ and --
arent necessarily atomic.
this is an update of a diff matthew@ posted to tech@ over a year ago.
Diffstat (limited to 'sys/kern/subr_pool.c')
-rw-r--r-- | sys/kern/subr_pool.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/sys/kern/subr_pool.c b/sys/kern/subr_pool.c index b47065de5c0..4c667f5ef4f 100644 --- a/sys/kern/subr_pool.c +++ b/sys/kern/subr_pool.c @@ -1,4 +1,4 @@ -/* $OpenBSD: subr_pool.c,v 1.109 2011/09/23 07:27:09 dlg Exp $ */ +/* $OpenBSD: subr_pool.c,v 1.110 2011/09/23 10:08:31 dlg Exp $ */ /* $NetBSD: subr_pool.c,v 1.61 2001/09/26 07:14:56 chs Exp $ */ /*- @@ -481,6 +481,8 @@ pool_get(struct pool *pp, int flags) panic("after pool_get"); } #endif + if (v != NULL) + pp->pr_nget++; mtx_leave(&pp->pr_mtx); if (v == NULL) return (v); @@ -490,6 +492,7 @@ pool_get(struct pool *pp, int flags) panic("pool_get: PR_ZERO when ctor set"); if (pp->pr_ctor(pp->pr_arg, v, flags)) { mtx_enter(&pp->pr_mtx); + pp->pr_nget--; pool_do_put(pp, v); mtx_leave(&pp->pr_mtx); v = NULL; @@ -498,8 +501,6 @@ pool_get(struct pool *pp, int flags) if (flags & PR_ZERO) memset(v, 0, pp->pr_size); } - if (v != NULL) - pp->pr_nget++; return (v); } @@ -717,8 +718,8 @@ pool_put(struct pool *pp, void *v) panic("after pool_put"); } #endif - mtx_leave(&pp->pr_mtx); pp->pr_nput++; + mtx_leave(&pp->pr_mtx); } /* |