Merge remote branch 'origin/android_branch' into android_branch

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

View file

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

View file

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

View file

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

View file

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