From 458114e4778a71b417b4c01b61dffce5d468ee72 Mon Sep 17 00:00:00 2001 From: davygrvy Date: Fri, 12 Dec 2003 00:59:09 +0000 Subject: (SocketThreadExitHandler) : added a TerminateThread fallback just in case the socket handler thread is really in a paused state. This can happen when Tcl is being unloaded by the OS from an exception handler. --- win/tclWinSock.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/win/tclWinSock.c b/win/tclWinSock.c index c925255..91236cb 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.39 2003/10/23 16:28:19 andreas_kupries Exp $ + * RCS: @(#) $Id: tclWinSock.c,v 1.40 2003/12/12 00:59:09 davygrvy Exp $ */ #include "tclWinInt.h" @@ -626,6 +626,7 @@ SocketThreadExitHandler(clientData) GetExitCodeThread(tsdPtr->socketThread, &exitCode); if (exitCode == STILL_ACTIVE) { + DWORD dwWait; PostMessage(tsdPtr->hwnd, SOCKET_TERMINATE, 0, 0); /* @@ -633,7 +634,16 @@ SocketThreadExitHandler(clientData) * completely cleaned up before we leave this function. */ - WaitForSingleObject(tsdPtr->socketThread, INFINITE); + 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); + } } CloseHandle(tsdPtr->socketThread); tsdPtr->socketThread = NULL; -- cgit v0.12