mamke status a member so that we aren't return the address of a local variable
This commit is contained in:
parent
e9ed046361
commit
ecce87b779
|
@ -253,7 +253,7 @@ void *Thread::mThreadFunc( void *arg )
|
||||||
Debug( 2, "Invoking thread" );
|
Debug( 2, "Invoking thread" );
|
||||||
|
|
||||||
Thread *thisPtr = (Thread *)arg;
|
Thread *thisPtr = (Thread *)arg;
|
||||||
void *status = 0;
|
thisPtr->status = 0;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
thisPtr->mThreadMutex.lock();
|
thisPtr->mThreadMutex.lock();
|
||||||
|
@ -261,19 +261,18 @@ void *Thread::mThreadFunc( void *arg )
|
||||||
thisPtr->mThreadCondition.signal();
|
thisPtr->mThreadCondition.signal();
|
||||||
thisPtr->mThreadMutex.unlock();
|
thisPtr->mThreadMutex.unlock();
|
||||||
thisPtr->mRunning = true;
|
thisPtr->mRunning = true;
|
||||||
int run=(thisPtr->run());
|
thisPtr->status = thisPtr->run();
|
||||||
status = (void *)&run;
|
|
||||||
thisPtr->mRunning = false;
|
thisPtr->mRunning = false;
|
||||||
Debug( 2, "Exiting thread, status %p", status );
|
Debug( 2, "Exiting thread, status %p", (void *)&(thisPtr->status) );
|
||||||
|
return (void *)&(thisPtr->status);
|
||||||
}
|
}
|
||||||
catch ( const ThreadException &e )
|
catch ( const ThreadException &e )
|
||||||
{
|
{
|
||||||
Error( "%s", e.getMessage().c_str() );
|
Error( "%s", e.getMessage().c_str() );
|
||||||
thisPtr->mRunning = false;
|
thisPtr->mRunning = false;
|
||||||
status = (void *)-1;
|
Debug( 2, "Exiting thread after exception, status %p", (void *)-1 );
|
||||||
Debug( 2, "Exiting thread after exception, status %p", status );
|
return (void *)-1;
|
||||||
}
|
}
|
||||||
return( status );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Thread::start()
|
void Thread::start()
|
||||||
|
|
|
@ -224,6 +224,7 @@ protected:
|
||||||
#endif
|
#endif
|
||||||
bool mStarted;
|
bool mStarted;
|
||||||
bool mRunning;
|
bool mRunning;
|
||||||
|
int status; // Used in various funcions to get around return a local variable
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Thread();
|
Thread();
|
||||||
|
@ -253,10 +254,10 @@ return tid;
|
||||||
return( pthread_self() );
|
return( pthread_self() );
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
void exit( int status = 0 )
|
void exit( int p_status = 0 )
|
||||||
{
|
{
|
||||||
//INFO( "Exiting" );
|
//INFO( "Exiting" );
|
||||||
pthread_exit( (void *)&status );
|
pthread_exit( (void *)&p_status );
|
||||||
}
|
}
|
||||||
static void *mThreadFunc( void *arg );
|
static void *mThreadFunc( void *arg );
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue