Merge pull request #1377 from ZoneMinder/random_fixes

Random fixes
This commit is contained in:
Andrew Bauer 2016-04-11 12:04:05 -05:00
commit 28b30ecb47
2 changed files with 9 additions and 9 deletions

View File

@ -253,7 +253,7 @@ void *Thread::mThreadFunc( void *arg )
Debug( 2, "Invoking thread" );
Thread *thisPtr = (Thread *)arg;
void *status = 0;
thisPtr->status = 0;
try
{
thisPtr->mThreadMutex.lock();
@ -261,19 +261,18 @@ void *Thread::mThreadFunc( void *arg )
thisPtr->mThreadCondition.signal();
thisPtr->mThreadMutex.unlock();
thisPtr->mRunning = true;
int run=(thisPtr->run());
status = (void *)&run;
thisPtr->status = thisPtr->run();
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 )
{
Error( "%s", e.getMessage().c_str() );
thisPtr->mRunning = false;
status = (void *)-1;
Debug( 2, "Exiting thread after exception, status %p", status );
Debug( 2, "Exiting thread after exception, status %p", (void *)-1 );
return (void *)-1;
}
return( status );
}
void Thread::start()

View File

@ -224,6 +224,7 @@ protected:
#endif
bool mStarted;
bool mRunning;
int status; // Used in various funcions to get around return a local variable
protected:
Thread();
@ -253,10 +254,10 @@ return tid;
return( pthread_self() );
}
#endif
void exit( int status = 0 )
void exit( int p_status = 0 )
{
//INFO( "Exiting" );
pthread_exit( (void *)&status );
pthread_exit( (void *)&p_status );
}
static void *mThreadFunc( void *arg );