Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/winsup
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2016-04-20 13:31:45 +0300
committerCorinna Vinschen <corinna@vinschen.de>2016-04-20 13:31:45 +0300
commit9409c5335bfac54ccd89fbe931e670b797462e05 (patch)
tree96d5fc9b47998f9e199f46081dfafb939c41eb69 /winsup
parent6ee81f44e04848901c7b05c968564d34a7ceed06 (diff)
Don't test pthread objects for being already initialized at init time
For all pthread init functions, POSIX says Results are undefined if pthread_FOO_init() is called specifying an already initialized pthread_FOO object. So far our pthread init functions tested the incoming object if it's already an initialized object and, if so, returned EBUSY. That's ok *iff* the object was already initialized. However, as the example in https://cygwin.com/ml/cygwin/2016-04/msg00473.html shows, an uninitialized pthread object could also accidentally look like an initialized object and then returning EBUSY is not ok. Consequentially, all those tests are dangerous. Per POSIX, an application has to know what its doing when calling any of the pthread init functions anyway, and re-initializing the object is just as well as undefined behaviour as is returning EBUSY on already initialized objects. * thread.cc (pthread_attr_init): Drop check for already initialized object. (pthread_condattr_init): Ditto. (pthread_rwlockattr_init): Ditto. (pthread_mutexattr_init): Ditto. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
Diffstat (limited to 'winsup')
-rw-r--r--winsup/cygwin/thread.cc12
1 files changed, 0 insertions, 12 deletions
diff --git a/winsup/cygwin/thread.cc b/winsup/cygwin/thread.cc
index 05757ac58..ec59f1f61 100644
--- a/winsup/cygwin/thread.cc
+++ b/winsup/cygwin/thread.cc
@@ -2175,9 +2175,6 @@ pthread::atfork (void (*prepare)(void), void (*parent)(void), void (*child)(void
extern "C" int
pthread_attr_init (pthread_attr_t *attr)
{
- if (pthread_attr::is_good_object (attr))
- return EBUSY;
-
*attr = new pthread_attr;
if (!pthread_attr::is_good_object (attr))
{
@@ -2854,9 +2851,6 @@ pthread_cond_wait (pthread_cond_t *cond, pthread_mutex_t *mutex)
extern "C" int
pthread_condattr_init (pthread_condattr_t *condattr)
{
- if (pthread_condattr::is_good_object (condattr))
- return EBUSY;
-
*condattr = new pthread_condattr;
if (!pthread_condattr::is_good_object (condattr))
{
@@ -3040,9 +3034,6 @@ pthread_rwlock_unlock (pthread_rwlock_t *rwlock)
extern "C" int
pthread_rwlockattr_init (pthread_rwlockattr_t *rwlockattr)
{
- if (pthread_rwlockattr::is_good_object (rwlockattr))
- return EBUSY;
-
*rwlockattr = new pthread_rwlockattr;
if (!pthread_rwlockattr::is_good_object (rwlockattr))
{
@@ -3370,9 +3361,6 @@ pthread_mutexattr_gettype (const pthread_mutexattr_t *attr, int *type)
extern "C" int
pthread_mutexattr_init (pthread_mutexattr_t *attr)
{
- if (pthread_mutexattr::is_good_object (attr))
- return EBUSY;
-
*attr = new pthread_mutexattr ();
if (!pthread_mutexattr::is_good_object (attr))
{