diff options
author | marha <marha@users.sourceforge.net> | 2013-11-08 13:12:15 +0100 |
---|---|---|
committer | marha <marha@users.sourceforge.net> | 2013-11-08 13:12:15 +0100 |
commit | f707ea3ce065f0ce40f586c40283fab42059b485 (patch) | |
tree | 055a5ccdecaec105365d1de9a90d7d6b38f257fb /X11/xtrans | |
parent | c8483dc2831dc37d93a36804022f6b064f5962ea (diff) | |
parent | 09e94a8e392e8fe6fd89ddefbf3897a92e525b5b (diff) | |
download | vcxsrv-f707ea3ce065f0ce40f586c40283fab42059b485.tar.gz vcxsrv-f707ea3ce065f0ce40f586c40283fab42059b485.tar.bz2 vcxsrv-f707ea3ce065f0ce40f586c40283fab42059b485.zip |
Merge remote-tracking branch 'origin/released'
* origin/released:
Added presentproto-1.0
libxtrans libxcb xcb-proto mesa git update 8 nov 2013
Conflicts:
X11/xtrans/Xtransint.h
X11/xtrans/Xtranssock.c
libxcb/src/.gitignore
mesalib/src/mesa/drivers/dri/common/dri_util.c
Diffstat (limited to 'X11/xtrans')
-rw-r--r-- | X11/xtrans/Xtrans.c | 9 | ||||
-rw-r--r-- | X11/xtrans/Xtrans.h | 6 | ||||
-rw-r--r-- | X11/xtrans/Xtransint.h | 6 | ||||
-rw-r--r-- | X11/xtrans/Xtranslcl.c | 35 | ||||
-rwxr-xr-x | X11/xtrans/Xtranssock.c | 138 | ||||
-rw-r--r-- | X11/xtrans/configure.ac | 2 | ||||
-rw-r--r-- | X11/xtrans/xtrans.m4 | 35 |
7 files changed, 188 insertions, 43 deletions
diff --git a/X11/xtrans/Xtrans.c b/X11/xtrans/Xtrans.c index d14136b70..93358bc75 100644 --- a/X11/xtrans/Xtrans.c +++ b/X11/xtrans/Xtrans.c @@ -871,12 +871,20 @@ TRANS(Write) (XtransConnInfo ciptr, char *buf, int size) } int +TRANS(Readv) (XtransConnInfo ciptr, struct iovec *buf, int size) + +{ + return ciptr->transptr->Readv (ciptr, buf, size); +} + +int TRANS(Writev) (XtransConnInfo ciptr, struct iovec *buf, int size) { return ciptr->transptr->Writev (ciptr, buf, size); } +#if XTRANS_SEND_FDS int TRANS(SendFd) (XtransConnInfo ciptr, int fd, int do_close) { @@ -888,6 +896,7 @@ TRANS(RecvFd) (XtransConnInfo ciptr) { return ciptr->transptr->RecvFd(ciptr); } +#endif int TRANS(Disconnect) (XtransConnInfo ciptr) diff --git a/X11/xtrans/Xtrans.h b/X11/xtrans/Xtrans.h index 53b8b627d..69accd780 100644 --- a/X11/xtrans/Xtrans.h +++ b/X11/xtrans/Xtrans.h @@ -344,6 +344,12 @@ int TRANS(Write)( int /* size */ ); +int TRANS(Readv)( + XtransConnInfo, /* ciptr */ + struct iovec *, /* buf */ + int /* size */ +); + int TRANS(Writev)( XtransConnInfo, /* ciptr */ struct iovec *, /* buf */ diff --git a/X11/xtrans/Xtransint.h b/X11/xtrans/Xtransint.h index f93f98fa4..96d9aa3ce 100644 --- a/X11/xtrans/Xtransint.h +++ b/X11/xtrans/Xtransint.h @@ -72,8 +72,8 @@ from The Open Group. # define XTRANSDEBUG 1 #endif -#ifndef _MSC_VER -#define XTRANS_SEND_FDS 1 +#if XTRANS_SEND_FDS && !(defined(linux) || defined(__sun)) +#error "FD passing support only on Linux & Solaris" #endif #ifdef WIN32 @@ -291,6 +291,7 @@ typedef struct _Xtransport { int /* size */ ); +#if XTRANS_SEND_FDS int (*SendFd)( XtransConnInfo, /* connection */ int, /* fd */ @@ -300,6 +301,7 @@ typedef struct _Xtransport { int (*RecvFd)( XtransConnInfo /* connection */ ); +#endif int (*Disconnect)( XtransConnInfo /* connection */ diff --git a/X11/xtrans/Xtranslcl.c b/X11/xtrans/Xtranslcl.c index 242e07af1..65f1957b9 100644 --- a/X11/xtrans/Xtranslcl.c +++ b/X11/xtrans/Xtranslcl.c @@ -146,6 +146,21 @@ TRANS(ReopenFail)(XtransConnInfo ciptr _X_UNUSED, int fd _X_UNUSED, char *port _ #endif /* TRANS_REOPEN */ +#if XTRANS_SEND_FDS +static int +TRANS(LocalRecvFdInvalid)(XtransConnInfo ciptr) +{ + errno = EINVAL; + return -1; +} + +static int +TRANS(LocalSendFdInvalid)(XtransConnInfo ciptr, int fd, int do_close) +{ + errno = EINVAL; + return -1; +} +#endif static int @@ -2374,6 +2389,10 @@ Xtransport TRANS(LocalFuncs) = { TRANS(LocalWrite), TRANS(LocalReadv), TRANS(LocalWritev), +#if XTRANS_SEND_FDS + TRANS(LocalSendFdInvalid), + TRANS(LocalRecvFdInvalid), +#endif TRANS(LocalDisconnect), TRANS(LocalClose), TRANS(LocalCloseForCloning), @@ -2416,6 +2435,10 @@ Xtransport TRANS(PTSFuncs) = { TRANS(LocalWrite), TRANS(LocalReadv), TRANS(LocalWritev), +#if XTRANS_SEND_FDS + TRANS(LocalSendFdInvalid), + TRANS(LocalRecvFdInvalid), +#endif TRANS(LocalDisconnect), TRANS(LocalClose), TRANS(LocalCloseForCloning), @@ -2460,6 +2483,10 @@ Xtransport TRANS(NAMEDFuncs) = { TRANS(LocalWrite), TRANS(LocalReadv), TRANS(LocalWritev), +#if XTRANS_SEND_FDS + TRANS(LocalSendFdInvalid), + TRANS(LocalRecvFdInvalid), +#endif TRANS(LocalDisconnect), TRANS(LocalClose), TRANS(LocalCloseForCloning), @@ -2501,6 +2528,10 @@ Xtransport TRANS(PIPEFuncs) = { TRANS(LocalWrite), TRANS(LocalReadv), TRANS(LocalWritev), +#if XTRANS_SEND_FDS + TRANS(LocalSendFdInvalid), + TRANS(LocalRecvFdInvalid), +#endif TRANS(LocalDisconnect), TRANS(LocalClose), TRANS(LocalCloseForCloning), @@ -2545,6 +2576,10 @@ Xtransport TRANS(SCOFuncs) = { TRANS(LocalWrite), TRANS(LocalReadv), TRANS(LocalWritev), +#if XTRANS_SEND_FDS + TRANS(LocalSendFdInvalid), + TRANS(LocalRecvFdInvalid), +#endif TRANS(LocalDisconnect), TRANS(LocalClose), TRANS(LocalCloseForCloning), diff --git a/X11/xtrans/Xtranssock.c b/X11/xtrans/Xtranssock.c index adae5769c..b07b10b73 100755 --- a/X11/xtrans/Xtranssock.c +++ b/X11/xtrans/Xtranssock.c @@ -2200,6 +2200,20 @@ TRANS(SocketSendFd) (XtransConnInfo ciptr, int fd, int do_close) return 0; } +static int +TRANS(SocketRecvFdInvalid)(XtransConnInfo ciptr) +{ + errno = EINVAL; + return -1; +} + +static int +TRANS(SocketSendFdInvalid)(XtransConnInfo ciptr, int fd, int do_close) +{ + errno = EINVAL; + return -1; +} + #define MAX_FDS 128 struct fd_pass { @@ -2226,20 +2240,6 @@ static inline void init_msg_send(struct msghdr *msg, struct iovec *iov, int niov #endif /* XTRANS_SEND_FDS */ static int -TRANS(SocketRecvFdInvalid)(XtransConnInfo ciptr) -{ - errno = EINVAL; - return -1; -} - -static int -TRANS(SocketSendFdInvalid)(XtransConnInfo ciptr, int fd, int do_close) -{ - errno = EINVAL; - return -1; -} - -static int TRANS(SocketRead) (XtransConnInfo ciptr, char *buf, int size) { @@ -2256,26 +2256,33 @@ TRANS(SocketRead) (XtransConnInfo ciptr, char *buf, int size) #else #if XTRANS_SEND_FDS { - struct msghdr msg; - struct iovec iov; - struct fd_pass pass; + struct iovec iov = { + .iov_base = buf, + .iov_len = size + }; + char cmsgbuf[CMSG_SPACE(sizeof(int) * MAX_FDS)]; + struct msghdr msg = { + .msg_name = NULL, + .msg_namelen = 0, + .msg_iov = &iov, + .msg_iovlen = 1, + .msg_control = cmsgbuf, + .msg_controllen = CMSG_LEN(MAX_FDS * sizeof(int)) + }; - iov.iov_base = buf; - iov.iov_len = size; - - init_msg_recv(&msg, &iov, 1, &pass, MAX_FDS); size = recvmsg(ciptr->fd, &msg, 0); - if (size >= 0 && msg.msg_controllen > sizeof (struct cmsghdr)) { - if (pass.cmsghdr.cmsg_level == SOL_SOCKET && - pass.cmsghdr.cmsg_type == SCM_RIGHTS && - !((msg.msg_flags & MSG_TRUNC) || - (msg.msg_flags & MSG_CTRUNC))) - { - int nfd = (msg.msg_controllen - sizeof (struct cmsghdr)) / sizeof (int); - int *fd = (int *) CMSG_DATA(&pass.cmsghdr); - int i; - for (i = 0; i < nfd; i++) - appendFd(&ciptr->recv_fds, fd[i], 0); + if (size >= 0) { + struct cmsghdr *hdr; + + for (hdr = CMSG_FIRSTHDR(&msg); hdr; hdr = CMSG_NXTHDR(&msg, hdr)) { + if (hdr->cmsg_level == SOL_SOCKET && hdr->cmsg_type == SCM_RIGHTS) { + int nfd = (hdr->cmsg_len - CMSG_LEN(0)) / sizeof (int); + int i; + int *fd = (int *) CMSG_DATA(hdr); + + for (i = 0; i < nfd; i++) + appendFd(&ciptr->recv_fds, fd[i], 0); + } } } return size; @@ -2292,7 +2299,38 @@ TRANS(SocketReadv) (XtransConnInfo ciptr, struct iovec *buf, int size) { prmsg (2,"SocketReadv(%d,%p,%d)\n", ciptr->fd, buf, size); +#if XTRANS_SEND_FDS + { + char cmsgbuf[CMSG_SPACE(sizeof(int) * MAX_FDS)]; + struct msghdr msg = { + .msg_name = NULL, + .msg_namelen = 0, + .msg_iov = buf, + .msg_iovlen = size, + .msg_control = cmsgbuf, + .msg_controllen = CMSG_LEN(MAX_FDS * sizeof(int)) + }; + + size = recvmsg(ciptr->fd, &msg, 0); + if (size >= 0) { + struct cmsghdr *hdr; + + for (hdr = CMSG_FIRSTHDR(&msg); hdr; hdr = CMSG_NXTHDR(&msg, hdr)) { + if (hdr->cmsg_level == SOL_SOCKET && hdr->cmsg_type == SCM_RIGHTS) { + int nfd = (hdr->cmsg_len - CMSG_LEN(0)) / sizeof (int); + int i; + int *fd = (int *) CMSG_DATA(hdr); + + for (i = 0; i < nfd; i++) + appendFd(&ciptr->recv_fds, fd[i], 0); + } + } + } + return size; + } +#else return READV (ciptr, buf, size); +#endif } @@ -2305,22 +2343,32 @@ TRANS(SocketWritev) (XtransConnInfo ciptr, struct iovec *buf, int size) #if XTRANS_SEND_FDS if (ciptr->send_fds) { - struct msghdr msg; - struct fd_pass pass; - int nfd; - struct _XtransConnFd *cf; + char cmsgbuf[CMSG_SPACE(sizeof(int) * MAX_FDS)]; + int nfd = nFd(&ciptr->send_fds); + struct _XtransConnFd *cf = ciptr->send_fds; + struct msghdr msg = { + .msg_name = NULL, + .msg_namelen = 0, + .msg_iov = buf, + .msg_iovlen = size, + .msg_control = cmsgbuf, + .msg_controllen = CMSG_LEN(nfd * sizeof(int)) + }; + struct cmsghdr *hdr = CMSG_FIRSTHDR(&msg); int i; + int *fds; - nfd = nFd(&ciptr->send_fds); - cf = ciptr->send_fds; + hdr->cmsg_len = msg.msg_controllen; + hdr->cmsg_level = SOL_SOCKET; + hdr->cmsg_type = SCM_RIGHTS; + fds = (int *) CMSG_DATA(hdr); /* Set up fds */ for (i = 0; i < nfd; i++) { - pass.fd[i] = cf->fd; + fds[i] = cf->fd; cf = cf->next; } - init_msg_send(&msg, buf, size, &pass, nfd); i = sendmsg(ciptr->fd, &msg, 0); if (i > 0) discardFd(&ciptr->send_fds, cf, 0); @@ -2501,8 +2549,10 @@ Xtransport TRANS(SocketTCPFuncs) = { TRANS(SocketWrite), TRANS(SocketReadv), TRANS(SocketWritev), +#if XTRANS_SEND_FDS TRANS(SocketSendFdInvalid), TRANS(SocketRecvFdInvalid), +#endif TRANS(SocketDisconnect), TRANS(SocketINETClose), TRANS(SocketINETClose), @@ -2543,8 +2593,10 @@ Xtransport TRANS(SocketINETFuncs) = { TRANS(SocketWrite), TRANS(SocketReadv), TRANS(SocketWritev), +#if XTRANS_SEND_FDS TRANS(SocketSendFdInvalid), TRANS(SocketRecvFdInvalid), +#endif TRANS(SocketDisconnect), TRANS(SocketINETClose), TRANS(SocketINETClose), @@ -2586,8 +2638,10 @@ Xtransport TRANS(SocketINET6Funcs) = { TRANS(SocketWrite), TRANS(SocketReadv), TRANS(SocketWritev), +#if XTRANS_SEND_FDS TRANS(SocketSendFdInvalid), TRANS(SocketRecvFdInvalid), +#endif TRANS(SocketDisconnect), TRANS(SocketINETClose), TRANS(SocketINETClose), @@ -2636,8 +2690,10 @@ Xtransport TRANS(SocketLocalFuncs) = { TRANS(SocketWrite), TRANS(SocketReadv), TRANS(SocketWritev), +#if XTRANS_SEND_FDS TRANS(SocketSendFd), TRANS(SocketRecvFd), +#endif TRANS(SocketDisconnect), TRANS(SocketUNIXClose), TRANS(SocketUNIXCloseForCloning), @@ -2692,8 +2748,10 @@ Xtransport TRANS(SocketUNIXFuncs) = { TRANS(SocketWrite), TRANS(SocketReadv), TRANS(SocketWritev), +#if XTRANS_SEND_FDS TRANS(SocketSendFd), TRANS(SocketRecvFd), +#endif TRANS(SocketDisconnect), TRANS(SocketUNIXClose), TRANS(SocketUNIXCloseForCloning), diff --git a/X11/xtrans/configure.ac b/X11/xtrans/configure.ac index 8c3aa3ded..998fb06cf 100644 --- a/X11/xtrans/configure.ac +++ b/X11/xtrans/configure.ac @@ -21,7 +21,7 @@ # Initialize Autoconf AC_PREREQ([2.60]) -AC_INIT([xtrans], [1.3.0], +AC_INIT([xtrans], [1.3.2], [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], [xtrans]) AC_CONFIG_SRCDIR([Makefile.am]) diff --git a/X11/xtrans/xtrans.m4 b/X11/xtrans/xtrans.m4 index 91c6f9d2f..d84442e86 100644 --- a/X11/xtrans/xtrans.m4 +++ b/X11/xtrans/xtrans.m4 @@ -57,6 +57,41 @@ AC_DEFUN([XTRANS_TCP_FLAGS],[ AC_INCLUDES_DEFAULT #include <sys/socket.h>]) + # XPG4v2/UNIX95 added msg_control - check to see if we need to define + # _XOPEN_SOURCE to get it (such as on Solaris) + AC_CHECK_MEMBER([struct msghdr.msg_control], [], [], + [ +AC_INCLUDES_DEFAULT +#include <sys/socket.h> + ]) + # First try for Solaris in C99 compliant mode, which requires XPG6/UNIX03 + if test "x$ac_cv_member_struct_msghdr_msg_control" = xno; then + unset ac_cv_member_struct_msghdr_msg_control + AC_MSG_NOTICE([trying again with _XOPEN_SOURCE=600]) + AC_CHECK_MEMBER([struct msghdr.msg_control], + [AC_DEFINE([_XOPEN_SOURCE], [600], + [Defined if needed to expose struct msghdr.msg_control]) + ], [], [ +#define _XOPEN_SOURCE 600 +AC_INCLUDES_DEFAULT +#include <sys/socket.h> + ]) + fi + # If that didn't work, fall back to XPG5/UNIX98 with C89 + if test "x$ac_cv_member_struct_msghdr_msg_control" = xno; then + unset ac_cv_member_struct_msghdr_msg_control + AC_MSG_NOTICE([trying again with _XOPEN_SOURCE=500]) + AC_CHECK_MEMBER([struct msghdr.msg_control], + [AC_DEFINE([_XOPEN_SOURCE], [500], + [Defined if needed to expose struct msghdr.msg_control]) + ], [], [ +#define _XOPEN_SOURCE 500 +AC_INCLUDES_DEFAULT +#include <sys/socket.h> + ]) + fi + + ]) # XTRANS_TCP_FLAGS # XTRANS_CONNECTION_FLAGS() |