diff options
| author | 2012-06-19 08:43:32 +0000 | |
|---|---|---|
| committer | 2012-06-19 08:43:32 +0000 | |
| commit | e08120d623c13638d9db3385d5fd3e95172a90b9 (patch) | |
| tree | 6f80ec7e72b2401de70fa9bbe8c542c96a017484 /sys/compat/linux/linux_futex.c | |
| parent | There are five main sections, not four, since routing domain support was added. (diff) | |
| download | wireguard-openbsd-e08120d623c13638d9db3385d5fd3e95172a90b9.tar.xz wireguard-openbsd-e08120d623c13638d9db3385d5fd3e95172a90b9.zip | |
Change the pool_get() flags from WAITOK to NOWAIT.
This avoids a potential lost-wakeup as pointed out by guenther@.
Now the futex is locked all through the process and EAGAIN is returned
on failure.
Makes sense to guenther@.
Diffstat (limited to 'sys/compat/linux/linux_futex.c')
| -rw-r--r-- | sys/compat/linux/linux_futex.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/sys/compat/linux/linux_futex.c b/sys/compat/linux/linux_futex.c index 20a9b224d5f..b16d4c801aa 100644 --- a/sys/compat/linux/linux_futex.c +++ b/sys/compat/linux/linux_futex.c @@ -1,4 +1,4 @@ -/* $OpenBSD: linux_futex.c,v 1.2 2012/06/16 11:47:24 pirofti Exp $ */ +/* $OpenBSD: linux_futex.c,v 1.3 2012/06/19 08:43:32 pirofti Exp $ */ /* $NetBSD: linux_futex.c,v 1.26 2010/07/07 01:30:35 chs Exp $ */ /*- @@ -203,9 +203,13 @@ linux_do_futex(struct proc *p, const struct linux_sys_futex_args *uap, if (SCARG(uap, timeout) != NULL && timeout_hz == 0) timeout_hz = 1; - mtx_leave(&futex_lock); - wp = pool_get(&futex_wp_pool, PR_WAITOK); - mtx_enter(&futex_lock); + wp = pool_get(&futex_wp_pool, PR_NOWAIT); + if (wp == NULL) { + DPRINTF(("FUTEX_WAIT %d: Couldn't fetch a new wp from" + "futex_wp_pool.\n", tid)); + mtx_leave(&futex_lock); + return EAGAIN; + } f = futex_get(SCARG(uap, uaddr)); ret = futex_sleep(&f, p, timeout_hz, wp); |
