summaryrefslogtreecommitdiffstats
path: root/unix
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2017-10-20 12:36:40 (GMT)
committerdgp <dgp@users.sourceforge.net>2017-10-20 12:36:40 (GMT)
commit336cf18ae876ce12826ad01e1836e401e582ce01 (patch)
tree26aae3f12779f4598108cbc1c7d5947403b768f9 /unix
parent08d9bb4c7c1e3b2912880a8d05f12cfab50c42e0 (diff)
parentdf974e71f99feff44f12a02e66281948465d32ec (diff)
downloadtcl-336cf18ae876ce12826ad01e1836e401e582ce01.zip
tcl-336cf18ae876ce12826ad01e1836e401e582ce01.tar.gz
tcl-336cf18ae876ce12826ad01e1836e401e582ce01.tar.bz2
Merge core-8-6-branch (execpt file win/makefile.vc)
Diffstat (limited to 'unix')
-rw-r--r--unix/Makefile.in12
-rwxr-xr-xunix/configure2
-rw-r--r--unix/configure.in2
-rw-r--r--unix/tcl.spec2
-rw-r--r--unix/tclLoadDyld.c2
-rw-r--r--unix/tclUnixPort.h8
-rw-r--r--unix/tclUnixSock.c299
-rw-r--r--unix/tclooConfig.sh2
8 files changed, 189 insertions, 140 deletions
diff --git a/unix/Makefile.in b/unix/Makefile.in
index 2fc9347..34b27b2 100644
--- a/unix/Makefile.in
+++ b/unix/Makefile.in
@@ -842,17 +842,17 @@ install-libraries: libraries
do \
$(INSTALL_DATA) $$i "$(SCRIPT_INSTALL_DIR)"/http1.0; \
done;
- @echo "Installing package http 2.8.11 as a Tcl Module";
- @$(INSTALL_DATA) $(TOP_DIR)/library/http/http.tcl "$(SCRIPT_INSTALL_DIR)"/../tcl8/8.6/http-2.8.11.tm;
+ @echo "Installing package http 2.8.12 as a Tcl Module";
+ @$(INSTALL_DATA) $(TOP_DIR)/library/http/http.tcl "$(SCRIPT_INSTALL_DIR)"/../tcl8/8.6/http-2.8.12.tm;
@echo "Installing package opt0.4 files to $(SCRIPT_INSTALL_DIR)/opt0.4/";
@for i in $(TOP_DIR)/library/opt/*.tcl ; \
do \
$(INSTALL_DATA) $$i "$(SCRIPT_INSTALL_DIR)"/opt0.4; \
done;
- @echo "Installing package msgcat 1.6.0 as a Tcl Module";
- @$(INSTALL_DATA) $(TOP_DIR)/library/msgcat/msgcat.tcl "$(SCRIPT_INSTALL_DIR)"/../tcl8/8.5/msgcat-1.6.0.tm;
- @echo "Installing package tcltest 2.4.0 as a Tcl Module";
- @$(INSTALL_DATA) $(TOP_DIR)/library/tcltest/tcltest.tcl "$(SCRIPT_INSTALL_DIR)"/../tcl8/8.5/tcltest-2.4.0.tm;
+ @echo "Installing package msgcat 1.6.1 as a Tcl Module";
+ @$(INSTALL_DATA) $(TOP_DIR)/library/msgcat/msgcat.tcl "$(SCRIPT_INSTALL_DIR)"/../tcl8/8.5/msgcat-1.6.1.tm;
+ @echo "Installing package tcltest 2.4.1 as a Tcl Module";
+ @$(INSTALL_DATA) $(TOP_DIR)/library/tcltest/tcltest.tcl "$(SCRIPT_INSTALL_DIR)"/../tcl8/8.5/tcltest-2.4.1.tm;
@echo "Installing package platform 1.0.14 as a Tcl Module";
@$(INSTALL_DATA) $(TOP_DIR)/library/platform/platform.tcl "$(SCRIPT_INSTALL_DIR)"/../tcl8/8.4/platform-1.0.14.tm;
diff --git a/unix/configure b/unix/configure
index 3e3b4c4..39076a4 100755
--- a/unix/configure
+++ b/unix/configure
@@ -1335,7 +1335,7 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
TCL_VERSION=8.6
TCL_MAJOR_VERSION=8
TCL_MINOR_VERSION=6
-TCL_PATCH_LEVEL=".6"
+TCL_PATCH_LEVEL=".7"
VERSION=${TCL_VERSION}
EXTRA_INSTALL_BINARIES=${EXTRA_INSTALL_BINARIES:-"@:"}
diff --git a/unix/configure.in b/unix/configure.in
index 1d86213..220a4aa 100644
--- a/unix/configure.in
+++ b/unix/configure.in
@@ -25,7 +25,7 @@ m4_ifdef([SC_USE_CONFIG_HEADERS], [
TCL_VERSION=8.6
TCL_MAJOR_VERSION=8
TCL_MINOR_VERSION=6
-TCL_PATCH_LEVEL=".6"
+TCL_PATCH_LEVEL=".7"
VERSION=${TCL_VERSION}
EXTRA_INSTALL_BINARIES=${EXTRA_INSTALL_BINARIES:-"@:"}
diff --git a/unix/tcl.spec b/unix/tcl.spec
index 8bf77f3..141511d 100644
--- a/unix/tcl.spec
+++ b/unix/tcl.spec
@@ -4,7 +4,7 @@
Name: tcl
Summary: Tcl scripting language development environment
-Version: 8.6.6
+Version: 8.6.7
Release: 2
License: BSD
Group: Development/Languages
diff --git a/unix/tclLoadDyld.c b/unix/tclLoadDyld.c
index 8b7dc58..e998bf9 100644
--- a/unix/tclLoadDyld.c
+++ b/unix/tclLoadDyld.c
@@ -48,7 +48,9 @@
#endif /* TCL_DYLD_USE_DLFCN */
#if TCL_DYLD_USE_NSMODULE || defined(TCL_LOAD_FROM_MEMORY)
+#if defined (__clang__) || ((__GNUC__) && ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ > 5))))
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
+#endif
#include <mach-o/dyld.h>
#include <mach-o/fat.h>
#include <mach-o/swap.h>
diff --git a/unix/tclUnixPort.h b/unix/tclUnixPort.h
index 2728957..ba56089 100644
--- a/unix/tclUnixPort.h
+++ b/unix/tclUnixPort.h
@@ -125,11 +125,11 @@ typedef off_t Tcl_SeekOffset;
# include <sys/select.h>
#endif
#include <sys/stat.h>
-#if TIME_WITH_SYS_TIME
+#ifdef TIME_WITH_SYS_TIME
# include <sys/time.h>
# include <time.h>
#else
-#if HAVE_SYS_TIME_H
+#ifdef HAVE_SYS_TIME_H
# include <sys/time.h>
#else
# include <time.h>
@@ -138,11 +138,11 @@ typedef off_t Tcl_SeekOffset;
#ifndef NO_SYS_WAIT_H
# include <sys/wait.h>
#endif
-#if HAVE_INTTYPES_H
+#ifdef HAVE_INTTYPES_H
# include <inttypes.h>
#endif
#include <limits.h>
-#if HAVE_STDINT_H
+#ifdef HAVE_STDINT_H
# include <stdint.h>
#endif
#ifdef HAVE_UNISTD_H
diff --git a/unix/tclUnixSock.c b/unix/tclUnixSock.c
index b9b6b53..e418ff0 100644
--- a/unix/tclUnixSock.c
+++ b/unix/tclUnixSock.c
@@ -19,6 +19,7 @@
#define SET_BITS(var, bits) ((var) |= (bits))
#define CLEAR_BITS(var, bits) ((var) &= ~(bits))
+#define GOT_BITS(var, bits) (((var) & (bits)) != 0)
/* "sock" + a pointer in hex + \0 */
#define SOCK_CHAN_LENGTH (4 + sizeof(void *) * 2 + 1)
@@ -117,8 +118,7 @@ struct TcpState {
* Static routines for this file:
*/
-static int TcpConnect(Tcl_Interp *interp,
- TcpState *state);
+static int TcpConnect(Tcl_Interp *interp, TcpState *state);
static void TcpAccept(ClientData data, int mask);
static int TcpBlockModeProc(ClientData data, int mode);
static int TcpCloseProc(ClientData instanceData,
@@ -173,21 +173,24 @@ static ProcessGlobalValue hostName =
#if 0
/* printf debugging */
-void printaddrinfo(struct addrinfo *addrlist, char *prefix)
+void
+printaddrinfo(
+ struct addrinfo *addrlist,
+ char *prefix)
{
char host[NI_MAXHOST], port[NI_MAXSERV];
struct addrinfo *ai;
+
for (ai = addrlist; ai != NULL; ai = ai->ai_next) {
getnameinfo(ai->ai_addr, ai->ai_addrlen,
- host, sizeof(host),
- port, sizeof(port),
- NI_NUMERICHOST|NI_NUMERICSERV);
+ host, sizeof(host), port, sizeof(port),
+ NI_NUMERICHOST|NI_NUMERICSERV);
fprintf(stderr,"%s: %s:%s\n", prefix, host, port);
}
}
#endif
/*
- *----------------------------------------------------------------------
+ * ----------------------------------------------------------------------
*
* InitializeHostName --
*
@@ -197,7 +200,7 @@ void printaddrinfo(struct addrinfo *addrlist, char *prefix)
* Results:
* None.
*
- *----------------------------------------------------------------------
+ * ----------------------------------------------------------------------
*/
static void
@@ -271,12 +274,12 @@ InitializeHostName(
*encodingPtr = Tcl_GetEncoding(NULL, NULL);
*lengthPtr = strlen(native);
- *valuePtr = ckalloc((*lengthPtr) + 1);
- memcpy(*valuePtr, native, (size_t)(*lengthPtr)+1);
+ *valuePtr = ckalloc(*lengthPtr + 1);
+ memcpy(*valuePtr, native, (size_t)(*lengthPtr) + 1);
}
/*
- *----------------------------------------------------------------------
+ * ----------------------------------------------------------------------
*
* Tcl_GetHostName --
*
@@ -290,7 +293,7 @@ InitializeHostName(
* Side effects:
* Caches the name to return for future calls.
*
- *----------------------------------------------------------------------
+ * ----------------------------------------------------------------------
*/
const char *
@@ -300,7 +303,7 @@ Tcl_GetHostName(void)
}
/*
- *----------------------------------------------------------------------
+ * ----------------------------------------------------------------------
*
* TclpHasSockets --
*
@@ -312,7 +315,7 @@ Tcl_GetHostName(void)
* Side effects:
* None.
*
- *----------------------------------------------------------------------
+ * ----------------------------------------------------------------------
*/
int
@@ -323,7 +326,7 @@ TclpHasSockets(
}
/*
- *----------------------------------------------------------------------
+ * ----------------------------------------------------------------------
*
* TclpFinalizeSockets --
*
@@ -335,7 +338,7 @@ TclpHasSockets(
* Side effects:
* None.
*
- *----------------------------------------------------------------------
+ * ----------------------------------------------------------------------
*/
void
@@ -345,7 +348,7 @@ TclpFinalizeSockets(void)
}
/*
- *----------------------------------------------------------------------
+ * ----------------------------------------------------------------------
*
* TcpBlockModeProc --
*
@@ -358,7 +361,7 @@ TclpFinalizeSockets(void)
* Side effects:
* Sets the device into blocking or nonblocking mode.
*
- *----------------------------------------------------------------------
+ * ----------------------------------------------------------------------
*/
/* ARGSUSED */
@@ -376,7 +379,7 @@ TcpBlockModeProc(
} else {
SET_BITS(statePtr->flags, TCP_NONBLOCKING);
}
- if (statePtr->flags & TCP_ASYNC_CONNECT) {
+ if (GOT_BITS(statePtr->flags, TCP_ASYNC_CONNECT)) {
statePtr->cachedBlocking = mode;
return 0;
}
@@ -387,33 +390,32 @@ TcpBlockModeProc(
}
/*
- *----------------------------------------------------------------------
+ * ----------------------------------------------------------------------
*
* WaitForConnect --
*
- * Check the state of an async connect process. If a connection
- * attempt terminated, process it, which may finalize it or may
- * start the next attempt. If a connect error occures, it is saved
- * in statePtr->connectError to be reported by 'fconfigure -error'.
+ * Check the state of an async connect process. If a connection attempt
+ * terminated, process it, which may finalize it or may start the next
+ * attempt. If a connect error occures, it is saved in
+ * statePtr->connectError to be reported by 'fconfigure -error'.
*
* There are two modes of operation, defined by errorCodePtr:
- * * non-NULL: Called by explicite read/write command. block if
+ * * non-NULL: Called by explicite read/write command. Blocks if the
* socket is blocking.
* May return two error codes:
* * EWOULDBLOCK: if connect is still in progress
- * * ENOTCONN: if connect failed. This would be the error
- * message of a rect or sendto syscall so this is
- * emulated here.
- * * NULL: Called by a backround operation. Do not block and
- * don't return any error code.
+ * * ENOTCONN: if connect failed. This would be the error message
+ * of a rect or sendto syscall so this is emulated here.
+ * * NULL: Called by a backround operation. Do not block and do not
+ * return any error code.
*
* Results:
- * 0 if the connection has completed, -1 if still in progress
- * or there is an error.
+ * 0 if the connection has completed, -1 if still in progress or there is
+ * an error.
*
* Side effects:
- * Processes socket events off the system queue.
- * May process asynchroneous connect.
+ * Processes socket events off the system queue. May process
+ * asynchroneous connects.
*
*----------------------------------------------------------------------
*/
@@ -426,11 +428,11 @@ WaitForConnect(
int timeout;
/*
- * Check if an async connect failed already and error reporting is demanded,
- * return the error ENOTCONN
+ * Check if an async connect failed already and error reporting is
+ * demanded, return the error ENOTCONN
*/
- if (errorCodePtr != NULL && (statePtr->flags & TCP_ASYNC_FAILED)) {
+ if (errorCodePtr != NULL && GOT_BITS(statePtr->flags, TCP_ASYNC_FAILED)) {
*errorCodePtr = ENOTCONN;
return -1;
}
@@ -439,26 +441,29 @@ WaitForConnect(
* Check if an async connect is running. If not return ok
*/
- if (!(statePtr->flags & TCP_ASYNC_PENDING)) {
+ if (!GOT_BITS(statePtr->flags, TCP_ASYNC_PENDING)) {
return 0;
}
- if (errorCodePtr == NULL || (statePtr->flags & TCP_NONBLOCKING)) {
+ if (errorCodePtr == NULL || GOT_BITS(statePtr->flags, TCP_NONBLOCKING)) {
timeout = 0;
} else {
timeout = -1;
}
do {
if (TclUnixWaitForFile(statePtr->fds.fd,
- TCL_WRITABLE | TCL_EXCEPTION, timeout) != 0) {
+ TCL_WRITABLE | TCL_EXCEPTION, timeout) != 0) {
TcpConnect(NULL, statePtr);
}
- /* Do this only once in the nonblocking case and repeat it until the
- * socket is final when blocking */
- } while (timeout == -1 && statePtr->flags & TCP_ASYNC_CONNECT);
+
+ /*
+ * Do this only once in the nonblocking case and repeat it until the
+ * socket is final when blocking.
+ */
+ } while (timeout == -1 && GOT_BITS(statePtr->flags, TCP_ASYNC_CONNECT));
if (errorCodePtr != NULL) {
- if (statePtr->flags & TCP_ASYNC_PENDING) {
+ if (GOT_BITS(statePtr->flags, TCP_ASYNC_PENDING)) {
*errorCodePtr = EAGAIN;
return -1;
} else if (statePtr->connectError != 0) {
@@ -615,7 +620,8 @@ TcpCloseProc(
fds = statePtr->fds.next;
while (fds != NULL) {
TcpFdList *next = fds->next;
- ckfree(fds);
+
+ ckfree(fds);
fds = next;
}
if (statePtr->addrlist != NULL) {
@@ -685,10 +691,9 @@ TcpClose2Proc(
*
* TcpHostPortList --
*
- * This function is called by the -gethostname and -getpeername
- * switches of TcpGetOptionProc() to add three list elements
- * with the textual representation of the given address to the
- * given DString.
+ * This function is called by the -gethostname and -getpeername switches
+ * of TcpGetOptionProc() to add three list elements with the textual
+ * representation of the given address to the given DString.
*
* Results:
* None.
@@ -700,6 +705,10 @@ TcpClose2Proc(
*/
#ifndef NEED_FAKE_RFC2553
+#if defined (__clang__) || ((__GNUC__) && ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ > 5))))
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wstrict-aliasing"
+#endif
static inline int
IPv6AddressNeedsNumericRendering(
struct in6_addr addr)
@@ -713,16 +722,16 @@ IPv6AddressNeedsNumericRendering(
* at least some versions of OSX.
*/
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wstrict-aliasing"
if (!IN6_IS_ADDR_V4MAPPED(&addr)) {
-#pragma GCC diagnostic pop
return 0;
}
return (addr.s6_addr[12] == 0 && addr.s6_addr[13] == 0
&& addr.s6_addr[14] == 0 && addr.s6_addr[15] == 0);
}
+#if defined (__clang__) || ((__GNUC__) && ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ > 5))))
+#pragma GCC diagnostic pop
+#endif
#endif /* NEED_FAKE_RFC2553 */
static void
@@ -736,14 +745,15 @@ TcpHostPortList(
char host[NI_MAXHOST], nhost[NI_MAXHOST], nport[NI_MAXSERV];
int flags = 0;
- getnameinfo(&addr.sa, salen,
- nhost, sizeof(nhost), nport, sizeof(nport),
- NI_NUMERICHOST | NI_NUMERICSERV);
+ getnameinfo(&addr.sa, salen, nhost, sizeof(nhost), nport, sizeof(nport),
+ NI_NUMERICHOST | NI_NUMERICSERV);
Tcl_DStringAppendElement(dsPtr, nhost);
+
/*
- * We don't want to resolve INADDR_ANY and sin6addr_any; they
- * can sometimes cause problems (and never have a name).
+ * We don't want to resolve INADDR_ANY and sin6addr_any; they can
+ * sometimes cause problems (and never have a name).
*/
+
if (addr.sa.sa_family == AF_INET) {
if (addr.sa4.sin_addr.s_addr == INADDR_ANY) {
flags |= NI_NUMERICHOST;
@@ -755,15 +765,27 @@ TcpHostPortList(
}
#endif /* NEED_FAKE_RFC2553 */
}
- /* Check if reverse DNS has been switched off globally */
- if (interp != NULL && Tcl_GetVar(interp, SUPPRESS_RDNS_VAR, 0) != NULL) {
+
+ /*
+ * Check if reverse DNS has been switched off globally.
+ */
+
+ if (interp != NULL &&
+ Tcl_GetVar2(interp, SUPPRESS_RDNS_VAR, NULL, 0) != NULL) {
flags |= NI_NUMERICHOST;
}
- if (getnameinfo(&addr.sa, salen, host, sizeof(host), NULL, 0, flags) == 0) {
- /* Reverse mapping worked */
+ if (getnameinfo(&addr.sa, salen, host, sizeof(host), NULL, 0,
+ flags) == 0) {
+ /*
+ * Reverse mapping worked.
+ */
+
Tcl_DStringAppendElement(dsPtr, host);
} else {
- /* Reverse mappong failed - use the numeric rep once more */
+ /*
+ * Reverse mapping failed - use the numeric rep once more.
+ */
+
Tcl_DStringAppendElement(dsPtr, nhost);
}
Tcl_DStringAppendElement(dsPtr, nport);
@@ -813,16 +835,20 @@ TcpGetOptionProc(
(strncmp(optionName, "-error", len) == 0)) {
socklen_t optlen = sizeof(int);
- if (statePtr->flags & TCP_ASYNC_CONNECT) {
- /* Suppress errors as long as we are not done */
+ if (GOT_BITS(statePtr->flags, TCP_ASYNC_CONNECT)) {
+ /*
+ * Suppress errors as long as we are not done.
+ */
+
errno = 0;
} else if (statePtr->connectError != 0) {
errno = statePtr->connectError;
statePtr->connectError = 0;
} else {
int err;
- getsockopt(statePtr->fds.fd, SOL_SOCKET, SO_ERROR,
- (char *) &err, &optlen);
+
+ getsockopt(statePtr->fds.fd, SOL_SOCKET, SO_ERROR, (char *) &err,
+ &optlen);
errno = err;
}
if (errno != 0) {
@@ -833,9 +859,8 @@ TcpGetOptionProc(
if ((len > 1) && (optionName[1] == 'c') &&
(strncmp(optionName, "-connecting", len) == 0)) {
-
Tcl_DStringAppend(dsPtr,
- (statePtr->flags & TCP_ASYNC_CONNECT) ? "1" : "0", -1);
+ GOT_BITS(statePtr->flags, TCP_ASYNC_CONNECT) ? "1" : "0", -1);
return TCL_OK;
}
@@ -844,10 +869,11 @@ TcpGetOptionProc(
address peername;
socklen_t size = sizeof(peername);
- if ( (statePtr->flags & TCP_ASYNC_CONNECT) ) {
+ if (GOT_BITS(statePtr->flags, TCP_ASYNC_CONNECT)) {
/*
* In async connect output an empty string
*/
+
if (len == 0) {
Tcl_DStringAppendElement(dsPtr, "-peername");
Tcl_DStringAppendElement(dsPtr, "");
@@ -858,6 +884,7 @@ TcpGetOptionProc(
/*
* Peername fetch succeeded - output list
*/
+
if (len == 0) {
Tcl_DStringAppendElement(dsPtr, "-peername");
Tcl_DStringStartSublist(dsPtr);
@@ -897,11 +924,12 @@ TcpGetOptionProc(
Tcl_DStringAppendElement(dsPtr, "-sockname");
Tcl_DStringStartSublist(dsPtr);
}
- if ( (statePtr->flags & TCP_ASYNC_CONNECT) ) {
+ if (GOT_BITS(statePtr->flags, TCP_ASYNC_CONNECT)) {
/*
* In async connect output an empty string
*/
- found = 1;
+
+ found = 1;
} else {
for (fds = &statePtr->fds; fds != NULL; fds = fds->next) {
size = sizeof(sockname);
@@ -926,14 +954,15 @@ TcpGetOptionProc(
}
if (len > 0) {
- return Tcl_BadChannelOption(interp, optionName, "connecting peername sockname");
+ return Tcl_BadChannelOption(interp, optionName,
+ "connecting peername sockname");
}
return TCL_OK;
}
/*
- *----------------------------------------------------------------------
+ * ----------------------------------------------------------------------
*
* TcpWatchProc --
*
@@ -946,7 +975,7 @@ TcpGetOptionProc(
* Sets up the notifier so that a future event on the channel will be
* seen by Tcl.
*
- *----------------------------------------------------------------------
+ * ----------------------------------------------------------------------
*/
static void
@@ -959,17 +988,17 @@ WrapNotify(
if (newmask == 0) {
/*
- * There was no overlap between the states the channel is
- * interested in notifications for, and the states that are
- * reported present on the file descriptor by select(). The
- * only way that can happen is when the channel is interested
- * in a writable condition, and only a readable state is reported
- * present (see TcpWatchProc() below). In that case, signal back
- * to the caller the writable state, which is really an error
- * condition. As an extra check on that assumption, check for
- * a non-zero value of errno before reporting an artificial
+ * There was no overlap between the states the channel is interested
+ * in notifications for, and the states that are reported present on
+ * the file descriptor by select(). The only way that can happen is
+ * when the channel is interested in a writable condition, and only a
+ * readable state is reported present (see TcpWatchProc() below). In
+ * that case, signal back to the caller the writable state, which is
+ * really an error condition. As an extra check on that assumption,
+ * check for a non-zero value of errno before reporting an artificial
* writable state.
*/
+
if (errno == 0) {
return;
}
@@ -993,33 +1022,36 @@ TcpWatchProc(
* be readable or writable at the Tcl level. This keeps Tcl scripts
* from interfering with the -accept behavior (bug #3394732).
*/
+
return;
}
- if (statePtr->flags & TCP_ASYNC_PENDING) {
- /* Async sockets use a FileHandler internally while connecting, so we
- * need to cache this request until the connection has succeeded. */
+ if (GOT_BITS(statePtr->flags, TCP_ASYNC_PENDING)) {
+ /*
+ * Async sockets use a FileHandler internally while connecting, so we
+ * need to cache this request until the connection has succeeded.
+ */
+
statePtr->filehandlers = mask;
} else if (mask) {
/*
- * Whether it is a bug or feature or otherwise, it is a fact
- * of life that on at least some Linux kernels select() fails
- * to report that a socket file descriptor is writable when
- * the other end of the socket is closed. This is in contrast
- * to the guarantees Tcl makes that its channels become
- * writable and fire writable events on an error conditon.
- * This has caused a leak of file descriptors in a state of
+ * Whether it is a bug or feature or otherwise, it is a fact of life
+ * that on at least some Linux kernels select() fails to report that a
+ * socket file descriptor is writable when the other end of the socket
+ * is closed. This is in contrast to the guarantees Tcl makes that
+ * its channels become writable and fire writable events on an error
+ * conditon. This has caused a leak of file descriptors in a state of
* background flushing. See Tcl ticket 1758a0b603.
*
- * As a workaround, when our caller indicates an interest in
- * writable notifications, we must tell the notifier built
- * around select() that we are interested in the readable state
- * of the file descriptor as well, as that is the only reliable
- * means to get notified of error conditions. Then it is the
- * task of WrapNotify() above to untangle the meaning of these
- * channel states and report the chan events as best it can.
- * We save a copy of the mask passed in to assist with that.
+ * As a workaround, when our caller indicates an interest in writable
+ * notifications, we must tell the notifier built around select() that
+ * we are interested in the readable state of the file descriptor as
+ * well, as that is the only reliable means to get notified of error
+ * conditions. Then it is the task of WrapNotify() above to untangle
+ * the meaning of these channel states and report the chan events as
+ * best it can. We save a copy of the mask passed in to assist with
+ * that.
*/
statePtr->interest = mask;
@@ -1031,7 +1063,7 @@ TcpWatchProc(
}
/*
- *----------------------------------------------------------------------
+ * ----------------------------------------------------------------------
*
* TcpGetHandleProc --
*
@@ -1045,7 +1077,7 @@ TcpWatchProc(
* Side effects:
* None.
*
- *----------------------------------------------------------------------
+ * ----------------------------------------------------------------------
*/
/* ARGSUSED */
@@ -1062,16 +1094,17 @@ TcpGetHandleProc(
}
/*
- *----------------------------------------------------------------------
+ * ----------------------------------------------------------------------
*
* TcpAsyncCallback --
*
- * Called by the event handler that TcpConnect sets up
- * internally for [socket -async] to get notified when the
- * asyncronous connection attempt has succeeded or failed.
+ * Called by the event handler that TcpConnect sets up internally for
+ * [socket -async] to get notified when the asyncronous connection
+ * attempt has succeeded or failed.
*
- *----------------------------------------------------------------------
+ * ----------------------------------------------------------------------
*/
+
static void
TcpAsyncCallback(
ClientData clientData, /* The socket state. */
@@ -1083,7 +1116,7 @@ TcpAsyncCallback(
}
/*
- *----------------------------------------------------------------------
+ * ----------------------------------------------------------------------
*
* TcpConnect --
*
@@ -1109,7 +1142,7 @@ TcpAsyncCallback(
* return and the loops resume as if they had never been interrupted.
* For syncronously connecting sockets, the loops work the usual way.
*
- *----------------------------------------------------------------------
+ * ----------------------------------------------------------------------
*/
static int
@@ -1118,9 +1151,9 @@ TcpConnect(
TcpState *statePtr)
{
socklen_t optlen;
- int async_callback = statePtr->flags & TCP_ASYNC_PENDING;
+ int async_callback = GOT_BITS(statePtr->flags, TCP_ASYNC_PENDING);
int ret = -1, error = EHOSTUNREACH;
- int async = statePtr->flags & TCP_ASYNC_CONNECT;
+ int async = GOT_BITS(statePtr->flags, TCP_ASYNC_CONNECT);
if (async_callback) {
goto reenter;
@@ -1128,8 +1161,8 @@ TcpConnect(
for (statePtr->addr = statePtr->addrlist; statePtr->addr != NULL;
statePtr->addr = statePtr->addr->ai_next) {
-
- for (statePtr->myaddr = statePtr->myaddrlist; statePtr->myaddr != NULL;
+ for (statePtr->myaddr = statePtr->myaddrlist;
+ statePtr->myaddr != NULL;
statePtr->myaddr = statePtr->myaddr->ai_next) {
int reuseaddr = 1;
@@ -1153,7 +1186,8 @@ TcpConnect(
errno = 0;
}
- statePtr->fds.fd = socket(statePtr->addr->ai_family, SOCK_STREAM, 0);
+ statePtr->fds.fd = socket(statePtr->addr->ai_family, SOCK_STREAM,
+ 0);
if (statePtr->fds.fd < 0) {
continue;
}
@@ -1172,14 +1206,18 @@ TcpConnect(
TclSockMinimumBuffers(INT2PTR(statePtr->fds.fd), SOCKET_BUFSIZE);
if (async) {
- ret = TclUnixSetBlockingMode(statePtr->fds.fd,TCL_MODE_NONBLOCKING);
+ ret = TclUnixSetBlockingMode(statePtr->fds.fd,
+ TCL_MODE_NONBLOCKING);
if (ret < 0) {
continue;
}
}
- /* Gotta reset the error variable here, before we use it for the
- * first time in this iteration. */
+ /*
+ * Must reset the error variable here, before we use it for the
+ * first time in this iteration.
+ */
+
error = 0;
(void) setsockopt(statePtr->fds.fd, SOL_SOCKET, SO_REUSEADDR,
@@ -1200,10 +1238,13 @@ TcpConnect(
ret = connect(statePtr->fds.fd, statePtr->addr->ai_addr,
statePtr->addr->ai_addrlen);
- if (ret < 0) error = errno;
+ if (ret < 0) {
+ error = errno;
+ }
if (ret < 0 && errno == EINPROGRESS) {
Tcl_CreateFileHandler(statePtr->fds.fd,
- TCL_WRITABLE|TCL_EXCEPTION, TcpAsyncCallback, statePtr);
+ TCL_WRITABLE | TCL_EXCEPTION, TcpAsyncCallback,
+ statePtr);
errno = EWOULDBLOCK;
SET_BITS(statePtr->flags, TCP_ASYNC_PENDING);
return TCL_OK;
@@ -1231,7 +1272,7 @@ TcpConnect(
}
}
-out:
+ out:
statePtr->connectError = error;
CLEAR_BITS(statePtr->flags, TCP_ASYNC_CONNECT);
if (async_callback) {
@@ -1329,6 +1370,7 @@ Tcl_OpenTcpClient(
/*
* Allocate a new TcpState for this socket.
*/
+
statePtr = ckalloc(sizeof(TcpState));
memset(statePtr, 0, sizeof(TcpState));
statePtr->flags = async ? TCP_ASYNC_CONNECT : 0;
@@ -1340,6 +1382,7 @@ Tcl_OpenTcpClient(
/*
* Create a new client socket and wrap it in a channel.
*/
+
if (TcpConnect(interp, statePtr) != TCL_OK) {
TcpCloseProc(statePtr, NULL);
return NULL;
@@ -1347,8 +1390,8 @@ Tcl_OpenTcpClient(
sprintf(channelName, SOCK_TEMPLATE, (long) statePtr);
- statePtr->channel = Tcl_CreateChannel(&tcpChannelType, channelName, statePtr,
- (TCL_READABLE | TCL_WRITABLE));
+ statePtr->channel = Tcl_CreateChannel(&tcpChannelType, channelName,
+ statePtr, TCL_READABLE | TCL_WRITABLE);
if (Tcl_SetChannelOption(interp, statePtr->channel, "-translation",
"auto crlf") == TCL_ERROR) {
Tcl_Close(NULL, statePtr->channel);
@@ -1377,7 +1420,8 @@ Tcl_Channel
Tcl_MakeTcpClientChannel(
ClientData sock) /* The socket to wrap up into a channel. */
{
- return (Tcl_Channel) TclpMakeTcpClientChannelMode(sock, (TCL_READABLE | TCL_WRITABLE));
+ return (Tcl_Channel) TclpMakeTcpClientChannelMode(sock,
+ TCL_READABLE | TCL_WRITABLE);
}
/*
@@ -1516,7 +1560,10 @@ Tcl_OpenTcpServer(
}
#ifdef IPV6_V6ONLY
- /* Missing on: Solaris 2.8 */
+ /*
+ * Missing on: Solaris 2.8
+ */
+
if (addrPtr->ai_family == AF_INET6) {
int v6only = 1;
@@ -1662,7 +1709,7 @@ TcpAccept(
sprintf(channelName, SOCK_TEMPLATE, (long) newSockState);
newSockState->channel = Tcl_CreateChannel(&tcpChannelType, channelName,
- newSockState, (TCL_READABLE | TCL_WRITABLE));
+ newSockState, TCL_READABLE | TCL_WRITABLE);
Tcl_SetChannelOption(NULL, newSockState->channel, "-translation",
"auto crlf");
diff --git a/unix/tclooConfig.sh b/unix/tclooConfig.sh
index ee10b81..2279542 100644
--- a/unix/tclooConfig.sh
+++ b/unix/tclooConfig.sh
@@ -16,4 +16,4 @@ TCLOO_STUB_LIB_SPEC=""
TCLOO_INCLUDE_SPEC=""
TCLOO_PRIVATE_INCLUDE_SPEC=""
TCLOO_CFLAGS=""
-TCLOO_VERSION=1.0.4
+TCLOO_VERSION=1.1.0