summaryrefslogtreecommitdiffstats
path: root/win
diff options
context:
space:
mode:
authordavygrvy <davygrvy@pobox.com>2003-12-12 00:59:09 (GMT)
committerdavygrvy <davygrvy@pobox.com>2003-12-12 00:59:09 (GMT)
commit458114e4778a71b417b4c01b61dffce5d468ee72 (patch)
treed8e644d805181acb556c0ccc5f3e0bfbeb7ba962 /win
parent219acd3be327a4f050a7102dbc860217813ed7d1 (diff)
downloadtcl-458114e4778a71b417b4c01b61dffce5d468ee72.zip
tcl-458114e4778a71b417b4c01b61dffce5d468ee72.tar.gz
tcl-458114e4778a71b417b4c01b61dffce5d468ee72.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.
Diffstat (limited to 'win')
-rw-r--r--win/tclWinSock.c14
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;