Pth threading bug fix
authorSam Lantinga <slouken@libsdl.org>
Mon, 10 Jun 2002 20:42:02 +0000
changeset 397283d348cb624
parent 396 11d6eed68dba
child 398 d219b0e02f5f
Pth threading bug fix
src/SDL.c
src/thread/SDL_thread.c
src/thread/pth/SDL_systhread.c
     1.1 --- a/src/SDL.c	Mon Jun 10 20:37:39 2002 +0000
     1.2 +++ b/src/SDL.c	Mon Jun 10 20:42:02 2002 +0000
     1.3 @@ -150,6 +150,12 @@
     1.4  
     1.5  int SDL_Init(Uint32 flags)
     1.6  {
     1.7 +#if !defined(DISABLE_THREADS) && defined(ENABLE_PTH)
     1.8 +	if (!pth_init()) {
     1.9 +		return -1;
    1.10 +	}
    1.11 +#endif
    1.12 +
    1.13  	/* Clear the error message */
    1.14  	SDL_ClearError();
    1.15  
    1.16 @@ -223,6 +229,10 @@
    1.17  
    1.18  	/* Uninstall any parachute signal handlers */
    1.19  	SDL_UninstallParachute();
    1.20 +
    1.21 +#if !defined(DISABLE_THREADS) && defined(ENABLE_PTH)
    1.22 +	pth_kill();
    1.23 +#endif
    1.24  }
    1.25  
    1.26  /* Return the library version number */
     2.1 --- a/src/thread/SDL_thread.c	Mon Jun 10 20:37:39 2002 +0000
     2.2 +++ b/src/thread/SDL_thread.c	Mon Jun 10 20:42:02 2002 +0000
     2.3 @@ -52,12 +52,6 @@
     2.4  {
     2.5  	int retval;
     2.6  
     2.7 -#ifdef ENABLE_PTH
     2.8 -	if (!pth_init()) {
     2.9 -		return -1;
    2.10 -	}
    2.11 -#endif
    2.12 -
    2.13  	retval = 0;
    2.14  	/* Set the thread lock creation flag so that we can reuse an
    2.15  	   existing lock on the system - since this mutex never gets
    2.16 @@ -86,10 +80,6 @@
    2.17  	if ( mutex != NULL ) {
    2.18  		SDL_DestroyMutex(mutex);
    2.19  	}
    2.20 -
    2.21 -#ifdef ENABLE_PTH
    2.22 -	pth_kill();
    2.23 -#endif
    2.24  }
    2.25  
    2.26  /* Routines for manipulating the thread list */
     3.1 --- a/src/thread/pth/SDL_systhread.c	Mon Jun 10 20:37:39 2002 +0000
     3.2 +++ b/src/thread/pth/SDL_systhread.c	Mon Jun 10 20:42:02 2002 +0000
     3.3 @@ -64,7 +64,8 @@
     3.4  	pth_attr_set(type, PTH_ATTR_JOINABLE, TRUE);
     3.5  
     3.6  	/* Create the thread and go! */
     3.7 -	if ( pth_spawn(type, RunThread, args) == NULL ) {
     3.8 +	thread->handle = pth_spawn(type, RunThread, args);
     3.9 +	if ( thread->handle == NULL ) {
    3.10  		SDL_SetError("Not enough resources to create thread");
    3.11  		return(-1);
    3.12  	}