Backout revision 1.5, the pthread->error was used as internal
authorDavid Xu <davidxu@dragonflybsd.org>
Sat, 7 May 2005 07:39:14 +0000 (07:39 +0000)
committerDavid Xu <davidxu@dragonflybsd.org>
Sat, 7 May 2005 07:39:14 +0000 (07:39 +0000)
communication variable between threads, two tls_set_tcb calls
are not signal safe.

lib/libthread_xu/thread/thr_mutex.c

index 4b9f351..344e4ef 100644 (file)
@@ -30,7 +30,7 @@
  * SUCH DAMAGE.
  *
  * $FreeBSD: src/lib/libpthread/thread/thr_mutex.c,v 1.46 2004/10/31 05:03:50 green Exp $
- * $DragonFly: src/lib/libthread_xu/thread/thr_mutex.c,v 1.5 2005/05/03 07:29:04 joerg Exp $
+ * $DragonFly: src/lib/libthread_xu/thread/thr_mutex.c,v 1.6 2005/05/07 07:39:14 davidxu Exp $
  */
 
 #include <machine/tls.h>
@@ -696,7 +696,7 @@ mutex_lock_common(struct pthread *curthread, pthread_mutex_t *m,
                                curthread->data.mutex = *m;
 
                                /* Clear any previous error: */
-                               errno = 0;
+                               curthread->error = 0;
 
                                THR_LOCK(curthread);
                                cycle = curthread->cycle;
@@ -729,8 +729,8 @@ mutex_lock_common(struct pthread *curthread, pthread_mutex_t *m,
                                 * waiting for the mutex causing a ceiling
                                 * violation.
                                 */
-                               ret = errno;
-                               errno = 0;
+                               ret = curthread->error;
+                               curthread->error = 0;
                        }
                        break;
 
@@ -1566,9 +1566,7 @@ mutex_handoff(struct pthread *curthread, struct pthread_mutex *mutex)
                                 * has been raised subsequent to the thread
                                 * being queued on the waiting list.
                                 */
-                               tls_set_tcb(pthread->tcb);
-                               errno = EINVAL;
-                               tls_set_tcb(curthread->tcb);
+                               pthread->error = EINVAL;
                        }
                        else {
                                /*