mirror of
https://sourceware.org/git/glibc.git
synced 2024-11-09 23:00:07 +00:00
Update.
2003-12-19 Ulrich Drepper <drepper@redhat.com> * eintr.c (setup_eintr): Add new parameter. Pass to thread function. (eintr_source): If ARG != NULL, use pthread_kill. * tst-eintr1.c: Adjust for this change. * tst-eintr2.c: Likewise. * Makefile (tests): Add tst-eintr3 and tst-eintr4. * tst-eintr3.c: New file. * tst-eintr4.c: New file. 2003-12-19 Jakub Jelinek <jakub@redhat.com> * libc-cancellation.c (__libc_enable_asynccancel): Don't cancel if CANCELSTATE_BITMASK is set. * sysdeps/pthread/librt-cancellation.c (__librt_enable_asynccancel): Likewise. * Makefile (tests): Add tst-cancel22 and tst-cancel23. (tests-reverse): Add tst-cancel23. * tst-cancel22.c: New test. * tst-cancel23.c: New test.
This commit is contained in:
parent
8a7455e70d
commit
4efdd8d355
@ -1,3 +1,25 @@
|
||||
2003-12-19 Ulrich Drepper <drepper@redhat.com>
|
||||
|
||||
* eintr.c (setup_eintr): Add new parameter. Pass to thread function.
|
||||
(eintr_source): If ARG != NULL, use pthread_kill.
|
||||
* tst-eintr1.c: Adjust for this change.
|
||||
* tst-eintr2.c: Likewise.
|
||||
* Makefile (tests): Add tst-eintr3 and tst-eintr4.
|
||||
* tst-eintr3.c: New file.
|
||||
* tst-eintr4.c: New file.
|
||||
|
||||
2003-12-19 Jakub Jelinek <jakub@redhat.com>
|
||||
|
||||
* libc-cancellation.c (__libc_enable_asynccancel): Don't cancel
|
||||
if CANCELSTATE_BITMASK is set.
|
||||
* sysdeps/pthread/librt-cancellation.c (__librt_enable_asynccancel):
|
||||
Likewise.
|
||||
|
||||
* Makefile (tests): Add tst-cancel22 and tst-cancel23.
|
||||
(tests-reverse): Add tst-cancel23.
|
||||
* tst-cancel22.c: New test.
|
||||
* tst-cancel23.c: New test.
|
||||
|
||||
2003-12-18 Ulrich Drepper <drepper@redhat.com>
|
||||
|
||||
* tst-eintr1.c: Better error messages.
|
||||
|
@ -207,7 +207,7 @@ tests = tst-attr1 tst-attr2 tst-attr3 \
|
||||
tst-kill1 tst-kill2 tst-kill3 tst-kill4 tst-kill5 tst-kill6 \
|
||||
tst-join1 tst-join2 tst-join3 tst-join4 tst-join5 \
|
||||
tst-detach1 \
|
||||
tst-eintr1 tst-eintr2 \
|
||||
tst-eintr1 tst-eintr2 tst-eintr3 tst-eintr4 \
|
||||
tst-tsd1 tst-tsd2 tst-tsd3 tst-tsd4 \
|
||||
tst-tls1 tst-tls2 \
|
||||
tst-fork1 tst-fork2 tst-fork3 tst-fork4 \
|
||||
@ -216,7 +216,7 @@ tests = tst-attr1 tst-attr2 tst-attr3 \
|
||||
tst-cancel6 tst-cancel7 tst-cancel8 tst-cancel9 tst-cancel10 \
|
||||
tst-cancel11 tst-cancel12 tst-cancel13 tst-cancel14 tst-cancel15 \
|
||||
tst-cancel16 tst-cancel17 tst-cancel18 tst-cancel19 tst-cancel20 \
|
||||
tst-cancel21 \
|
||||
tst-cancel21 tst-cancel22 tst-cancel23 \
|
||||
tst-cleanup0 tst-cleanup1 tst-cleanup2 tst-cleanup3 tst-cleanup4 \
|
||||
tst-flock1 tst-flock2 \
|
||||
tst-signal1 tst-signal2 tst-signal3 tst-signal4 tst-signal5 \
|
||||
@ -326,7 +326,7 @@ ifeq ($(build-static),yes)
|
||||
tests-static += tst-locale1 tst-locale2
|
||||
endif
|
||||
# These tests are linked with libc before libpthread
|
||||
tests-reverse += tst-cancel5
|
||||
tests-reverse += tst-cancel5 tst-cancel23
|
||||
|
||||
include ../Rules
|
||||
|
||||
|
@ -44,7 +44,10 @@ eintr_source (void *arg)
|
||||
|
||||
while (1)
|
||||
{
|
||||
kill (getpid (), the_sig);
|
||||
if (arg != NULL)
|
||||
pthread_kill (*(pthread_t *) arg, the_sig);
|
||||
else
|
||||
kill (getpid (), the_sig);
|
||||
|
||||
nanosleep (&ts, NULL);
|
||||
}
|
||||
@ -55,7 +58,7 @@ eintr_source (void *arg)
|
||||
|
||||
|
||||
static void
|
||||
setup_eintr (int sig)
|
||||
setup_eintr (int sig, pthread_t *thp)
|
||||
{
|
||||
struct sigaction sa;
|
||||
sigemptyset (&sa.sa_mask);
|
||||
@ -70,7 +73,7 @@ setup_eintr (int sig)
|
||||
|
||||
/* Create the thread which will fire off the signals. */
|
||||
pthread_t th;
|
||||
if (pthread_create (&th, NULL, eintr_source, NULL) != 0)
|
||||
if (pthread_create (&th, NULL, eintr_source, thp) != 0)
|
||||
{
|
||||
puts ("setup_eintr: pthread_create failed");
|
||||
exit (1);
|
||||
|
@ -42,8 +42,9 @@ __libc_enable_asynccancel (void)
|
||||
|
||||
if (__builtin_expect ((oldval & CANCELED_BITMASK) != 0, 0))
|
||||
{
|
||||
/* If we are already exiting stop right here. */
|
||||
if ((oldval & EXITING_BITMASK) != 0)
|
||||
/* If we are already exiting or if PTHREAD_CANCEL_DISABLED,
|
||||
stop right here. */
|
||||
if ((oldval & (EXITING_BITMASK | CANCELSTATE_BITMASK)) != 0)
|
||||
break;
|
||||
|
||||
int curval = THREAD_ATOMIC_CMPXCHG_VAL (self, cancelhandling,
|
||||
|
@ -41,8 +41,9 @@ __librt_enable_asynccancel (void)
|
||||
|
||||
if (__builtin_expect ((oldval & CANCELED_BITMASK) != 0, 0))
|
||||
{
|
||||
/* If we are already exiting stop right here. */
|
||||
if ((oldval & EXITING_BITMASK) != 0)
|
||||
/* If we are already exiting or if PTHREAD_CANCEL_DISABLED,
|
||||
stop right here. */
|
||||
if ((oldval & (EXITING_BITMASK | CANCELSTATE_BITMASK)) != 0)
|
||||
break;
|
||||
|
||||
int curval = THREAD_ATOMIC_CMPXCHG_VAL (self, cancelhandling,
|
||||
|
121
nptl/tst-cancel22.c
Normal file
121
nptl/tst-cancel22.c
Normal file
@ -0,0 +1,121 @@
|
||||
/* Copyright (C) 2003 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
Contributed by Jakub Jelinek <jakub@redhat.com>, 2003.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with the GNU C Library; if not, write to the Free
|
||||
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
||||
02111-1307 USA. */
|
||||
|
||||
#include <errno.h>
|
||||
#include <pthread.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
pthread_barrier_t b;
|
||||
int seen;
|
||||
|
||||
static void *
|
||||
tf (void *arg)
|
||||
{
|
||||
int old;
|
||||
int r = pthread_setcancelstate (PTHREAD_CANCEL_DISABLE, &old);
|
||||
if (r != 0)
|
||||
{
|
||||
puts ("setcancelstate failed");
|
||||
exit (1);
|
||||
}
|
||||
|
||||
r = pthread_barrier_wait (&b);
|
||||
if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
|
||||
{
|
||||
puts ("barrier_wait failed");
|
||||
exit (1);
|
||||
}
|
||||
|
||||
for (int i = 0; i < 10; ++i)
|
||||
{
|
||||
struct timespec ts = { .tv_sec = 0, .tv_nsec = 100000000 };
|
||||
TEMP_FAILURE_RETRY (nanosleep (&ts, &ts));
|
||||
}
|
||||
|
||||
seen = 1;
|
||||
pthread_setcancelstate (old, NULL);
|
||||
|
||||
struct timespec ts = { .tv_sec = 0, .tv_nsec = 100000000 };
|
||||
TEMP_FAILURE_RETRY (nanosleep (&ts, &ts));
|
||||
|
||||
exit (1);
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
do_test (void)
|
||||
{
|
||||
if (pthread_barrier_init (&b, NULL, 2) != 0)
|
||||
{
|
||||
puts ("barrier init failed");
|
||||
return 1;
|
||||
}
|
||||
|
||||
pthread_t th;
|
||||
if (pthread_create (&th, NULL, tf, NULL) != 0)
|
||||
{
|
||||
puts ("thread creation failed");
|
||||
return 1;
|
||||
}
|
||||
|
||||
int r = pthread_barrier_wait (&b);
|
||||
if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
|
||||
{
|
||||
puts ("barrier_wait failed");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (pthread_cancel (th) != 0)
|
||||
{
|
||||
puts ("cancel failed");
|
||||
return 1;
|
||||
}
|
||||
|
||||
void *status;
|
||||
if (pthread_join (th, &status) != 0)
|
||||
{
|
||||
puts ("join failed");
|
||||
return 1;
|
||||
}
|
||||
if (status != PTHREAD_CANCELED)
|
||||
{
|
||||
puts ("thread not canceled");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (pthread_barrier_destroy (&b) != 0)
|
||||
{
|
||||
puts ("barrier_destroy failed");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (seen != 1)
|
||||
{
|
||||
puts ("thread cancelled when PTHREAD_CANCEL_DISABLED");
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define TIMEOUT 5
|
||||
#define TEST_FUNCTION do_test ()
|
||||
#include "../test-skeleton.c"
|
1
nptl/tst-cancel23.c
Normal file
1
nptl/tst-cancel23.c
Normal file
@ -0,0 +1 @@
|
||||
#include "tst-cancel22.c"
|
@ -77,7 +77,7 @@ tf1 (void *arg)
|
||||
static int
|
||||
do_test (void)
|
||||
{
|
||||
setup_eintr (SIGUSR1);
|
||||
setup_eintr (SIGUSR1, NULL);
|
||||
|
||||
int i;
|
||||
for (i = 0; i < 10; ++i)
|
||||
|
@ -84,7 +84,7 @@ do_test (void)
|
||||
exit (1);
|
||||
}
|
||||
|
||||
setup_eintr (SIGUSR1);
|
||||
setup_eintr (SIGUSR1, NULL);
|
||||
|
||||
pthread_t th;
|
||||
char buf[100];
|
||||
|
72
nptl/tst-eintr3.c
Normal file
72
nptl/tst-eintr3.c
Normal file
@ -0,0 +1,72 @@
|
||||
/* Copyright (C) 2003 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
Contributed by Ulrich Drepper <drepper@redhat.com>, 2003.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with the GNU C Library; if not, write to the Free
|
||||
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
||||
02111-1307 USA. */
|
||||
|
||||
#include <errno.h>
|
||||
#include <pthread.h>
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "eintr.c"
|
||||
|
||||
|
||||
static void *
|
||||
tf (void *arg)
|
||||
{
|
||||
pthread_mutex_t m = PTHREAD_MUTEX_INITIALIZER;
|
||||
pthread_mutex_lock (&m);
|
||||
/* This call must not return. */
|
||||
pthread_mutex_lock (&m);
|
||||
|
||||
puts ("tf: mutex_lock returned");
|
||||
exit (1);
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
do_test (void)
|
||||
{
|
||||
pthread_t self = pthread_self ();
|
||||
|
||||
setup_eintr (SIGUSR1, &self);
|
||||
|
||||
pthread_t th;
|
||||
char buf[100];
|
||||
int e = pthread_create (&th, NULL, tf, NULL);
|
||||
if (e != 0)
|
||||
{
|
||||
printf ("main: pthread_create failed: %s\n",
|
||||
strerror_r (e, buf, sizeof (buf)));
|
||||
exit (1);
|
||||
}
|
||||
|
||||
/* This call must never return. */
|
||||
e = pthread_join (th, NULL);
|
||||
|
||||
if (e == EINTR)
|
||||
puts ("pthread_join returned with EINTR");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define EXPECTED_SIGNAL SIGALRM
|
||||
#define TIMEOUT 1
|
||||
#define TEST_FUNCTION do_test ()
|
||||
#include "../test-skeleton.c"
|
56
nptl/tst-eintr4.c
Normal file
56
nptl/tst-eintr4.c
Normal file
@ -0,0 +1,56 @@
|
||||
/* Copyright (C) 2003 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
Contributed by Ulrich Drepper <drepper@redhat.com>, 2003.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with the GNU C Library; if not, write to the Free
|
||||
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
||||
02111-1307 USA. */
|
||||
|
||||
#include <errno.h>
|
||||
#include <pthread.h>
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "eintr.c"
|
||||
|
||||
|
||||
static int
|
||||
do_test (void)
|
||||
{
|
||||
pthread_t self = pthread_self ();
|
||||
|
||||
setup_eintr (SIGUSR1, &self);
|
||||
|
||||
pthread_barrier_t b;
|
||||
if (pthread_barrier_init (&b, NULL, 2) != 0)
|
||||
{
|
||||
puts ("barrier_init failed");
|
||||
exit (1);
|
||||
}
|
||||
|
||||
/* This call must never return. */
|
||||
int e = pthread_barrier_wait (&b);
|
||||
|
||||
if (e == EINTR)
|
||||
puts ("pthread_join returned with EINTR");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define EXPECTED_SIGNAL SIGALRM
|
||||
#define TIMEOUT 1
|
||||
#define TEST_FUNCTION do_test ()
|
||||
#include "../test-skeleton.c"
|
Loading…
Reference in New Issue
Block a user