diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2022-09-07 13:26:09 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2022-09-07 13:26:09 (GMT) |
commit | b9b527183ac69f9f311eff0b2dce73e289985bad (patch) | |
tree | 13e65ad5b8a131bb62c22b7ff381c154a5f7aab5 /win | |
parent | 446587dc917e9cf5f049686be2ce20822d4c22ab (diff) | |
parent | 67be0a6752a150bad176f36988e3af03f25cc4d3 (diff) | |
download | tcl-b9b527183ac69f9f311eff0b2dce73e289985bad.zip tcl-b9b527183ac69f9f311eff0b2dce73e289985bad.tar.gz tcl-b9b527183ac69f9f311eff0b2dce73e289985bad.tar.bz2 |
Merge 8.7
Diffstat (limited to 'win')
-rw-r--r-- | win/tclWinConsole.c | 90 | ||||
-rw-r--r-- | win/tclWinInit.c | 9 | ||||
-rw-r--r-- | win/tclWinSock.c | 229 | ||||
-rw-r--r-- | win/tclooConfig.sh | 2 |
4 files changed, 178 insertions, 152 deletions
diff --git a/win/tclWinConsole.c b/win/tclWinConsole.c index 23652de..753a572 100644 --- a/win/tclWinConsole.c +++ b/win/tclWinConsole.c @@ -19,8 +19,8 @@ #include <ctype.h> /* - * A general note on the design: The console channel driver differs from most - * other drivers in the following respects: + * A general note on the design: The console channel driver differs from + * most other drivers in the following respects: * * - There can be at most 3 console handles at any time since Windows does * support allocation of more than one console (with three handles @@ -35,9 +35,10 @@ * std* channels are shared amongst threads which means there can be * multiple Tcl channels corresponding to a single console handle. * - * - Even with multiple threads, more than one file event handler is unlikely. - * It does not make sense for multiple threads to register handlers for - * stdin because the input would be randomly fragmented amongst the threads. + * - Even with multiple threads, more than one file event handler is + * unlikely. It does not make sense for multiple threads to register + * handlers for stdin because the input would be randomly fragmented amongst + * the threads. * * Various design factors are driven by the above, e.g. use of lists instead * of hash tables (at most 3 console handles) and use of global instead of @@ -55,9 +56,9 @@ * because an interpreter may (for example) turn off echo for passwords and * the read ahead would come in the way of that. * - * If multiple threads are reading from stdin, the input is sprayed in random - * fashion. This is not good application design and hence no plan to address - * this (not clear what should be done even in theory) + * If multiple threads are reading from stdin, the input is sprayed in + * random fashion. This is not good application design and hence no plan to + * address this (not clear what should be done even in theory) * * For output, we do not restrict all output to the console writer threads. * See ConsoleOutputProc for the conditions. @@ -152,7 +153,7 @@ typedef struct ConsoleHandleInfo { * only from the thread owning channel EXCEPT when a console traverses it * looking for a channel that is watching for events on the console. Even * in that case, no locking is required because that access is only under - * the consoleLock lock which prevents the channel from being removed from + * the gConsoleLock lock which prevents the channel from being removed from * the gWatchingChannelList which in turn means it will not be deallocated * from under the console thread. Access to individual fields does not need * to be controlled because @@ -861,21 +862,33 @@ ConsoleCheckProc( handleInfoPtr = FindConsoleInfo(chanInfoPtr); /* Pointer is safe to access as we are holding gConsoleLock */ - if (handleInfoPtr != NULL) { - AcquireSRWLockShared(&handleInfoPtr->lock); - /* Rememebr channel is read or write, never both */ - if (chanInfoPtr->watchMask & TCL_READABLE) { - if (RingBufferLength(&handleInfoPtr->buffer) > 0 - || handleInfoPtr->lastError != ERROR_SUCCESS) { - needEvent = 1; /* Input data available or error/EOF */ - } - } else if (chanInfoPtr->watchMask & TCL_WRITABLE) { - if (RingBufferHasFreeSpace(&handleInfoPtr->buffer)) { - needEvent = 1; /* Output space available */ - } + if (handleInfoPtr == NULL) { + /* Stale event */ + continue; + } + + needEvent = 0; + AcquireSRWLockShared(&handleInfoPtr->lock); + /* Rememeber channel is read or write, never both */ + if (chanInfoPtr->watchMask & TCL_READABLE) { + if (RingBufferLength(&handleInfoPtr->buffer) > 0 + || handleInfoPtr->lastError != ERROR_SUCCESS) { + needEvent = 1; /* Input data available or error/EOF */ + } + /* + * TCL_READABLE watch means someone is looking out for data being + * available, let reader thread know. Note channel need not be + * ASYNC! (Bug [baa51423c2]) + */ + handleInfoPtr->flags |= CONSOLE_DATA_AWAITED; + WakeConditionVariable(&handleInfoPtr->consoleThreadCV); + } + else if (chanInfoPtr->watchMask & TCL_WRITABLE) { + if (RingBufferHasFreeSpace(&handleInfoPtr->buffer)) { + needEvent = 1; /* Output space available */ } - ReleaseSRWLockShared(&handleInfoPtr->lock); } + ReleaseSRWLockShared(&handleInfoPtr->lock); if (needEvent) { ConsoleEvent *evPtr = (ConsoleEvent *)ckalloc(sizeof(ConsoleEvent)); @@ -1103,12 +1116,6 @@ ConsoleInputProc( * buffered data, we will pass it up. */ if (numRead != 0) { - /* If console thread was blocked, awaken it */ - if (chanInfoPtr->flags & CONSOLE_ASYNC) { - /* Async channels always want read ahead */ - handleInfoPtr->flags |= CONSOLE_DATA_AWAITED; - WakeConditionVariable(&handleInfoPtr->consoleThreadCV); - } break; } /* @@ -1199,7 +1206,9 @@ ConsoleInputProc( /* Lock is reacquired, loop back to try again */ } - if (chanInfoPtr->flags & CONSOLE_ASYNC) { + /* We read data. Ask for more if either async or watching for reads */ + if ((chanInfoPtr->flags & CONSOLE_ASYNC) + || (chanInfoPtr->watchMask & TCL_READABLE)) { handleInfoPtr->flags |= CONSOLE_DATA_AWAITED; WakeConditionVariable(&handleInfoPtr->consoleThreadCV); } @@ -1333,7 +1342,7 @@ ConsoleOutputProc( } } - /* Lock is reacquired. Continue loop */ + /* Lock must have been reacquired before continuing loop */ } WakeConditionVariable(&handleInfoPtr->consoleThreadCV); ReleaseSRWLockExclusive(&handleInfoPtr->lock); @@ -1499,8 +1508,10 @@ ConsoleWatchProc( ConsoleHandleInfo *handleInfoPtr; handleInfoPtr = FindConsoleInfo(chanInfoPtr); if (handleInfoPtr) { + AcquireSRWLockExclusive(&handleInfoPtr->lock); handleInfoPtr->flags |= CONSOLE_DATA_AWAITED; WakeConditionVariable(&handleInfoPtr->consoleThreadCV); + ReleaseSRWLockExclusive(&handleInfoPtr->lock); } ReleaseSRWLockExclusive(&gConsoleLock); } @@ -1508,6 +1519,7 @@ ConsoleWatchProc( } else if (oldMask) { /* Remove from list of watched channels */ + AcquireSRWLockExclusive(&gConsoleLock); for (nextPtrPtr = &gWatchingChannelList, ptr = *nextPtrPtr; ptr != NULL; nextPtrPtr = &ptr->nextWatchingChannelPtr, ptr = *nextPtrPtr) { @@ -1516,6 +1528,7 @@ ConsoleWatchProc( break; } } + ReleaseSRWLockExclusive(&gConsoleLock); } } @@ -1571,7 +1584,7 @@ ConsoleGetHandleProc( static int ConsoleDataAvailable (HANDLE consoleHandle) { - INPUT_RECORD input[5]; + INPUT_RECORD input[10]; DWORD count; DWORD i; @@ -1583,11 +1596,17 @@ ConsoleGetHandleProc( == FALSE) { return -1; } + /* + * Even if windows size and mouse events are disabled, can still have + * events other than keyboard, like focus events. Look for at least one + * keydown event because a trailing LF keyup is always present from the + * last input. However, if our buffer is full, assume there is a key + * down somewhere in the unread buffer. I suppose we could expand the + * buffer but not worth... + */ + if (count == (sizeof(input)/sizeof(input[0]))) + return 1; for (i = 0; i < count; ++i) { - /* - * Event must be a keydown because a trailing LF keyup event is always - * present for line based input. - */ if (input[i].EventType == KEY_EVENT && input[i].Event.KeyEvent.bKeyDown) { return 1; @@ -1984,6 +2003,7 @@ AllocateConsoleHandleInfo( handleInfoPtr = (ConsoleHandleInfo *)ckalloc(sizeof(*handleInfoPtr)); + memset(handleInfoPtr, 0, sizeof(*handleInfoPtr)); handleInfoPtr->console = consoleHandle; InitializeSRWLock(&handleInfoPtr->lock); InitializeConditionVariable(&handleInfoPtr->consoleThreadCV); diff --git a/win/tclWinInit.c b/win/tclWinInit.c index fdeb0aa..8fa176b 100644 --- a/win/tclWinInit.c +++ b/win/tclWinInit.c @@ -527,7 +527,14 @@ TclpSetVariables( Tcl_SetVar2(interp, "env", "HOME", Tcl_DStringValue(&ds), TCL_GLOBAL_ONLY); } else { - Tcl_SetVar2(interp, "env", "HOME", "c:\\", TCL_GLOBAL_ONLY); + /* None of HOME, HOMEDRIVE, HOMEPATH exists. Try USERPROFILE */ + ptr = Tcl_GetVar2(interp, "env", "USERPROFILE", TCL_GLOBAL_ONLY); + if (ptr != NULL && ptr[0]) { + Tcl_SetVar2(interp, "env", "HOME", ptr, TCL_GLOBAL_ONLY); + } else { + /* Last resort */ + Tcl_SetVar2(interp, "env", "HOME", "c:\\", TCL_GLOBAL_ONLY); + } } } diff --git a/win/tclWinSock.c b/win/tclWinSock.c index e806423..f85e444 100644 --- a/win/tclWinSock.c +++ b/win/tclWinSock.c @@ -125,8 +125,6 @@ typedef struct TcpFdList { struct TcpState { Tcl_Channel channel; /* Channel associated with this socket. */ - int testFlags; /* bit field for tests. Is set by testsocket - * test procedure */ struct TcpFdList *sockets; /* Windows SOCKET handle. */ int flags; /* Bit field comprised of the flags described * below. */ @@ -149,7 +147,7 @@ struct TcpState { * protected by semaphore */ Tcl_TcpAcceptProc *acceptProc; /* Proc to call on accept. */ - ClientData acceptProcData; /* The data for the accept proc. */ + void *acceptProcData; /* The data for the accept proc. */ /* * Only needed for client sockets @@ -167,6 +165,8 @@ struct TcpState { * Access must be protected by semaphore */ struct TcpState *nextPtr; /* The next socket on the per-thread socket * list. */ + int testFlags; /* bit field for tests. Is set by testsocket + * test procedure */ }; /* @@ -245,7 +245,7 @@ static int TcpConnect(Tcl_Interp *interp, TcpState *state); static void InitSockets(void); static TcpState * NewSocketInfo(SOCKET socket); -static void SocketExitHandler(ClientData clientData); +static void SocketExitHandler(void *clientData); static LRESULT CALLBACK SocketProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam); static int SocketsEnabled(void); @@ -256,7 +256,7 @@ static int WaitForSocketEvent(TcpState *statePtr, int events, static void AddSocketInfoFd(TcpState *statePtr, SOCKET socket); static int FindFDInList(TcpState *statePtr, SOCKET socket); static DWORD WINAPI SocketThread(LPVOID arg); -static void TcpThreadActionProc(ClientData instanceData, +static void TcpThreadActionProc(void *instanceData, int action); static Tcl_EventCheckProc SocketCheckProc; @@ -392,8 +392,8 @@ InitializeHostName( Tcl_DStringSetLength(&inDs, 256); if (gethostname(Tcl_DStringValue(&inDs), Tcl_DStringLength(&inDs)) == 0) { - Tcl_ExternalToUtfDString(NULL, Tcl_DStringValue(&inDs), TCL_INDEX_NONE, - &ds); + Tcl_ExternalToUtfDString(NULL, Tcl_DStringValue(&inDs), + TCL_INDEX_NONE, &ds); } Tcl_DStringFree(&inDs); } @@ -466,7 +466,7 @@ TclpHasSockets( } if (interp != NULL) { Tcl_SetObjResult(interp, Tcl_NewStringObj( - "sockets are not available on this system", -1)); + "sockets are not available on this system", TCL_INDEX_NONE)); } return TCL_ERROR; } @@ -548,7 +548,7 @@ TclpFinalizeSockets(void) static int TcpBlockModeProc( - ClientData instanceData, /* Socket state. */ + void *instanceData, /* Socket state. */ int mode) /* The mode to set. Can be one of * TCL_MODE_BLOCKING or * TCL_MODE_NONBLOCKING. */ @@ -558,7 +558,7 @@ TcpBlockModeProc( if (mode == TCL_MODE_NONBLOCKING) { SET_BITS(statePtr->flags, TCP_NONBLOCKING); } else { - CLEAR_BITS(statePtr->flags, TCP_NONBLOCKING); + CLEAR_BITS(statePtr->flags, TCP_NONBLOCKING); } return 0; } @@ -589,7 +589,7 @@ TcpBlockModeProc( * * Side effects: * Processes socket events off the system queue. May process - * asynchroneous connect. + * asynchronous connect. * *---------------------------------------------------------------------- */ @@ -656,13 +656,13 @@ WaitForConnect( WaitForSingleObject(tsdPtr->socketListLock, INFINITE); /* - * Check for connect event. - */ + * Check for connect event. + */ if (GOT_BITS(statePtr->readyEvents, FD_CONNECT)) { /* - * Consume the connect event. - */ + * Consume the connect event. + */ CLEAR_BITS(statePtr->readyEvents, FD_CONNECT); @@ -677,8 +677,8 @@ WaitForConnect( } /* - * Free list lock. - */ + * Free list lock. + */ SetEvent(tsdPtr->socketListLock); @@ -690,8 +690,8 @@ WaitForConnect( result = TcpConnect(NULL, statePtr); /* - * Restore event service mode. - */ + * Restore event service mode. + */ (void) Tcl_SetServiceMode(oldMode); @@ -779,7 +779,7 @@ WaitForConnect( static int TcpInputProc( - ClientData instanceData, /* Socket state. */ + void *instanceData, /* Socket state. */ char *buf, /* Where to store data read. */ int bufSize, /* How much space is available in the * buffer? */ @@ -834,9 +834,9 @@ TcpInputProc( SendSelectMessage(tsdPtr, UNSELECT, statePtr); /* - * Single fd operation: this proc is only called for a connected - * socket. - */ + * Single fd operation: this proc is only called for a connected + * socket. + */ bytesRead = recv(statePtr->sockets->fd, buf, bufSize, 0); CLEAR_BITS(statePtr->readyEvents, FD_READ); @@ -881,7 +881,7 @@ TcpInputProc( */ if (GOT_BITS(statePtr->flags, TCP_NONBLOCKING) - || (error != WSAEWOULDBLOCK)) { + || (error != WSAEWOULDBLOCK)) { Tcl_WinConvertError(error); *errorCodePtr = Tcl_GetErrno(); bytesRead = -1; @@ -923,7 +923,7 @@ TcpInputProc( static int TcpOutputProc( - ClientData instanceData, /* Socket state. */ + void *instanceData, /* Socket state. */ const char *buf, /* The data buffer. */ int toWrite, /* How many bytes to write? */ int *errorCodePtr) /* Where to store error code. */ @@ -960,9 +960,9 @@ TcpOutputProc( SendSelectMessage(tsdPtr, UNSELECT, statePtr); /* - * Single fd operation: this proc is only called for a connected - * socket. - */ + * Single fd operation: this proc is only called for a connected + * socket. + */ written = send(statePtr->sockets->fd, buf, toWrite, 0); if (written != SOCKET_ERROR) { @@ -1038,7 +1038,7 @@ TcpOutputProc( static int TcpCloseProc( - ClientData instanceData, /* The socket to close. */ + void *instanceData, /* The socket to close. */ TCL_UNUSED(Tcl_Interp *)) { TcpState *statePtr = (TcpState *)instanceData; @@ -1088,16 +1088,16 @@ TcpCloseProc( if (tsdPtr->pendingTcpState != NULL && tsdPtr->pendingTcpState == statePtr) { /* - * Get infoPtr lock, because this concerns the notifier thread. - */ + * Get infoPtr lock, because this concerns the notifier thread. + */ WaitForSingleObject(tsdPtr->socketListLock, INFINITE); tsdPtr->pendingTcpState = NULL; /* - * Free list lock. - */ + * Free list lock. + */ SetEvent(tsdPtr->socketListLock); } @@ -1132,7 +1132,7 @@ TcpCloseProc( static int TcpClose2Proc( - ClientData instanceData, /* The socket to close. */ + void *instanceData, /* The socket to close. */ Tcl_Interp *interp, /* For error reporting. */ int flags) /* Flags that indicate which side to close. */ { @@ -1182,7 +1182,7 @@ TcpClose2Proc( static int TcpSetOptionProc( - ClientData instanceData, /* Socket state. */ + void *instanceData, /* Socket state. */ Tcl_Interp *interp, /* For error reporting - can be NULL. */ const char *optionName, /* Name of the option to set. */ TCL_UNUSED(const char *) /*value*/) /* New value for option. */ @@ -1287,7 +1287,7 @@ TcpSetOptionProc( static int TcpGetOptionProc( - ClientData instanceData, /* Socket state. */ + void *instanceData, /* Socket state. */ Tcl_Interp *interp, /* For error reporting - can be NULL. */ const char *optionName, /* Name of the option to retrieve the value * for, or NULL to get all options and their @@ -1335,8 +1335,8 @@ TcpGetOptionProc( if ((len > 1) && (optionName[1] == 'e') && (strncmp(optionName, "-error", len) == 0)) { /* - * Do not return any errors if async connect is running. - */ + * Do not return any errors if async connect is running. + */ if (!GOT_BITS(statePtr->flags, TCP_ASYNC_PENDING)) { if (GOT_BITS(statePtr->flags, TCP_ASYNC_FAILED)) { @@ -1383,8 +1383,7 @@ TcpGetOptionProc( if (err) { Tcl_WinConvertError(err); - Tcl_DStringAppend(dsPtr, Tcl_ErrnoMsg(Tcl_GetErrno()), - -1); + Tcl_DStringAppend(dsPtr, Tcl_ErrnoMsg(Tcl_GetErrno()), -1); } } } @@ -1400,7 +1399,7 @@ TcpGetOptionProc( } if (interp != NULL - && Tcl_GetVar2(interp, SUPPRESS_RDNS_VAR, NULL, 0) != NULL) { + && Tcl_GetVar(interp, SUPPRESS_RDNS_VAR, 0) != NULL) { reverseDNS = NI_NUMERICHOST; } @@ -1421,7 +1420,7 @@ TcpGetOptionProc( return TCL_OK; } } else if (getpeername(sock, (LPSOCKADDR) &(peername.sa), - &size) == 0) { + &size) == 0) { /* * Peername fetch succeeded - output list */ @@ -1479,7 +1478,7 @@ TcpGetOptionProc( * In async connect output an empty string */ - found = 1; + found = 1; } else { for (fds = statePtr->sockets; fds != NULL; fds = fds->next) { sock = fds->fd; @@ -1609,7 +1608,7 @@ TcpGetOptionProc( static void TcpWatchProc( - ClientData instanceData, /* The socket state. */ + void *instanceData, /* The socket state. */ int mask) /* Events of interest; an OR-ed combination of * TCL_READABLE, TCL_WRITABLE and * TCL_EXCEPTION. */ @@ -1663,9 +1662,9 @@ TcpWatchProc( static int TcpGetHandleProc( - ClientData instanceData, /* The socket state. */ + void *instanceData, /* The socket state. */ TCL_UNUSED(int) /*direction*/, - ClientData *handlePtr) /* Where to store the handle. */ + void **handlePtr) /* Where to store the handle. */ { TcpState *statePtr = (TcpState *)instanceData; @@ -1732,9 +1731,9 @@ TcpConnect( for (statePtr->addr = statePtr->addrlist; statePtr->addr != NULL; statePtr->addr = statePtr->addr->ai_next) { - for (statePtr->myaddr = statePtr->myaddrlist; - statePtr->myaddr != NULL; - statePtr->myaddr = statePtr->myaddr->ai_next) { + for (statePtr->myaddr = statePtr->myaddrlist; + statePtr->myaddr != NULL; + statePtr->myaddr = statePtr->myaddr->ai_next) { /* * No need to try combinations of local and remote addresses * of different families. @@ -1754,8 +1753,8 @@ TcpConnect( } /* - * Get statePtr lock. - */ + * Get statePtr lock. + */ WaitForSingleObject(tsdPtr->socketListLock, INFINITE); @@ -1767,17 +1766,17 @@ TcpConnect( Tcl_SetErrno(0); statePtr->sockets->fd = socket(statePtr->myaddr->ai_family, - SOCK_STREAM, 0); + SOCK_STREAM, 0); /* - * Free list lock. - */ + * Free list lock. + */ SetEvent(tsdPtr->socketListLock); /* - * Continue on socket creation error. - */ + * Continue on socket creation error. + */ if (statePtr->sockets->fd == INVALID_SOCKET) { Tcl_WinConvertError((DWORD) WSAGetLastError()); @@ -1790,14 +1789,14 @@ TcpConnect( */ SetHandleInformation((HANDLE) statePtr->sockets->fd, - HANDLE_FLAG_INHERIT, 0); + HANDLE_FLAG_INHERIT, 0); /* * Set kernel space buffering */ TclSockMinimumBuffers((void *) statePtr->sockets->fd, - TCP_BUFFER_SIZE); + TCP_BUFFER_SIZE); /* * Try to bind to a local port. @@ -1810,7 +1809,7 @@ TcpConnect( } /* - * For asynchroneous connect set the socket in nonblocking mode + * For asynchronous connect set the socket in nonblocking mode * and activate connect notification */ @@ -1819,8 +1818,8 @@ TcpConnect( int in_socket_list = 0; /* - * Get statePtr lock. - */ + * Get statePtr lock. + */ WaitForSingleObject(tsdPtr->socketListLock, INFINITE); @@ -1848,7 +1847,7 @@ TcpConnect( /* * Set connect mask to connect events - * + * * This is activated by a SOCKET_SELECT message to the * notifier thread. */ @@ -1861,9 +1860,9 @@ TcpConnect( SetEvent(tsdPtr->socketListLock); - /* - * Activate accept notification. - */ + /* + * Activate accept notification. + */ SendSelectMessage(tsdPtr, SELECT, statePtr); } @@ -1899,33 +1898,33 @@ TcpConnect( CLEAR_BITS(statePtr->flags, TCP_ASYNC_PENDING); /* - * Get statePtr lock. - */ + * Get statePtr lock. + */ WaitForSingleObject(tsdPtr->socketListLock, INFINITE); /* - * Get signaled connect error. - */ + * Get signaled connect error. + */ Tcl_WinConvertError((DWORD) statePtr->notifierConnectError); /* - * Clear eventual connect flag. - */ + * Clear eventual connect flag. + */ CLEAR_BITS(statePtr->selectEvents, FD_CONNECT); /* - * Free list lock. - */ + * Free list lock. + */ SetEvent(tsdPtr->socketListLock); } /* * Clear the tsd socket list pointer if we did not wait for - * the FD_CONNECT asynchroneously + * the FD_CONNECT asynchronously */ tsdPtr->pendingTcpState = NULL; @@ -1977,32 +1976,32 @@ TcpConnect( statePtr->selectEvents = FD_WRITE|FD_READ; /* - * Get statePtr lock. - */ + * Get statePtr lock. + */ WaitForSingleObject(tsdPtr->socketListLock, INFINITE); /* - * Signal ready readable and writable events. - */ + * Signal ready readable and writable events. + */ SET_BITS(statePtr->readyEvents, FD_WRITE | FD_READ); /* - * Flag error to event routine. - */ + * Flag error to event routine. + */ SET_BITS(statePtr->flags, TCP_ASYNC_FAILED); /* - * Save connect error to be reported by 'fconfigure -error'. - */ + * Save connect error to be reported by 'fconfigure -error'. + */ statePtr->connectError = Tcl_GetErrno(); /* - * Free list lock. - */ + * Free list lock. + */ SetEvent(tsdPtr->socketListLock); } @@ -2133,7 +2132,7 @@ Tcl_OpenTcpClient( Tcl_Channel Tcl_MakeTcpClientChannel( - ClientData sock) /* The socket to wrap up into a channel. */ + void *sock) /* The socket to wrap up into a channel. */ { TcpState *statePtr; char channelName[SOCK_CHAN_LENGTH]; @@ -2193,7 +2192,7 @@ Tcl_OpenTcpServerEx( Tcl_TcpAcceptProc *acceptProc, /* Callback for accepting connections from new * clients. */ - ClientData acceptProcData) /* Data for the callback. */ + void *acceptProcData) /* Data for the callback. */ { SOCKET sock = INVALID_SOCKET; unsigned short chosenport = 0; @@ -2229,7 +2228,7 @@ Tcl_OpenTcpServerEx( } if (!TclCreateSocketAddress(interp, &addrlist, myHost, port, 1, - &errorMsg)) { + &errorMsg)) { goto error; } @@ -2287,7 +2286,7 @@ Tcl_OpenTcpServerEx( */ if (bind(sock, addrPtr->ai_addr, - addrPtr->ai_addrlen) == SOCKET_ERROR) { + addrPtr->ai_addrlen) == SOCKET_ERROR) { Tcl_WinConvertError((DWORD) WSAGetLastError()); closesocket(sock); continue; @@ -2489,7 +2488,7 @@ InitSockets(void) windowClass.style = 0; windowClass.cbClsExtra = 0; windowClass.cbWndExtra = 0; - windowClass.hInstance = TclWinGetTclInstance(); + windowClass.hInstance = (HINSTANCE)TclWinGetTclInstance(); windowClass.hbrBackground = NULL; windowClass.lpszMenuName = NULL; windowClass.lpszClassName = className; @@ -2610,7 +2609,7 @@ SocketsEnabled(void) static void SocketExitHandler( - TCL_UNUSED(ClientData)) + TCL_UNUSED(void *)) { Tcl_MutexLock(&socketMutex); @@ -2620,7 +2619,7 @@ SocketExitHandler( */ TclpFinalizeSockets(); - UnregisterClassW(className, TclWinGetTclInstance()); + UnregisterClassW(className, (HINSTANCE)TclWinGetTclInstance()); initialized = 0; Tcl_MutexUnlock(&socketMutex); } @@ -2644,7 +2643,7 @@ SocketExitHandler( void SocketSetupProc( - TCL_UNUSED(ClientData), + TCL_UNUSED(void *), int flags) /* Event flags as passed to Tcl_DoOneEvent. */ { TcpState *statePtr; @@ -2662,7 +2661,7 @@ SocketSetupProc( for (statePtr = tsdPtr->socketList; statePtr != NULL; statePtr = statePtr->nextPtr) { if (GOT_BITS(statePtr->readyEvents, - statePtr->watchEvents | FD_CONNECT | FD_ACCEPT)) { + statePtr->watchEvents | FD_CONNECT | FD_ACCEPT)) { Tcl_SetMaxBlockTime(&blockTime); break; } @@ -2689,7 +2688,7 @@ SocketSetupProc( static void SocketCheckProc( - TCL_UNUSED(ClientData), + TCL_UNUSED(void *), int flags) /* Event flags as passed to Tcl_DoOneEvent. */ { TcpState *statePtr; @@ -2819,19 +2818,19 @@ SocketEventProc( if (GOT_BITS(statePtr->readyEvents, FD_ACCEPT)) { for (fds = statePtr->sockets; fds != NULL; fds = fds->next) { /* - * Accept the incoming connection request. - */ + * Accept the incoming connection request. + */ len = sizeof(address); newSocket = accept(fds->fd, &(addr.sa), &len); /* - * On Tcl server sockets with multiple OS fds we loop over the fds + * On Tcl server sockets with multiple OS fds we loop over the fds * trying an accept() on each, so we expect INVALID_SOCKET. There * are also other network stack conditions that can result in * FD_ACCEPT but a subsequent failure on accept() by the time we * get around to it. - * + * * Access to sockets (acceptEventCount, readyEvents) in socketList * is still protected by the lock (prevents reintroduction of * SF Tcl Bug 3056775. @@ -2857,7 +2856,7 @@ SocketEventProc( SetEvent(tsdPtr->socketListLock); /* - * Caution: TcpAccept() has the side-effect of evaluating the + * Caution: TcpAccept() has the side-effect of evaluating the * server accept script (via AcceptCallbackProc() in tclIOCmd.c), * which can close the server socket and invalidate statePtr and * fds. If TcpAccept() accepts a socket we must return immediately @@ -2869,7 +2868,7 @@ SocketEventProc( } /* - * Loop terminated with no sockets accepted; clear the ready mask so + * Loop terminated with no sockets accepted; clear the ready mask so * we can detect the next connection request. Note that connection * requests are level triggered, so if there is a request already * pending, a new event will be generated. @@ -2985,15 +2984,15 @@ AddSocketInfoFd( if (fds == NULL) { /* - * Add the first FD. - */ + * Add the first FD. + */ statePtr->sockets = (TcpFdList *)ckalloc(sizeof(TcpFdList)); fds = statePtr->sockets; } else { /* - * Find end of list and append FD. - */ + * Find end of list and append FD. + */ while (fds->next != NULL) { fds = fds->next; @@ -3094,34 +3093,34 @@ WaitForSocketEvent( int event_found; /* - * Get statePtr lock. - */ + * Get statePtr lock. + */ WaitForSingleObject(tsdPtr->socketListLock, INFINITE); /* - * Check if event occured. - */ + * Check if event occured. + */ event_found = GOT_BITS(statePtr->readyEvents, events); /* - * Free list lock. - */ + * Free list lock. + */ SetEvent(tsdPtr->socketListLock); /* - * Exit loop if event occured. - */ + * Exit loop if event occured. + */ if (event_found) { break; } /* - * Exit loop if event did not occur but this is a non-blocking channel - */ + * Exit loop if event did not occur but this is a non-blocking channel + */ if (statePtr->flags & TCP_NONBLOCKING) { *errorCodePtr = EWOULDBLOCK; @@ -3472,7 +3471,7 @@ TclWinGetServByName( static void TcpThreadActionProc( - ClientData instanceData, + void *instanceData, int action) { ThreadSpecificData *tsdPtr; diff --git a/win/tclooConfig.sh b/win/tclooConfig.sh index 4c2068c..a400b5b 100644 --- a/win/tclooConfig.sh +++ b/win/tclooConfig.sh @@ -16,4 +16,4 @@ TCLOO_STUB_LIB_SPEC="" TCLOO_INCLUDE_SPEC="" TCLOO_PRIVATE_INCLUDE_SPEC="" TCLOO_CFLAGS="" -TCLOO_VERSION=1.2.0 +TCLOO_VERSION=1.3 |