diff options
| author | rpj <rpj> | 1999-02-02 15:16:42 +0000 | 
|---|---|---|
| committer | rpj <rpj> | 1999-02-02 15:16:42 +0000 | 
| commit | 856068d292843ed7e8b3c49ecf55bd5f5c1b2368 (patch) | |
| tree | ca7e8a24249ff45e0d538530180b2c628b21ee63 | |
| parent | cc29ad943903e9b8dba96cd978cb126f79f73e38 (diff) | |
Wed Feb  3 10:13:48 1999  Ross Johnson  <rpj@ixobrychus.canberra.edu.au>
	* sync.c (pthread_join): Check for NULL value_ptr arg;
	check for detached threads.
| -rw-r--r-- | ChangeLog | 5 | ||||
| -rw-r--r-- | sync.c | 29 | 
2 files changed, 27 insertions, 7 deletions
| @@ -1,3 +1,8 @@ +Wed Feb  3 10:13:48 1999  Ross Johnson  <rpj@ixobrychus.canberra.edu.au> + +	* sync.c (pthread_join): Check for NULL value_ptr arg; +	check for detached threads. +  Tue Feb  2 18:07:43 1999  Ross Johnson  <rpj@swan.canberra.edu.au>  	* implement.h: Add #include <pthread.h>. @@ -72,8 +72,11 @@ pthread_join (pthread_t thread, void **value_ptr)        *      completion.        *        * PARAMETERS -      *      sem -      *              pointer to an instance of sem_t +      *      thread +      *              an instance of pthread_t +      * +      *      value_ptr +      *              pointer to an instance of pointer to void        *        *        * DESCRIPTION @@ -100,7 +103,10 @@ pthread_join (pthread_t thread, void **value_ptr)    if (pthread_equal (self, thread) == 0)      {        result = EDEADLK; - +    } +  else if (thread->detachState == PTHREAD_CREATE_DETACHED) +    { +      result = EINVAL;      }    else      { @@ -108,14 +114,21 @@ pthread_join (pthread_t thread, void **value_ptr)        stat = WaitForSingleObject (thread->threadH, INFINITE); -      if (stat != WAIT_OBJECT_0 && -	  !GetExitCodeThread (thread->threadH, (LPDWORD) value_ptr)) +      if (stat == WAIT_OBJECT_0)  	{ -	  result = ESRCH; +	  if (value_ptr != NULL +	      && !GetExitCodeThread (thread->threadH, (LPDWORD) value_ptr)) +	    { +	      result = ESRCH; +	    } +	  else +	    { +	      _pthread_threadDestroy (thread); +	    }  	}        else  	{ -	  _pthread_threadDestroy (thread); +	  result = ESRCH;  	}      } @@ -125,3 +138,5 @@ pthread_join (pthread_t thread, void **value_ptr)  /* </JEB> */ + + | 
