diff options
author | andreas_kupries <akupries@shaw.ca> | 2003-10-23 17:49:05 (GMT) |
---|---|---|
committer | andreas_kupries <akupries@shaw.ca> | 2003-10-23 17:49:05 (GMT) |
commit | 8fe5b2fcac7044adea04de99718e6edecdc109b4 (patch) | |
tree | 3793a485642e94c6eefbf29b86618f5444aa8b90 | |
parent | 30812e7dd017c24c6fe9087088d51216f735512a (diff) | |
download | tcl-8fe5b2fcac7044adea04de99718e6edecdc109b4.zip tcl-8fe5b2fcac7044adea04de99718e6edecdc109b4.tar.gz tcl-8fe5b2fcac7044adea04de99718e6edecdc109b4.tar.bz2 |
* unix/tclUnixChan.c (Tcl_MakeFileChannel): Applied [Patch 813606]
fixing [Bug 813087]. Detection of sockets was off for Mac OS X
which implements pipes as local sockets. The new code ensures
that only IP sockets are detected as such.
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | unix/tclUnixChan.c | 21 |
2 files changed, 19 insertions, 9 deletions
@@ -1,3 +1,10 @@ +2003-10-23 Andreas Kupries <andreask@activestate.com> + + * unix/tclUnixChan.c (Tcl_MakeFileChannel): Applied [Patch 813606] + fixing [Bug 813087]. Detection of sockets was off for Mac OS X + which implements pipes as local sockets. The new code ensures + that only IP sockets are detected as such. + 2003-10-22 Andreas Kupries <andreask@activestate.com> * win/tclWinSock.c (TcpWatchProc): Watch for FD_CLOSE too when diff --git a/unix/tclUnixChan.c b/unix/tclUnixChan.c index 133e44f..7b6f59f 100644 --- a/unix/tclUnixChan.c +++ b/unix/tclUnixChan.c @@ -10,7 +10,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclUnixChan.c,v 1.42 2003/02/21 02:36:27 hobbs Exp $ + * RCS: @(#) $Id: tclUnixChan.c,v 1.42.2.1 2003/10/23 17:49:06 andreas_kupries Exp $ */ #include "tclInt.h" /* Internal definitions for Tcl. */ @@ -1889,8 +1889,8 @@ Tcl_MakeFileChannel(handle, mode) #ifdef DEPRECATED ThreadSpecificData *tsdPtr = TCL_TSD_INIT(&dataKey); #endif /* DEPRECATED */ - int socketType = 0; - socklen_t argLength = sizeof(int); + struct sockaddr sockaddr; + socklen_t sockaddrLen = sizeof(sockaddr); if (mode == 0) { return NULL; @@ -1911,6 +1911,8 @@ Tcl_MakeFileChannel(handle, mode) } #endif /* DEPRECATED */ + sockaddr.sa_family = AF_UNSPEC; + #ifdef SUPPORTS_TTY if (isatty(fd)) { fsPtr = TtyInit(fd, 0); @@ -1918,13 +1920,14 @@ Tcl_MakeFileChannel(handle, mode) sprintf(channelName, "serial%d", fd); } else #endif /* SUPPORTS_TTY */ - if (getsockopt(fd, SOL_SOCKET, SO_TYPE, (VOID *)&socketType, - &argLength) == 0 && socketType == SOCK_STREAM) { - return MakeTcpClientChannelMode((ClientData) fd, mode); + if (getsockname(fd, (struct sockaddr *)&sockaddr, &sockaddrLen) == 0 + && sockaddrLen > 0 + && sockaddr.sa_family == AF_INET) { + return MakeTcpClientChannelMode((ClientData) fd, mode); } else { - channelTypePtr = &fileChannelType; - fsPtr = (FileState *) ckalloc((unsigned) sizeof(FileState)); - sprintf(channelName, "file%d", fd); + channelTypePtr = &fileChannelType; + fsPtr = (FileState *) ckalloc((unsigned) sizeof(FileState)); + sprintf(channelName, "file%d", fd); } #ifdef DEPRECATED |