]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: work around Linux kernel bug in futex
authorRuss Cox <rsc@golang.org>
Tue, 23 Feb 2010 04:45:36 +0000 (20:45 -0800)
committerRuss Cox <rsc@golang.org>
Tue, 23 Feb 2010 04:45:36 +0000 (20:45 -0800)
Fixes #420.

R=r
CC=golang-dev
https://golang.org/cl/218065

src/pkg/runtime/linux/thread.c

index efb138021f1af7a422aca74fcc23417985d17420..d6811eb378d0878a6c6f2c9e97913d597264b425 100644 (file)
@@ -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.