summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2022-09-08 14:14:08 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2022-09-08 14:14:08 (GMT)
commitd2ed22d022756475d85c538b38cfe0c4fe4679e8 (patch)
treeafc16b8477cada11063d99fcf7ffff8218b48ab1
parent4c66b6ec4315475b1a2b49380da00926a9c4fbb6 (diff)
parent607e3a5ba3c721c845b29c89db243882f25c5ba5 (diff)
downloadtcl-d2ed22d022756475d85c538b38cfe0c4fe4679e8.zip
tcl-d2ed22d022756475d85c538b38cfe0c4fe4679e8.tar.gz
tcl-d2ed22d022756475d85c538b38cfe0c4fe4679e8.tar.bz2
Merge 8.7
-rw-r--r--generic/tclTest.c17
-rw-r--r--unix/tclUnixSock.c13
-rw-r--r--win/tclWinSock.c15
3 files changed, 21 insertions, 24 deletions
diff --git a/generic/tclTest.c b/generic/tclTest.c
index a745ef0..f038817 100644
--- a/generic/tclTest.c
+++ b/generic/tclTest.c
@@ -91,8 +91,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)
@@ -6401,6 +6400,10 @@ TestChannelEventCmd(
*----------------------------------------------------------------------
*/
+#define TCP_ASYNC_TEST_MODE (1<<8) /* Async testing activated. Do not
+ * automatically continue connection
+ * process. */
+
static int
TestSocketCmd(
TCL_UNUSED(void *),
@@ -6422,6 +6425,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
*/
@@ -6443,7 +6447,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;
}
diff --git a/unix/tclUnixSock.c b/unix/tclUnixSock.c
index 3cc0c8b..da26e52 100644
--- a/unix/tclUnixSock.c
+++ b/unix/tclUnixSock.c
@@ -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 */
/*
@@ -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 */
};
/*
@@ -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. */
@@ -468,7 +461,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;
diff --git a/win/tclWinSock.c b/win/tclWinSock.c
index 3a9ebf7..660c8d1 100644
--- a/win/tclWinSock.c
+++ b/win/tclWinSock.c
@@ -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. */
@@ -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 */
};
/*
@@ -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 */
@@ -626,7 +619,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;
@@ -1319,7 +1312,7 @@ TcpGetOptionProc(
* below.
*/
- if (!GOT_BITS(statePtr->testFlags, TCP_ASYNC_TEST_MODE)) {
+ if (!GOT_BITS(statePtr->flags, TCP_ASYNC_TEST_MODE)) {
WaitForConnect(statePtr, NULL);
}