version 1.17, 2002/06/01 00:56:40
|
version 1.18, 2002/06/07 00:03:34
|
|
|
gettimeofday(&now, NULL); | gettimeofday(&now, NULL); |
Uint32 bodies = 0; | Uint32 bodies = 0; |
| |
|
|
// first go thread the dead q and clean it up as much as possible | // first go thread the dead q and clean it up as much as possible |
while(_dead.count() > 0) | while(_dead.count() > 0) |
{ | { |
|
|
{ | { |
q->try_lock(); | q->try_lock(); |
} | } |
catch(AlreadyLocked &) |
catch(...) |
{ | { |
q++; |
return bodies; |
continue; |
|
} | } |
| |
struct timeval dt = { 0, 0 }; | struct timeval dt = { 0, 0 }; |
|
|
{ | { |
dtp = (struct timeval *)th->try_reference_tsd("deadlock timer"); | dtp = (struct timeval *)th->try_reference_tsd("deadlock timer"); |
} | } |
catch(AlreadyLocked &) |
catch(...) |
{ | { |
th = q->next(th); |
return bodies; |
continue; |
|
} | } |
| |
if(dtp != 0) | if(dtp != 0) |
{ | { |
memcpy(&dt, dtp, sizeof(struct timeval)); | memcpy(&dt, dtp, sizeof(struct timeval)); |
|
|
} | } |
th->dereference_tsd(); | th->dereference_tsd(); |
struct timeval deadlock_timeout; | struct timeval deadlock_timeout; |
if( true == check_time(&dt, get_deadlock_detect(&deadlock_timeout) )) |
Boolean too_long; |
|
if( i == 0) |
|
{ |
|
too_long = check_time(&dt, get_deallocate_wait(&deadlock_timeout)); |
|
} |
|
else |
|
{ |
|
check_time(&dt, get_deadlock_detect(&deadlock_timeout)); |
|
} |
|
|
|
if( true == too_long) |
{ | { |
// if we are deallocating from the pool, escape if we are | // if we are deallocating from the pool, escape if we are |
// down to the minimum thread count | // down to the minimum thread count |
_current_threads--; | _current_threads--; |
if( _current_threads.value() <= (Uint32)_min_threads ) |
if( _current_threads.value() < (Uint32)_min_threads ) |
{ | { |
if( i == 0) | if( i == 0) |
{ | { |
|
|
| |
if(th != 0) | if(th != 0) |
{ | { |
|
|
th->delete_tsd("work func"); | th->delete_tsd("work func"); |
th->put_tsd("work func", NULL, | th->put_tsd("work func", NULL, |
sizeof( PEGASUS_THREAD_RETURN (PEGASUS_THREAD_CDECL *)(void *)), | sizeof( PEGASUS_THREAD_RETURN (PEGASUS_THREAD_CDECL *)(void *)), |
|
|
th->dereference_tsd(); | th->dereference_tsd(); |
throw NullPointer(); | throw NullPointer(); |
} | } |
|
|
// put the thread on the dead list | // put the thread on the dead list |
_dead.insert_first(th); | _dead.insert_first(th); |
bodies++; | bodies++; |
|
|
} | } |
} | } |
} | } |
|
|
|
|
return bodies; | return bodies; |
} | } |
| |