From ddb6d460589930ed73cc8b92cebc714b9021946f Mon Sep 17 00:00:00 2001 From: davygrvy Date: Thu, 6 May 2004 01:03:56 +0000 Subject: * win/tclWinSock.c: (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. (SocketEventProc) : connect errors should fire both the readable and writable handlers because this is how it works on UNIX [Bug 794839] --- win/tclWinSock.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/win/tclWinSock.c b/win/tclWinSock.c index 4586698..3d0d5f0 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.36.2.1 2003/10/23 16:24:42 andreas_kupries Exp $ + * RCS: @(#) $Id: tclWinSock.c,v 1.36.2.2 2004/05/06 01:03:56 davygrvy Exp $ */ #include "tclWinInt.h" @@ -627,13 +627,14 @@ SocketThreadExitHandler(clientData) GetExitCodeThread(tsdPtr->socketThread, &exitCode); if (exitCode == STILL_ACTIVE) { 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. */ - WaitForSingleObject(tsdPtr->socketThread, INFINITE); + WaitForSingleObject(tsdPtr->socketThread, 100); } CloseHandle(tsdPtr->socketThread); tsdPtr->socketThread = NULL; @@ -900,6 +901,10 @@ SocketEventProc(evPtr, flags) } if (events & (FD_WRITE | FD_CONNECT)) { mask |= TCL_WRITABLE; + if (events & FD_CONNECT && infoPtr->lastError != NO_ERROR) { + /* connect errors should also fire the readable handler. */ + mask |= TCL_READABLE; + } } if (mask) { -- cgit v0.12