| 1 |
/*******************************************************/ |
/*******************************************************/ |
| 2 |
/* */ |
/* */ |
| 3 |
/* LeafOK Innbbsd */ |
/* LeafOK Innbbsd */ |
| 4 |
/* Copyright (C) LeafOK.com, 2003-2004 */ |
/* Copyright (C) LeafOK.com, 2003-2005 */ |
| 5 |
/* */ |
/* */ |
| 6 |
/* Programmed by Leaf */ |
/* Programmed by Leaf */ |
| 7 |
/* E-mail:leaflet@leafok.com QQ:6049044 */ |
/* E-mail:leaflet@leafok.com QQ:6049044 */ |
| 153 |
} |
} |
| 154 |
|
|
| 155 |
|
|
| 156 |
int thread_pool::SetThreadStatus(ULONG ulThreadd, int uStatus) |
int thread_pool::SetThreadStatus(ULONG ulThreadId, int uStatus) |
| 157 |
{ |
{ |
| 158 |
UINTT i; |
UINT i; |
| 159 |
|
|
| 160 |
if (this->uThreadCount <= 0) |
if (this->uThreadCount <= 0) |
| 161 |
{ |
{ |
| 229 |
// Remove dead thread from thread pool |
// Remove dead thread from thread pool |
| 230 |
if (p->RemoveThread(ulThreadId) != 0) |
if (p->RemoveThread(ulThreadId) != 0) |
| 231 |
{ |
{ |
| 232 |
syslog << logfile::log_head << "Unregister thread ... Failed" << endl; |
syslog << logfile::log_head << "Unregister thread (" << ulThreadId << ") ... Failed" << endl; |
| 233 |
} |
} |
| 234 |
// Kill dead thread |
// Kill dead thread |
| 235 |
if ((hThread = OpenThread(THREAD_TERMINATE,FALSE,ulThreadId)) == NULL) |
if ((hThread = OpenThread(THREAD_TERMINATE,FALSE,ulThreadId)) == NULL) |
| 240 |
{ |
{ |
| 241 |
if (TerminateThread(hThread,-1)) |
if (TerminateThread(hThread,-1)) |
| 242 |
{ |
{ |
| 243 |
syslog << logfile::log_head << "Terminate dead thread ... OK" << endl; |
syslog << logfile::log_head << "Terminate dead thread (" << ulThreadId << ") ... OK" << endl; |
| 244 |
} |
} |
| 245 |
else |
else |
| 246 |
{ |
{ |
| 247 |
syslog << logfile::log_head << "Terminate dead thread ... Failed" << endl; |
syslog << logfile::log_head << "Terminate dead thread (" << ulThreadId << ") ... Failed" << endl; |
| 248 |
} |
} |
| 249 |
CloseHandle(hThread); |
CloseHandle(hThread); |
| 250 |
} |
} |
| 275 |
this->bTerminateThreadKiller = false; |
this->bTerminateThreadKiller = false; |
| 276 |
if (hThreadCurrent = CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)thread_pool::KillDeadThread,(LPVOID)this,0,&ulThreadId)) |
if (hThreadCurrent = CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)thread_pool::KillDeadThread,(LPVOID)this,0,&ulThreadId)) |
| 277 |
{ |
{ |
| 278 |
|
CloseHandle(hThreadCurrent); |
| 279 |
syslog << logfile::log_head << "Create killer thread ... OK" << endl; |
syslog << logfile::log_head << "Create killer thread ... OK" << endl; |
| 280 |
} |
} |
| 281 |
else |
else |
| 363 |
{ |
{ |
| 364 |
if (TerminateThread(hThread,-1)) |
if (TerminateThread(hThread,-1)) |
| 365 |
{ |
{ |
| 366 |
syslog << logfile::log_head << "Terminate all thread ... OK" << endl; |
syslog << logfile::log_head << "Terminate all thread (" << ulThreadId << ") ... OK" << endl; |
| 367 |
} |
} |
| 368 |
else |
else |
| 369 |
{ |
{ |
| 370 |
syslog << logfile::log_head << "Terminate all thread ... Failed" << endl; |
syslog << logfile::log_head << "Terminate all thread (" << ulThreadId << ") ... Failed" << endl; |
| 371 |
} |
} |
| 372 |
CloseHandle(hThread); |
CloseHandle(hThread); |
| 373 |
} |
} |