diff options
author | davygrvy <davygrvy@noemail.net> | 2003-12-12 00:59:08 (GMT) |
---|---|---|
committer | davygrvy <davygrvy@noemail.net> | 2003-12-12 00:59:08 (GMT) |
commit | 20a20f2b5d9e43c00ebec676b9a82f425246910d (patch) | |
tree | d8e644d805181acb556c0ccc5f3e0bfbeb7ba962 /win | |
parent | e8644fb01506b0d6ccd276b2c93a2a67ed39bcb5 (diff) | |
download | tcl-20a20f2b5d9e43c00ebec676b9a82f425246910d.zip tcl-20a20f2b5d9e43c00ebec676b9a82f425246910d.tar.gz tcl-20a20f2b5d9e43c00ebec676b9a82f425246910d.tar.bz2 |
(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.
FossilOrigin-Name: ebde28db0175a5f04b93bae1f6820b8576b36ace
Diffstat (limited to 'win')
-rw-r--r-- | win/tclWinSock.c | 14 |
1 files 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; |