diff options
author | Ulrich Drepper <drepper@redhat.com> | 2006-09-08 10:41:17 +0000 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 2006-09-08 10:41:17 +0000 |
commit | 346e6ad4016f3a19f71ccd0edd8a2682746d6fe7 (patch) | |
tree | f96d1336d032a8b0d2438378e4fe621b7a5590f9 /nptl/sysdeps/unix | |
parent | 469615bdd422cec2d89a09c765a8e965faa29722 (diff) | |
download | glibc-346e6ad4016f3a19f71ccd0edd8a2682746d6fe7.tar glibc-346e6ad4016f3a19f71ccd0edd8a2682746d6fe7.tar.gz glibc-346e6ad4016f3a19f71ccd0edd8a2682746d6fe7.tar.bz2 glibc-346e6ad4016f3a19f71ccd0edd8a2682746d6fe7.zip |
[BZ #3123]
2006-09-08 Ulrich Drepper <drepper@redhat.com>
[BZ #3123]
* sysdeps/pthread/pthread_cond_wait.c (__condvar_cleanup): Don't
increment WAKEUP_SEQ if this would increase the value beyond TOTAL_SEQ.
* sysdeps/unix/sysv/linux/i386/i486/pthread_cond_wait.c: Likewise.
* sysdeps/unix/sysv/linux/i386/i486/pthread_cond_timedwait.c: Likewise.
* sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.c: Likewise.
* Makefile (tests): Add tst-cond22.
* tst-cond22.c: New file.
Diffstat (limited to 'nptl/sysdeps/unix')
3 files changed, 36 insertions, 9 deletions
diff --git a/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_cond_timedwait.S b/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_cond_timedwait.S index 699c2cb227..692e0dd670 100644 --- a/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_cond_timedwait.S +++ b/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_cond_timedwait.S @@ -1,4 +1,4 @@ -/* Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc. +/* Copyright (C) 2002, 2003, 2004, 2006 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@redhat.com>, 2002. @@ -406,10 +406,21 @@ __condvar_tw_cleanup: cmpl 20(%esp), %eax jne 3f - addl $1, wakeup_seq(%ebx) + /* We increment the woken_seq counter only if it is lower than + total_seq. If this is not the case the thread was woken and + then canceled. In this case we ignore the signal. */ + movl total_seq(%ebx), %eax + movl total_seq+4(%ebx), %edi + cmpl wakeup_seq+4(%ebx), %edi + jb 6f + ja 7f + cmpl wakeup_seq(%ebx), %eax + jbe 7f + +6: addl $1, wakeup_seq(%ebx) adcl $0, wakeup_seq+4(%ebx) - addl $1, cond_futex(%ebx) +7: addl $1, cond_futex(%ebx) addl $1, woken_seq(%ebx) adcl $0, woken_seq+4(%ebx) diff --git a/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_cond_wait.S b/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_cond_wait.S index d282785151..7f93a85732 100644 --- a/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_cond_wait.S +++ b/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_cond_wait.S @@ -1,4 +1,4 @@ -/* Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc. +/* Copyright (C) 2002, 2003, 2004, 2006 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@redhat.com>, 2002. @@ -297,11 +297,21 @@ __condvar_w_cleanup: cmpl 12(%esp), %eax jne 3f - addl $1, wakeup_seq(%ebx) + /* We increment the woken_seq counter only if it is lower than + total_seq. If this is not the case the thread was woken and + then canceled. In this case we ignore the signal. */ + movl total_seq(%ebx), %eax + movl total_seq+4(%ebx), %edi + cmpl wakeup_seq+4(%ebx), %edi + jb 6f + ja 7f + cmpl wakeup_seq(%ebx), %eax + jbe 7f + +6: addl $1, wakeup_seq(%ebx) adcl $0, wakeup_seq+4(%ebx) - addl $1, cond_futex(%ebx) - +7: addl $1, cond_futex(%ebx) addl $1, woken_seq(%ebx) adcl $0, woken_seq+4(%ebx) diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S index b837d466b1..6b8091b3ee 100644 --- a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S +++ b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S @@ -1,4 +1,4 @@ -/* Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc. +/* Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@redhat.com>, 2002. @@ -67,8 +67,14 @@ __condvar_cleanup: cmpl 4(%r8), %edx jne 3f + /* We increment the woken_seq counter only if it is lower than + total_seq. If this is not the case the thread was woken and + then canceled. In this case we ignore the signal. */ + movq total_seq(%rdi), %rax + cmpq wakeup_seq(%rdi), %rax + jbe 6f incq wakeup_seq(%rdi) - incq woken_seq(%rdi) +6: incq woken_seq(%rdi) incl cond_futex(%rdi) 3: subl $(1 << clock_bits), cond_nwaiters(%rdi) |