Skip to content

Commit

Permalink
Merge 8.7
Browse files Browse the repository at this point in the history
  • Loading branch information
jan.nijtmans committed Sep 8, 2022
2 parents 0fc5061 + a9bad60 commit 79a87cf
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 24 deletions.
17 changes: 14 additions & 3 deletions generic/tclTest.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,7 @@ typedef struct TcpState TcpState;

struct TcpState {
Tcl_Channel channel; /* Channel associated with this socket. */
int testFlags; /* bit field for tests. Is set by testsocket
* test procedure */
int flags; /* ORed combination of various bitfields. */
};

TCL_DECLARE_MUTEX(asyncTestMutex)
Expand Down Expand Up @@ -6481,6 +6480,10 @@ TestChannelEventCmd(
*----------------------------------------------------------------------
*/

#define TCP_ASYNC_TEST_MODE (1<<8) /* Async testing activated. Do not
* automatically continue connection
* process. */

static int
TestSocketCmd(
TCL_UNUSED(void *),
Expand All @@ -6502,6 +6505,7 @@ TestSocketCmd(
if ((cmdName[0] == 't') && (strncmp(cmdName, "testflags", len) == 0)) {
Tcl_Channel hChannel;
int modePtr;
int testMode;
TcpState *statePtr;
/* Set test value in the socket driver
*/
Expand All @@ -6523,7 +6527,14 @@ TestSocketCmd(
NULL);
return TCL_ERROR;
}
statePtr->testFlags = atoi(argv[3]);
if (Tcl_GetBoolean(interp, argv[3], &testMode) != TCL_OK) {
return TCL_ERROR;
}
if (testMode) {
statePtr->flags |= TCP_ASYNC_TEST_MODE;
} else {
statePtr->flags &= ~TCP_ASYNC_TEST_MODE;
}
return TCL_OK;
}

Expand Down
13 changes: 3 additions & 10 deletions unix/tclUnixSock.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ typedef struct TcpFdList {

struct TcpState {
Tcl_Channel channel; /* Channel associated with this file. */
TcpFdList fds; /* The file descriptors of the sockets. */
int flags; /* ORed combination of the bitfields defined
* below. */
TcpFdList fds; /* The file descriptors of the sockets. */
int interest; /* Event types of interest */

/*
Expand All @@ -78,8 +78,6 @@ struct TcpState {
* an async socket is not yet connected. */
int connectError; /* Cache SO_ERROR of async socket. */
int cachedBlocking; /* Cache blocking mode of async socket. */
int testFlags; /* bit field for tests. Is set by testsocket
* test procedure */
};

/*
Expand All @@ -95,12 +93,7 @@ struct TcpState {
* still pending */
#define TCP_ASYNC_FAILED (1<<5) /* An async connect finally failed */

/*
* These bits may be ORed together into the "testFlags" field of a TcpState
* structure.
*/

#define TCP_ASYNC_TEST_MODE (1<<0) /* Async testing activated. Do not
#define TCP_ASYNC_TEST_MODE (1<<8) /* Async testing activated. Do not
* automatically continue connection
* process. */

Expand Down Expand Up @@ -471,7 +464,7 @@ WaitForConnect(
* (errorCodePtr != NULL && !GOT_BITS(flags, TCP_NONBLOCKING))
*/

if (GOT_BITS(statePtr->testFlags, TCP_ASYNC_TEST_MODE)
if (GOT_BITS(statePtr->flags, TCP_ASYNC_TEST_MODE)
&& !(errorCodePtr != NULL
&& !GOT_BITS(statePtr->flags, TCP_NONBLOCKING))) {
*errorCodePtr = EWOULDBLOCK;
Expand Down
15 changes: 4 additions & 11 deletions win/tclWinSock.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,9 @@ typedef struct TcpFdList {

struct TcpState {
Tcl_Channel channel; /* Channel associated with this socket. */
struct TcpFdList *sockets; /* Windows SOCKET handle. */
int flags; /* Bit field comprised of the flags described
* below. */
struct TcpFdList *sockets; /* Windows SOCKET handle. */
int watchEvents; /* OR'ed combination of FD_READ, FD_WRITE,
* FD_CLOSE, FD_ACCEPT and FD_CONNECT that
* indicate which events are interesting. */
Expand Down Expand Up @@ -165,8 +165,6 @@ 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 */
};

/*
Expand All @@ -186,12 +184,7 @@ struct TcpState {
* still pending */
#define TCP_ASYNC_FAILED (1<<5) /* An async connect finally failed */

/*
* These bits may be ORed together into the "testFlags" field of a TcpState
* structure.
*/

#define TCP_ASYNC_TEST_MODE (1<<0) /* Async testing activated. Do not
#define TCP_ASYNC_TEST_MODE (1<<8) /* Async testing activated. Do not
* automatically continue connection
* process */

Expand Down Expand Up @@ -630,7 +623,7 @@ WaitForConnect(
* - Call by the event queue (errorCodePtr == NULL)
*/

if (GOT_BITS(statePtr->testFlags, TCP_ASYNC_TEST_MODE)
if (GOT_BITS(statePtr->flags, TCP_ASYNC_TEST_MODE)
&& errorCodePtr != NULL
&& GOT_BITS(statePtr->flags, TCP_NONBLOCKING)) {
*errorCodePtr = EWOULDBLOCK;
Expand Down Expand Up @@ -1323,7 +1316,7 @@ TcpGetOptionProc(
* below.
*/

if (!GOT_BITS(statePtr->testFlags, TCP_ASYNC_TEST_MODE)) {
if (!GOT_BITS(statePtr->flags, TCP_ASYNC_TEST_MODE)) {
WaitForConnect(statePtr, NULL);
}

Expand Down

0 comments on commit 79a87cf

Please sign in to comment.