libstdc++: Fix return values for atomic wait on futex
authorJonathan Wakely <jwakely@redhat.com>
Tue, 28 Sep 2021 19:41:46 +0000 (20:41 +0100)
committerJonathan Wakely <jwakely@redhat.com>
Tue, 28 Sep 2021 20:27:04 +0000 (21:27 +0100)
This fixes a logic error in the futex-based timed wait.

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
libstdc++-v3/ChangeLog:

* include/bits/atomic_timed_wait.h (__platform_wait_until_impl):
Return false for ETIMEDOUT and true otherwise.

libstdc++-v3/include/bits/atomic_timed_wait.h

index 3db08f8..d423a7a 100644 (file)
@@ -101,12 +101,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
        if (__e)
          {
-           if ((errno != ETIMEDOUT) && (errno != EINTR)
-               && (errno != EAGAIN))
+           if (errno == ETIMEDOUT)
+             return false;
+           if (errno != EINTR && errno != EAGAIN)
              __throw_system_error(errno);
-           return true;
          }
-       return false;
+       return true;
       }
 
     // returns true if wait ended before timeout