diff options
author | redman <redman> | 1999-08-01 22:09:25 (GMT) |
---|---|---|
committer | redman <redman> | 1999-08-01 22:09:25 (GMT) |
commit | 82389cfbf44c58aa0eacc14452ff199223e1cb99 (patch) | |
tree | 8d71976eeb6df6fa19ee8f376f9f6b8a9f70f39e /win | |
parent | 920d13e1cc6f72c3725509e4bbb26097c546a5ae (diff) | |
download | tcl-82389cfbf44c58aa0eacc14452ff199223e1cb99.zip tcl-82389cfbf44c58aa0eacc14452ff199223e1cb99.tar.gz tcl-82389cfbf44c58aa0eacc14452ff199223e1cb99.tar.bz2 |
* win/tclWinSock.c: Added comment block to SocketThread()
function. Added code to avoid calling TerminateThread(), but
instead to send a message to the socket event window to tell it to
terminate its thread.
Diffstat (limited to 'win')
-rw-r--r-- | win/tclWinSock.c | 35 |
1 files changed, 27 insertions, 8 deletions
diff --git a/win/tclWinSock.c b/win/tclWinSock.c index 6f53df3..c39d8ba 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.16 1999/07/31 01:24:25 redman Exp $ + * RCS: @(#) $Id: tclWinSock.c,v 1.17 1999/08/01 22:09:29 redman Exp $ */ #include "tclWinInt.h" @@ -82,6 +82,7 @@ static struct { #define SOCKET_MESSAGE WM_USER+1 #define SOCKET_SELECT WM_USER+2 +#define SOCKET_TERMINATE WM_USER+3 #define SELECT TRUE #define UNSELECT FALSE @@ -585,19 +586,18 @@ SocketThreadExitHandler(clientData) if (tsdPtr->socketThread != NULL) { - WaitForSingleObject(tsdPtr->socketListLock, INFINITE); - Tcl_MutexLock(&socketMutex); - TerminateThread(tsdPtr->socketThread, 0); + PostMessage(tsdPtr->hwnd, SOCKET_TERMINATE, 0, 0); - /* + /* * Wait for the thread to terminate. This ensures that we are * completely cleaned up before we leave this function. */ - + WaitForSingleObject(tsdPtr->socketThread, INFINITE); + CloseHandle(tsdPtr->socketThread); CloseHandle(tsdPtr->readyEvent); CloseHandle(tsdPtr->socketListLock); - Tcl_MutexUnlock(&socketMutex); + } if (tsdPtr->hwnd != NULL) { DestroyWindow(tsdPtr->hwnd); @@ -2122,6 +2122,22 @@ TcpGetHandleProc(instanceData, direction, handlePtr) return TCL_OK; } +/* + *---------------------------------------------------------------------- + * + * SocketThread -- + * + * Helper thread used to manage the socket event handling window. + * + * Results: + * 1 if unable to create socket event window, 0 otherwise. + * + * Side effects: + * None. + * + *---------------------------------------------------------------------- + */ + static DWORD WINAPI SocketThread(LPVOID arg) { @@ -2210,7 +2226,7 @@ SocketProc(hwnd, message, wParam, lParam) * Find the specified socket on the socket list and update its * eventState flag. */ - + WaitForSingleObject(tsdPtr->socketListLock, INFINITE); for (infoPtr = tsdPtr->socketList; infoPtr != NULL; infoPtr = infoPtr->nextPtr) { @@ -2287,6 +2303,9 @@ SocketProc(hwnd, message, wParam, lParam) 0, 0); } break; + case SOCKET_TERMINATE: + ExitThread(0); + break; } return 0; |