From c7af0f6068720e7d18a61e75a17712373d39b1bc Mon Sep 17 00:00:00 2001 From: davygrvy Date: Sat, 21 Feb 2004 02:17:31 +0000 Subject: (SocketThreadExitHandler): Don't call TerminateThread when WaitForSingleObject returns a timeout. Tcl_Finalize called from DllMain will pause all threads. Trust that the thread will get the close notice at a later time if it does ever wake up before being cleaned up by the system anyway. --- win/tclWinSock.c | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/win/tclWinSock.c b/win/tclWinSock.c index a790b31..b52b4f3 100644 --- a/win/tclWinSock.c +++ b/win/tclWinSock.c @@ -8,7 +8,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclWinSock.c,v 1.41 2003/12/24 04:18:23 davygrvy Exp $ + * RCS: @(#) $Id: tclWinSock.c,v 1.42 2004/02/21 02:17:31 davygrvy Exp $ */ #include "tclWinInt.h" @@ -626,24 +626,15 @@ SocketThreadExitHandler(clientData) GetExitCodeThread(tsdPtr->socketThread, &exitCode); if (exitCode == STILL_ACTIVE) { - DWORD dwWait; PostMessage(tsdPtr->hwnd, SOCKET_TERMINATE, 0, 0); - /* * Wait for the thread to close. This ensures that we are - * completely cleaned up before we leave this function. + * completely cleaned up before we leave this function. + * If Tcl_Finalize was called from DllMain, the thread + * is in a paused state so we need to timeout and continue. */ - dwWait = WaitForSingleObject(tsdPtr->socketThread, 100); - if (dwWait == WAIT_TIMEOUT) { - /* - * Avoids a lock-up, just in case it is needed from an - * unclean exit condition when the thread appears - * running, but isn't. - */ - - TerminateThread(tsdPtr->socketThread, EXIT_FAILURE); - } + WaitForSingleObject(tsdPtr->socketThread, 100); } CloseHandle(tsdPtr->socketThread); tsdPtr->socketThread = NULL; -- cgit v0.12