diff options
Diffstat (limited to 'X11/xtrans/Xtranssock.c')
-rw-r--r-- | X11/xtrans/Xtranssock.c | 61 |
1 files changed, 37 insertions, 24 deletions
diff --git a/X11/xtrans/Xtranssock.c b/X11/xtrans/Xtranssock.c index fdf1dd774..6d4207f1c 100644 --- a/X11/xtrans/Xtranssock.c +++ b/X11/xtrans/Xtranssock.c @@ -129,11 +129,15 @@ from the copyright holders. #include <X11/Xw32defs.h> #undef close #define close closesocket +#undef ECONNREFUSED #define ECONNREFUSED WSAECONNREFUSED +#undef EADDRINUSE #define EADDRINUSE WSAEADDRINUSE +#undef EPROTOTYPE #define EPROTOTYPE WSAEPROTOTYPE #undef EWOULDBLOCK #define EWOULDBLOCK WSAEWOULDBLOCK +#undef EINPROGRESS #define EINPROGRESS WSAEINPROGRESS #undef EINTR #define EINTR WSAEINTR @@ -242,13 +246,20 @@ static int TRANS(SocketINETClose) (XtransConnInfo ciptr); #endif #if defined HAVE_SOCKLEN_T || (defined(IPv6) && defined(AF_INET6)) +#ifdef _MSC_VER +# define SOCKLEN_T int +#else # define SOCKLEN_T socklen_t +#endif #elif defined(SVR4) || defined(__SVR4) || defined(__SCO__) # define SOCKLEN_T size_t #else # define SOCKLEN_T int #endif +static int TRANS(SocketRecvFdInvalid)(XtransConnInfo ciptr); +static int TRANS(SocketSendFdInvalid)(XtransConnInfo ciptr, int fd, int do_close); + /* * These are some utility function used by the real interface function below. */ @@ -640,7 +651,7 @@ TRANS(SocketOpenCOTSServer) (Xtransport *thistrans, char *protocol, if (Sockettrans2devtab[i].family == AF_INET6) { int one = 1; - setsockopt(ciptr->fd, IPPROTO_IPV6, IPV6_V6ONLY, &one, sizeof(int)); + setsockopt(ciptr->fd, IPPROTO_IPV6, IPV6_V6ONLY, (const char *)&one, sizeof(int)); } #endif /* Save the index for later use */ @@ -725,7 +736,7 @@ TRANS(SocketOpenCLTSServer) (Xtransport *thistrans, char *protocol, if (Sockettrans2devtab[i].family == AF_INET6) { int one = 1; - setsockopt(ciptr->fd, IPPROTO_IPV6, IPV6_V6ONLY, &one, sizeof(int)); + setsockopt(ciptr->fd, IPPROTO_IPV6, IPV6_V6ONLY, (const char *)&one, sizeof(int)); } #endif /* Save the index for later use */ @@ -850,6 +861,10 @@ set_sun_path(const char *port, const char *upath, char *path, int abstract) #ifdef TRANS_SERVER +#ifndef SO_BINDRETRYCOUNT +#define SO_BINDRETRYCOUNT 20 +#endif + static int TRANS(SocketCreateListener) (XtransConnInfo ciptr, struct sockaddr *sockname, @@ -867,7 +882,7 @@ TRANS(SocketCreateListener) (XtransConnInfo ciptr, || Sockettrans2devtab[ciptr->index].family == AF_INET6 #endif ) - retry = 20; + retry = SO_BINDRETRYCOUNT; else retry = 0; @@ -1247,7 +1262,11 @@ TRANS(SocketINETAccept) (XtransConnInfo ciptr, int *status) { XtransConnInfo newciptr; +#if defined(IPv6) && defined(AF_INET6) + struct sockaddr_storage sockname; +#else struct sockaddr_in sockname; +#endif SOCKLEN_T namelen = sizeof(sockname); prmsg (2, "SocketINETAccept(%p,%d)\n", ciptr, ciptr->fd); @@ -2181,6 +2200,15 @@ TRANS(SocketSendFd) (XtransConnInfo ciptr, int fd, int do_close) return 0; } +#define MAX_FDS 128 + +union fd_pass { + struct cmsghdr cmsghdr; + char buf[CMSG_SPACE(MAX_FDS * sizeof(int))]; +}; + +#endif /* XTRANS_SEND_FDS */ + static int TRANS(SocketRecvFdInvalid)(XtransConnInfo ciptr) { @@ -2195,15 +2223,6 @@ TRANS(SocketSendFdInvalid)(XtransConnInfo ciptr, int fd, int do_close) return -1; } -#define MAX_FDS 128 - -union fd_pass { - struct cmsghdr cmsghdr; - char buf[CMSG_SPACE(MAX_FDS * sizeof(int))]; -}; - -#endif /* XTRANS_SEND_FDS */ - static int TRANS(SocketRead) (XtransConnInfo ciptr, char *buf, int size) @@ -2514,10 +2533,8 @@ Xtransport TRANS(SocketTCPFuncs) = { TRANS(SocketWrite), TRANS(SocketReadv), TRANS(SocketWritev), -#if XTRANS_SEND_FDS - TRANS(SocketSendFdInvalid), - TRANS(SocketRecvFdInvalid), -#endif + TRANS(SocketSendFdInvalid), + TRANS(SocketRecvFdInvalid), TRANS(SocketDisconnect), TRANS(SocketINETClose), TRANS(SocketINETClose), @@ -2558,10 +2575,8 @@ Xtransport TRANS(SocketINETFuncs) = { TRANS(SocketWrite), TRANS(SocketReadv), TRANS(SocketWritev), -#if XTRANS_SEND_FDS - TRANS(SocketSendFdInvalid), - TRANS(SocketRecvFdInvalid), -#endif + TRANS(SocketSendFdInvalid), + TRANS(SocketRecvFdInvalid), TRANS(SocketDisconnect), TRANS(SocketINETClose), TRANS(SocketINETClose), @@ -2603,10 +2618,8 @@ Xtransport TRANS(SocketINET6Funcs) = { TRANS(SocketWrite), TRANS(SocketReadv), TRANS(SocketWritev), -#if XTRANS_SEND_FDS - TRANS(SocketSendFdInvalid), - TRANS(SocketRecvFdInvalid), -#endif + TRANS(SocketSendFdInvalid), + TRANS(SocketRecvFdInvalid), TRANS(SocketDisconnect), TRANS(SocketINETClose), TRANS(SocketINETClose), |