[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

xtrans: Changes to 'upstream-unstable'



 Xtranssock.c |   75 +++++++++++++++++++++++++++++------------------------------
 Xtransutil.c |    6 +++-
 configure.ac |    2 -
 xtrans.m4    |   18 +++++++++++---
 4 files changed, 58 insertions(+), 43 deletions(-)

New commits:
commit e75b9dad0ae4bc0869af81652d8259675a3c5cac
Author: Julien Cristau <jcristau@debian.org>
Date:   Thu May 8 16:27:29 2008 +0200

    Bump to 1.2

diff --git a/configure.ac b/configure.ac
index 0846bf1..304fd6b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -21,7 +21,7 @@ dnl
 dnl Process this file with autoconf to create configure.
 
 AC_PREREQ([2.57])
-AC_INIT(xtrans, 1.1, [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], xtrans)
+AC_INIT(xtrans, 1.2, [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], xtrans)
 AM_INIT_AUTOMAKE([dist-bzip2])
 AM_MAINTAINER_MODE
 

commit 962ad4d3f8096f5ffa14b32b3ee094f250790c77
Author: Alan Hourihane <alanh@tungstengraphics.com>
Date:   Mon Apr 28 23:46:05 2008 +0100

    disable UNIXCONN on MINGW

diff --git a/xtrans.m4 b/xtrans.m4
index dfc5dd3..31d456b 100644
--- a/xtrans.m4
+++ b/xtrans.m4
@@ -67,17 +67,21 @@ AC_INCLUDES_DEFAULT
 AC_DEFUN([XTRANS_CONNECTION_FLAGS],[
  AC_REQUIRE([AC_CANONICAL_HOST])
  AC_REQUIRE([AC_TYPE_SIGNAL])
+ [case $host_os in
+	mingw*)	unixdef="no"   ;;
+	*)	unixdef="yes"  ;;
+ esac]
  AC_ARG_ENABLE(unix-transport,
 	AC_HELP_STRING([--enable-unix-transport],[Enable UNIX domain socket transport]),
-	[UNIXCONN=$enableval], [UNIXCONN=yes])
- AC_ARG_ENABLE(tcp-transport, 
-	AC_HELP_STRING([--enable-tcp-transport],[Enable TCP socket transport]),
-	[TCPCONN=$enableval], [TCPCONN=yes])
+	[UNIXCONN=$enableval], [UNIXCONN=$unixdef])
  AC_MSG_CHECKING([if Xtrans should support UNIX socket connections])
  if test "$UNIXCONN" = "yes"; then
 	AC_DEFINE(UNIXCONN,1,[Support UNIX socket connections])
  fi
  AC_MSG_RESULT($UNIXCONN)
+ AC_ARG_ENABLE(tcp-transport, 
+	AC_HELP_STRING([--enable-tcp-transport],[Enable TCP socket transport]),
+	[TCPCONN=$enableval], [TCPCONN=yes])
  AC_MSG_CHECKING([if Xtrans should support TCP socket connections])
  AC_MSG_RESULT($TCPCONN)
  if test "$TCPCONN" = "yes"; then

commit 9e8c0e3356bc6359368b7655d3a717d6c000387e
Author: Alan Hourihane <alanh@tungstengraphics.com>
Date:   Sat Apr 26 16:23:19 2008 +0100

    fix build for MAKEWORD

diff --git a/Xtransutil.c b/Xtransutil.c
old mode 100644
new mode 100755
index 9906367..f68b1e7
--- a/Xtransutil.c
+++ b/Xtransutil.c
@@ -57,6 +57,10 @@ from The Open Group.
 #ifdef XTHREADS
 #include <X11/Xthreads.h>
 #endif
+#ifdef WIN32
+#include <X11/Xlibint.h>
+#include <X11/Xwinsock.h>
+#endif
 
 #ifdef X11_t
 

commit 568c5ea02ee1de437833ee0b53a7b3fd7ece084f
Author: Colin Harrison <colin.harrison-at-virgin.net>
Date:   Sat Apr 26 08:53:13 2008 +0100

    Update to winsock2

diff --git a/Xtransutil.c b/Xtransutil.c
index a35c84b..9906367 100644
--- a/Xtransutil.c
+++ b/Xtransutil.c
@@ -479,7 +479,7 @@ TRANS(WSAStartup) (void)
 
     PRMSG (2,"WSAStartup()\n", 0, 0, 0);
 
