Merge branch 'android_branch' into gtk_multigame

This commit is contained in:
Eric House 2013-01-11 20:48:44 -08:00
commit 33735ae7a5
4 changed files with 14 additions and 11 deletions

View file

@ -24,6 +24,7 @@
#include <string.h>
#include <stdlib.h>
#include <pthread.h>
#include <unistd.h>
#include "crefmgr.h"
#include "cref.h"
@ -413,6 +414,8 @@ CRefMgr::getCookieRef( CookieID cid, bool failOk )
break;
}
m_cidlock->Relinquish( cinfo, true );
logf( XW_LOGINFO, "%s: sleeping after failing to get cinfo", __func__ );
usleep(200000); /* 2/10 second */
}
return cinfo;
} /* getCookieRef */

View file

@ -85,17 +85,15 @@ XWThreadPool::Setup( int nThreads, packet_func pFunc, kill_func kFunc )
m_pFunc = pFunc;
m_kFunc = kFunc;
pthread_t thread;
int ii;
for ( ii = 0; ii < nThreads; ++ii ) {
for ( int ii = 0; ii < nThreads; ++ii ) {
ThreadInfo* tip = &m_threadInfos[ii];
tip->me = this;
int result = pthread_create( &thread, NULL, tpool_main, tip );
int result = pthread_create( &tip->thread, NULL, tpool_main, tip );
assert( result == 0 );
pthread_detach( thread );
pthread_detach( tip->thread );
}
pthread_t thread;
int result = pthread_create( &thread, NULL, listener_main, this );
assert( result == 0 );
result = pthread_detach( thread );
@ -478,7 +476,7 @@ XWThreadPool::print_in_use( void )
void
XWThreadPool::log_hung_threads( void )
{
const time_t HUNG_THREASHHOLD = 5; // seconds
const time_t HUNG_THREASHHOLD = 300; // seconds
int ii;
time_t now = time( NULL );
for ( ii = 0; ii < m_nThreads; ++ii ) {
@ -487,8 +485,10 @@ XWThreadPool::log_hung_threads( void )
if ( 0 != recentTime ) {
time_t howLong = now - recentTime;
if ( HUNG_THREASHHOLD < howLong ) {
logf( XW_LOGERROR, "thread %d stopped for %d seconds!", ii, howLong );
logf( XW_LOGERROR, "thread %d (%p) stopped for %d seconds!",
ii, tip->thread, howLong );
tip->recentTime = 0; // only log once
assert(0);
}
}
}

View file

@ -44,6 +44,7 @@ class XWThreadPool {
typedef struct _ThreadInfo {
XWThreadPool* me;
pthread_t thread;
time_t recentTime;
} ThreadInfo;

View file

@ -7,7 +7,6 @@ XWRELAY=${DIR}/xwrelay
PIDFILE=${DIR}/xwrelay.pid
CONFFILE=${DIR}/xwrelay.conf
IDFILE=${DIR}/nextid.txt
CSSFILE=${DIR}/xwrelay.css
LOGFILE=/tmp/xwrelay_log_$$.txt
#LOGFILE=/dev/null
@ -98,8 +97,8 @@ do_start() {
exit 1
fi
echo "starting..." | tee -a $LOGFILE
echo "running $XWRELAY $@ -f $CONFFILE -s $CSSFILE" | tee -a $LOGFILE
$XWRELAY $@ -f $CONFFILE -s $CSSFILE &
echo "running $XWRELAY $@ -f $CONFFILE" | tee -a $LOGFILE
$XWRELAY $@ -f $CONFFILE &
NEWPID=$!
echo -n $NEWPID > $PIDFILE
sleep 1