diff options
author | Russ Cox <rsc@golang.org> | 2010-02-22 20:45:36 -0800 |
---|---|---|
committer | Russ Cox <rsc@golang.org> | 2010-02-22 20:45:36 -0800 |
commit | 5ebae25d67e5af7a8494fc34c31695dc0747611f (patch) | |
tree | 7bb450ec9180fb9a75c6ebe85ce1d44057bbfc26 /src/pkg/runtime/linux/thread.c | |
parent | 5c43720ecff4c992218cd95d6e4b4beaf6bf5e9d (diff) | |
download | golang-5ebae25d67e5af7a8494fc34c31695dc0747611f.tar.gz |
runtime: work around Linux kernel bug in futex
Fixes issue 420.
R=r
CC=golang-dev
http://codereview.appspot.com/218065
Diffstat (limited to 'src/pkg/runtime/linux/thread.c')
-rw-r--r-- | src/pkg/runtime/linux/thread.c | 20 |
1 files changed, 6 insertions, 14 deletions
diff --git a/src/pkg/runtime/linux/thread.c b/src/pkg/runtime/linux/thread.c index efb138021..d6811eb37 100644 --- a/src/pkg/runtime/linux/thread.c +++ b/src/pkg/runtime/linux/thread.c @@ -42,20 +42,12 @@ static Timespec longtime = static void futexsleep(uint32 *addr, uint32 val) { - int32 ret; - - ret = futex(addr, FUTEX_WAIT, val, &longtime, nil, 0); - if(ret >= 0 || ret == -EAGAIN || ret == -EINTR) - return; - - prints("futexsleep addr="); - ·printpointer(addr); - prints(" val="); - ·printint(val); - prints(" returned "); - ·printint(ret); - prints("\n"); - *(int32*)0x1005 = 0x1005; + // Some Linux kernels have a bug where futex of + // FUTEX_WAIT returns an internal error code + // as an errno. Libpthread ignores the return value + // here, and so can we: as it says a few lines up, + // spurious wakeups are allowed. + futex(addr, FUTEX_WAIT, val, &longtime, nil, 0); } // If any procs are sleeping on addr, wake up at least one. |