-    if (!wsadata.wVersion && WSAStartup(0x0101, &wsadata))
+    if (!wsadata.wVersion && WSAStartup(MAKEWORD(2,2), &wsadata))
         return 1;
     return 0;
 }

commit 960902584a3ef125946beb5ebe331b54d697e9d9
Author: James Cloos <cloos@jhcloos.com>
Date:   Fri Apr 25 15:53:20 2008 -0400

    Fix length calculation for the path for abstract unix domain sockets
    
    Since the struct has a fixed-lenght char[] its sizeof() contains
    trailing NUL octets which results in corrupt abstract sockets.
    
    Instead, take the strlen(3) of the path, plus the single NUL octet
    (which identifies the path as an abstract path rather than a file-
    system path) plus the offset from the start of the struct to the
    start of the char array.
    
    This fixes:
    
    https://bugs.freedesktop.org/show_bug.cgi?id=15677

diff --git a/Xtranssock.c b/Xtranssock.c
index 8f64429..9be7f5a 100644
--- a/Xtranssock.c
+++ b/Xtranssock.c
@@ -1180,7 +1180,7 @@ TRANS(SocketUNIXCreateListener) (XtransConnInfo ciptr, char *port,
 
     if (abstract) {
 	sockname.sun_path[0] = '\0';
-	namelen = sizeof(sockname);
+	namelen = offsetof(struct sockaddr_un, sun_path) + 1 + strlen(&sockname.sun_path[1]);
     }
     else
 	unlink (sockname.sun_path);

commit 3a2a5375b8aab85697b4f2644ab99c3ccf79e658
Author: Colin Harrison <colin.harrison-at-virgin.net>
Date:   Wed Apr 23 10:39:30 2008 +0100

    Only call WSAGetLastError() if there has been an
    error condition.

diff --git a/Xtranssock.c b/Xtranssock.c
index 5ac6a62..8f64429 100644
--- a/Xtranssock.c
+++ b/Xtranssock.c
@@ -2221,7 +2221,7 @@ TRANS(SocketBytesReadable) (XtransConnInfo ciptr, BytesReadable_t *pend)
 #ifdef WIN32
     {
 	int ret = ioctlsocket ((SOCKET) ciptr->fd, FIONREAD, (u_long *) pend);
-	errno = WSAGetLastError();
+	if (ret == SOCKET_ERROR) errno = WSAGetLastError();
 	return ret;
     }
 #else
@@ -2248,7 +2248,7 @@ TRANS(SocketRead) (XtransConnInfo ciptr, char *buf, int size)
     {
 	int ret = recv ((SOCKET)ciptr->fd, buf, size, 0);
 #ifdef WIN32
-	errno = WSAGetLastError();
+	if (ret == SOCKET_ERROR) errno = WSAGetLastError();
 #endif
 	return ret;
     }
@@ -2268,7 +2268,7 @@ TRANS(SocketWrite) (XtransConnInfo ciptr, char *buf, int size)
     {
 	int ret = send ((SOCKET)ciptr->fd, buf, size, 0);
 #ifdef WIN32
-	errno = WSAGetLastError();
+	if (ret == SOCKET_ERROR) errno = WSAGetLastError();
 #endif
 	return ret;
     }
@@ -2307,7 +2307,7 @@ TRANS(SocketDisconnect) (XtransConnInfo ciptr)
 #ifdef WIN32
     { 
 	int ret = shutdown (ciptr->fd, 2);
-	errno = WSAGetLastError();
+	if (ret == SOCKET_ERROR) errno = WSAGetLastError();
 	return ret;
     }
 #else
@@ -2326,7 +2326,7 @@ TRANS(SocketINETClose) (XtransConnInfo ciptr)
 #ifdef WIN32
     {
 	int ret = close (ciptr->fd);
-	errno = WSAGetLastError();
+	if (ret == SOCKET_ERROR) errno = WSAGetLastError();
 	return ret;
     }
 #else

commit ac13a1a34b61247a21da130f0ba9922f35d3dc3b
Author: Alan Coopersmith <alan.coopersmith@sun.com>
Date:   Tue Apr 15 12:32:35 2008 -0700

    Sun bug #6688467: _X11TransConvertAddress: Unknown family type on 64-bit SPARC
    
    Check for socklen_t definition and if found use it instead of size_t or
    int for the length argument to getpeername/getsockname/etc.
    
    <http://bugs.opensolaris.org/bugdatabase/view_bug.do?bug_id=6688467>

diff --git a/Xtranssock.c b/Xtranssock.c
index da4afe9..5ac6a62 100644
--- a/Xtranssock.c
+++ b/Xtranssock.c
@@ -281,6 +281,14 @@ static int TRANS(SocketINETClose) (XtransConnInfo ciptr);
 #define MAXHOSTNAMELEN 255
 #endif
 
+#if defined HAVE_SOCKLEN_T || (defined(IPv6) && defined(AF_INET6))
+# define SOCKLEN_T socklen_t
+#elif defined(SVR4) || defined(__SCO__)
+# define SOCKLEN_T size_t 
+#else
+# define SOCKLEN_T int
+#endif
+
 /*
  * This provides compatibility for apps linked against system libraries
  * that don't have IPv6 support.
@@ -330,11 +338,7 @@ TRANS(SocketINETGetAddr) (XtransConnInfo ciptr)
 #endif
     struct sockaddr_in socknamev4;
     void *socknamePtr;
-#if defined(SVR4) || defined(__SCO__)
-    size_t namelen;
-#else
-    int namelen;
-#endif
+    SOCKLEN_T namelen;
 
     PRMSG (3,"SocketINETGetAddr(%p)\n", ciptr, 0, 0);
 
@@ -407,11 +411,7 @@ TRANS(SocketINETGetPeerAddr) (XtransConnInfo ciptr)
 #endif
     struct sockaddr_in 	socknamev4;
     void *socknamePtr;
-#if defined(SVR4) || defined(__SCO__)
-    size_t namelen;
-#else
-    int namelen;
-#endif
+    SOCKLEN_T namelen;
 
 #if defined(IPv6) && defined(AF_INET6)
     if (haveIPv6 && ciptr->family == AF_INET6)
@@ -918,7 +918,7 @@ TRANS(SocketCreateListener) (XtransConnInfo ciptr,
 			     int socknamelen, unsigned int flags)
 
 {
-    int	namelen = socknamelen;
+    SOCKLEN_T namelen = socknamelen;
     int	fd = ciptr->fd;
     int	retry;
 
@@ -998,7 +998,7 @@ TRANS(SocketINETCreateListener) (XtransConnInfo ciptr, char *port, unsigned int
     struct sockaddr_in	    sockname;
 #endif
     unsigned short	    sport;
-    int		namelen = sizeof(sockname);
+    SOCKLEN_T	namelen = sizeof(sockname);
     int		status;
     long	tmpport;
 #ifdef XTHREADS_NEEDS_BYNAMEPARAMS
@@ -1315,7 +1315,7 @@ TRANS(SocketINETAccept) (XtransConnInfo ciptr, int *status)
 {
     XtransConnInfo	newciptr;
     struct sockaddr_in	sockname;
-    int			namelen = sizeof(sockname);
+    SOCKLEN_T		namelen = sizeof(sockname);
 
     PRMSG (2, "SocketINETAccept(%p,%d)\n", ciptr, ciptr->fd, 0);
 
@@ -1394,11 +1394,7 @@ TRANS(SocketUNIXAccept) (XtransConnInfo ciptr, int *status)
 {
     XtransConnInfo	newciptr;
     struct sockaddr_un	sockname;
-#if defined(SVR4) || defined(__SCO__)
-    size_t namelen = sizeof sockname;
-#else
-    int namelen = sizeof sockname;
-#endif
+    SOCKLEN_T 		namelen = sizeof sockname;
 
     PRMSG (2, "SocketUNIXAccept(%p,%d)\n", ciptr, ciptr->fd, 0);
 
@@ -2031,11 +2027,11 @@ TRANS(SocketUNIXConnect) (XtransConnInfo ciptr, char *host, char *port)
 
 {
     struct sockaddr_un	sockname;
-    int			namelen;
+    SOCKLEN_T		namelen;
 
 #if defined(hpux) && defined(X11_t)
     struct sockaddr_un	old_sockname;
-    int			old_namelen;
+    SOCKLEN_T		old_namelen;
 #endif
 
     int abstract = 0;
diff --git a/xtrans.m4 b/xtrans.m4
index 1d80595..dfc5dd3 100644
--- a/xtrans.m4
+++ b/xtrans.m4
@@ -52,6 +52,12 @@ AC_DEFUN([XTRANS_TCP_FLAGS],[
 #include <sys/socket.h>
 #include <netinet/in.h>
  ])
+
+ # POSIX.1g changed the type of pointer passed to getsockname/getpeername/etc.
+ AC_CHECK_TYPES([socklen_t], [], [], [
+AC_INCLUDES_DEFAULT
+#include <sys/socket.h>])
+ 
 ]) # XTRANS_TCP_FLAGS
 
 # XTRANS_CONNECTION_FLAGS()

commit 556a351de83fc6f401b02213dae95731553c216d
Author: Loïc Minier <lool@dooz.org>
Date:   Mon Mar 24 15:38:27 2008 -0400

    Bug #10489: Don't retry unix socket connect()s on ENOENT.
    
    If the socket isn't there, it's not gonna magically appear.  Either it's
    a server socket and you should have just waited for the SIGUSR1 from the
    server, or it's a stale reference to an ICE socket.
    
    However, do retry once, so fallback from abstract to filesystem namespace
    works.
    
    Originally Debian bug #385976.

diff --git a/Xtranssock.c b/Xtranssock.c
index 8a7d2ec..da4afe9 100644
--- a/Xtranssock.c
+++ b/Xtranssock.c
@@ -2146,8 +2146,13 @@ TRANS(SocketUNIXConnect) (XtransConnInfo ciptr, char *host, char *port)
 	    errno = olderrno;
 	    
 	    /*
-	     * If the error was ENOENT, the server may be starting up
-	     * and we should try again.
+	     * If the error was ENOENT, the server may be starting up; we used
+	     * to suggest to try again in this case with
+	     * TRANS_TRY_CONNECT_AGAIN, but this introduced problems for
+	     * processes still referencing stale sockets in their environment.
+	     * Hence, we now return a hard error, TRANS_CONNECT_FAILED, and it
+	     * is suggested that higher level stacks handle retries on their
+	     * level when they face a slow starting server.
 	     *
 	     * If the error was EWOULDBLOCK or EINPROGRESS then the socket
 	     * was non-blocking and we should poll using select
@@ -2161,14 +2166,14 @@ TRANS(SocketUNIXConnect) (XtransConnInfo ciptr, char *host, char *port)
 	    else if (olderrno == EINTR)
 		return TRANS_TRY_CONNECT_AGAIN;
 	    else if (olderrno == ENOENT) {
-		/*
-		* If opening as abstract socket failed, try again "normally"
-		*/
-		if (abstract)
+		/* If opening as abstract socket failed, try again normally */
+		if (abstract) {
 		    ciptr->transptr->flags &= ~(TRANS_ABSTRACT);
-		return TRANS_TRY_CONNECT_AGAIN;
-	    }
-	    else {
+		    return TRANS_TRY_CONNECT_AGAIN;
+		} else {
+		    return TRANS_CONNECT_FAILED;
+		}
+	    } else {
 		PRMSG (2,"SocketUNIXConnect: Can't connect: errno = %d\n",
 		       EGET(),0, 0);
 

commit 3de3e666e0653d4e8ae23fc3e6e31864ddad4059
Author: Julien Cristau <jcristau@debian.org>
Date:   Sun Mar 23 19:43:32 2008 +0100

    BSD44SOCKETS is the wrong check for SOCK_MAXADDRLEN
    
    GNU/kFreeBSD defines BSD44SOCKETS, but doesn't have SOCK_MAXADDRLEN.
    Check for the latter directly.

diff --git a/Xtranssock.c b/Xtranssock.c
index 94b73e2..8a7d2ec 100644
--- a/Xtranssock.c
+++ b/Xtranssock.c
@@ -540,7 +540,7 @@ TRANS(SocketReopen) (int i, int type, int fd, char *port)
     }
 
     portlen = strlen(port) + 1; // include space for trailing null
-#ifdef BSD44SOCKETS
+#ifdef SOCK_MAXADDRLEN
     if (portlen < 0 || portlen > (SOCK_MAXADDRLEN + 2)) {
       PRMSG (1, "SocketReopen: invalid portlen %d\n", portlen, 0, 0);
       return NULL;
@@ -551,7 +551,7 @@ TRANS(SocketReopen) (int i, int type, int fd, char *port)
       PRMSG (1, "SocketReopen: invalid portlen %d\n", portlen, 0, 0);
       return NULL;
     }
-#endif /*BSD44SOCKETS*/
+#endif /*SOCK_MAXADDRLEN*/
 
     if ((ciptr = (XtransConnInfo) xcalloc (
 	1, sizeof(struct _XtransConnInfo))) == NULL)


Reply to: