# HG changeset patch # User Sam Lantinga # Date 1023741722 0 # Node ID 283d348cb624b92f61778b15aa1de3e396721e69 # Parent 11d6eed68dbac17e5a84fde06f0051abf769ae2b Pth threading bug fix diff -r 11d6eed68dba -r 283d348cb624 src/SDL.c --- a/src/SDL.c Mon Jun 10 20:37:39 2002 +0000 +++ b/src/SDL.c Mon Jun 10 20:42:02 2002 +0000 @@ -150,6 +150,12 @@ int SDL_Init(Uint32 flags) { +#if !defined(DISABLE_THREADS) && defined(ENABLE_PTH) + if (!pth_init()) { + return -1; + } +#endif + /* Clear the error message */ SDL_ClearError(); @@ -223,6 +229,10 @@ /* Uninstall any parachute signal handlers */ SDL_UninstallParachute(); + +#if !defined(DISABLE_THREADS) && defined(ENABLE_PTH) + pth_kill(); +#endif } /* Return the library version number */ diff -r 11d6eed68dba -r 283d348cb624 src/thread/SDL_thread.c --- a/src/thread/SDL_thread.c Mon Jun 10 20:37:39 2002 +0000 +++ b/src/thread/SDL_thread.c Mon Jun 10 20:42:02 2002 +0000 @@ -52,12 +52,6 @@ { int retval; -#ifdef ENABLE_PTH - if (!pth_init()) { - return -1; - } -#endif - retval = 0; /* Set the thread lock creation flag so that we can reuse an existing lock on the system - since this mutex never gets @@ -86,10 +80,6 @@ if ( mutex != NULL ) { SDL_DestroyMutex(mutex); } - -#ifdef ENABLE_PTH - pth_kill(); -#endif } /* Routines for manipulating the thread list */ diff -r 11d6eed68dba -r 283d348cb624 src/thread/pth/SDL_systhread.c --- a/src/thread/pth/SDL_systhread.c Mon Jun 10 20:37:39 2002 +0000 +++ b/src/thread/pth/SDL_systhread.c Mon Jun 10 20:42:02 2002 +0000 @@ -64,7 +64,8 @@ pth_attr_set(type, PTH_ATTR_JOINABLE, TRUE); /* Create the thread and go! */ - if ( pth_spawn(type, RunThread, args) == NULL ) { + thread->handle = pth_spawn(type, RunThread, args); + if ( thread->handle == NULL ) { SDL_SetError("Not enough resources to create thread"); return(-1); }