version 1.19, 2002/06/07 15:17:13
|
version 1.20, 2002/06/07 20:52:13
|
|
|
| |
static struct timeval create_time = {0, 10}; | static struct timeval create_time = {0, 10}; |
static struct timeval destroy_time = {5, 0}; | static struct timeval destroy_time = {5, 0}; |
static struct timeval deadlock_time = {100, 0}; |
static struct timeval deadlock_time = {1000, 0}; |
| |
//////////////////////////////////////////////////////////////////////////////// | //////////////////////////////////////////////////////////////////////////////// |
// | // |
|
|
destroy_time, | destroy_time, |
deadlock_time); | deadlock_time); |
} | } |
|
else |
|
_thread_pool = 0; |
} | } |
|
|
Monitor::~Monitor() | Monitor::~Monitor() |
{ | { |
Tracer::trace(TRC_HTTP, Tracer::LEVEL4, | Tracer::trace(TRC_HTTP, Tracer::LEVEL4, |
|
|
Socket::uninitializeInterface(); | Socket::uninitializeInterface(); |
Tracer::trace(TRC_HTTP, Tracer::LEVEL4, | Tracer::trace(TRC_HTTP, Tracer::LEVEL4, |
"returning from monitor destructor"); | "returning from monitor destructor"); |
|
if(_async == false) |
delete _thread_pool; | delete _thread_pool; |
} | } |
| |
|
|
{ | { |
static struct timeval now, last; | static struct timeval now, last; |
gettimeofday(&now, NULL); | gettimeofday(&now, NULL); |
|
int dead_threads = 0; |
| |
if( now.tv_sec - last.tv_sec > 0 ) | if( now.tv_sec - last.tv_sec > 0 ) |
{ | { |
gettimeofday(&last, NULL); | gettimeofday(&last, NULL); |
return _thread_pool->kill_dead_threads(); |
try |
|
{ |
|
|
|
dead_threads = _thread_pool->kill_dead_threads(); |
} | } |
return 0; |
catch(IPCException& ) |
|
{ |
|
} |
|
|
|
} |
|
return dead_threads; |
} | } |
| |
| |
|
|
Boolean Monitor::run(Uint32 milliseconds) | Boolean Monitor::run(Uint32 milliseconds) |
{ | { |
| |
static struct timeval now, last; |
|
|
|
#ifdef PEGASUS_OS_TYPE_WINDOWS | #ifdef PEGASUS_OS_TYPE_WINDOWS |
| |
// Windows select() has a strange little bug. It returns immediately if | // Windows select() has a strange little bug. It returns immediately if |
|
|
// there were no undispatched events from last time. | // there were no undispatched events from last time. |
| |
int count = 0; | int count = 0; |
pegasus_gettimeofday(&now); |
|
| |
memcpy(&_rep->active_rd_fd_set, &_rep->rd_fd_set, sizeof(fd_set)); | memcpy(&_rep->active_rd_fd_set, &_rep->rd_fd_set, sizeof(fd_set)); |
// memcpy(&_rep->active_wr_fd_set, &_rep->wr_fd_set, sizeof(fd_set)); | // memcpy(&_rep->active_wr_fd_set, &_rep->wr_fd_set, sizeof(fd_set)); |
|
|
&tv); | &tv); |
if(count == 0) | if(count == 0) |
{ | { |
if( now.tv_sec - last.tv_sec > 2) |
|
{ |
|
kill_idle_threads(); |
|
MessageQueueService::kill_idle_threads(); |
|
pegasus_gettimeofday(&last); |
|
} |
|
return false; | return false; |
} | } |
#ifdef PEGASUS_OS_TYPE_WINDOWS | #ifdef PEGASUS_OS_TYPE_WINDOWS |