| 662 | |
| 663 | |
| 664 | UINT __stdcall CGenericServer::HelperThread(LPVOID pParam) |
| 665 | { |
| 666 | CGenericServer *pGenericServer = (CGenericServer*)pParam; |
| 667 | HANDLELIST::iterator it; |
| 668 | |
| 669 | SetEvent(pGenericServer->ThreadLaunchedEvent); |
| 670 | |
| 671 | for(;;) |
| 672 | { |
| 673 | if(WaitForSingleObject(pGenericServer->ShutdownEvent, TICK) == WAIT_TIMEOUT) |
| 674 | { |
| 675 | EnterCriticalSection(&pGenericServer->_cs); |
| 676 | while(pGenericServer->HandleList.size()) |
| 677 | { |
| 678 | HANDLE h = pGenericServer->HandleList.front(); |
| 679 | DWORD n = WaitForSingleObject(h, THREADKILL_TO); |
| 680 | if(n == WAIT_TIMEOUT) |
| 681 | { |
| 682 | pGenericServer->LogMessage(LOGFILENAME, _T("WaitForSingleObject(...) timed out"), _T("HelperThread")); |
| 683 | if(!TerminateThread(h, THREADEXIT_SUCCESS)) |
| 684 | pGenericServer->LogMessage(LOGFILENAME, _T("TerminateThread(.h.) failure, probably it is already terminated"), _T("HelperThread"), GetLastError()); |
| 685 | } |
| 686 | CloseHandle(h); |
| 687 | pGenericServer->HandleList.pop_front(); |
| 688 | } |
| 689 | LeaveCriticalSection(&pGenericServer->_cs); |
| 690 | } |
| 691 | else |
| 692 | return THREADEXIT_SUCCESS; |
| 693 | |
| 694 | } |
| 695 | |
| 696 | return THREADEXIT_SUCCESS; |
| 697 | } |
| 698 | |
| 699 | |
| 700 |
nothing calls this directly
no test coverage detected