Vincent Fatica
2010-01-27 03:48:59 UTC
I have a thread doing this.
DWORD WINAPI ReadPipeThread(LPVOID lpv)
{
WCHAR Buffer[32768];//, szResult[32];
DWORD dwRead, dwWritten;
while ( bListen )
{
if ( ConnectNamedPipe(hPipe, NULL) ) // blocks
{
if ( ReadFile(hPipe, Buffer, 32768 * sizeof(WCHAR),
&dwRead, NULL) && dwRead )
...
If from another thread I call
VOID ShutDownServer(VOID)
{
Printf(L"Stopping server\r\n");
bListen = FALSE;
if ( hPipe != INVALID_HANDLE_VALUE )
{
CloseHandle(hPipe);
hPipe = INVALID_HANDLE_VALUE;
}
Printf(L"Stopping server\r\n");
//if ( hThread )
//{
// TerminateThread(hThread, 0);
// CloseHandle(hThread);
// hThread = NULL;
//}
}
ShutDownServer() never returns; the thread that calls it hangs! In fact I don't
even see the second message. I'm very surprised, not seeing any reason for that
to happen. Any ideas? Thanks.
DWORD WINAPI ReadPipeThread(LPVOID lpv)
{
WCHAR Buffer[32768];//, szResult[32];
DWORD dwRead, dwWritten;
while ( bListen )
{
if ( ConnectNamedPipe(hPipe, NULL) ) // blocks
{
if ( ReadFile(hPipe, Buffer, 32768 * sizeof(WCHAR),
&dwRead, NULL) && dwRead )
...
If from another thread I call
VOID ShutDownServer(VOID)
{
Printf(L"Stopping server\r\n");
bListen = FALSE;
if ( hPipe != INVALID_HANDLE_VALUE )
{
CloseHandle(hPipe);
hPipe = INVALID_HANDLE_VALUE;
}
Printf(L"Stopping server\r\n");
//if ( hThread )
//{
// TerminateThread(hThread, 0);
// CloseHandle(hThread);
// hThread = NULL;
//}
}
ShutDownServer() never returns; the thread that calls it hangs! In fact I don't
even see the second message. I'm very surprised, not seeing any reason for that
to happen. Any ideas? Thanks.
--
- Vince
- Vince