diff options
author | Arfrever Frehtes Taifersar Arahesis <arfrever@gentoo.org> | 2009-06-12 23:10:32 +0000 |
---|---|---|
committer | Arfrever Frehtes Taifersar Arahesis <arfrever@gentoo.org> | 2009-06-12 23:10:32 +0000 |
commit | 5457fcf73c091d9b2ef91074dcbcff50f5218186 (patch) | |
tree | c269722dacf9b4d8c986544087bf1476394d0c5d /net-misc | |
parent | live ebuild moved to my dev overlay (diff) | |
download | gentoo-2-5457fcf73c091d9b2ef91074dcbcff50f5218186.tar.gz gentoo-2-5457fcf73c091d9b2ef91074dcbcff50f5218186.tar.bz2 gentoo-2-5457fcf73c091d9b2ef91074dcbcff50f5218186.zip |
Fix support for old kernels + new glibc built against new kernel headers (bug #264101).
(Portage version: 13636-svn/cvs/Linux x86_64)
Diffstat (limited to 'net-misc')
-rw-r--r-- | net-misc/neon/ChangeLog | 7 | ||||
-rw-r--r-- | net-misc/neon/files/neon-0.28.4-SOCK_CLOEXEC.patch | 122 | ||||
-rw-r--r-- | net-misc/neon/neon-0.28.4.ebuild | 4 |
3 files changed, 131 insertions, 2 deletions
diff --git a/net-misc/neon/ChangeLog b/net-misc/neon/ChangeLog index 425016f27b38..70978a02e430 100644 --- a/net-misc/neon/ChangeLog +++ b/net-misc/neon/ChangeLog @@ -1,6 +1,11 @@ # ChangeLog for net-misc/neon # Copyright 1999-2009 Gentoo Foundation; Distributed under the GPL v2 -# $Header: /var/cvsroot/gentoo-x86/net-misc/neon/ChangeLog,v 1.124 2009/05/03 18:38:47 maekke Exp $ +# $Header: /var/cvsroot/gentoo-x86/net-misc/neon/ChangeLog,v 1.125 2009/06/12 23:10:32 arfrever Exp $ + + 12 Jun 2009; Arfrever Frehtes Taifersar Arahesis <arfrever@gentoo.org> + neon-0.28.4.ebuild, +files/neon-0.28.4-SOCK_CLOEXEC.patch: + Fix support for old kernels + new glibc built against new kernel headers + (bug #264101). 03 May 2009; Markus Meier <maekke@gentoo.org> neon-0.28.4.ebuild: amd64 stable, bug #267272 diff --git a/net-misc/neon/files/neon-0.28.4-SOCK_CLOEXEC.patch b/net-misc/neon/files/neon-0.28.4-SOCK_CLOEXEC.patch new file mode 100644 index 000000000000..6ac1cb7f1e0f --- /dev/null +++ b/net-misc/neon/files/neon-0.28.4-SOCK_CLOEXEC.patch @@ -0,0 +1,122 @@ +--- src/ne_socket.c ++++ src/ne_socket.c +@@ -1,6 +1,6 @@ + /* + Socket handling routines +- Copyright (C) 1998-2008, Joe Orton <joe@manyfish.co.uk> ++ Copyright (C) 1998-2009, Joe Orton <joe@manyfish.co.uk> + Copyright (C) 1999-2000 Tommi Komulainen <Tommi.Komulainen@iki.fi> + Copyright (C) 2004 Aleix Conchillo Flaque <aleix@member.fsf.org> + +@@ -1007,6 +1007,20 @@ + ne_free(addr); + } + ++/* Perform a connect() for given fd, handling EINTR retries. Returns ++ * zero on success or -1 on failure, in which case, ne_errno is set ++ * appropriately. */ ++static int raw_connect(int fd, const struct sockaddr *sa, size_t salen) ++{ ++ int ret; ++ ++ do { ++ ret = connect(fd, sa, salen); ++ } while (ret < 0 && NE_ISINTR(ne_errno)); ++ ++ return ret; ++} ++ + /* Perform a connect() for fd to address sa of length salen, with a + * timeout if supported on this platform. Returns zero on success or + * NE_SOCK_* on failure, with sock->error set appropriately. */ +@@ -1021,12 +1035,17 @@ + + /* Get flags and then set O_NONBLOCK. */ + flags = fcntl(fd, F_GETFL); +- if (fcntl(fd, F_SETFL, flags | O_NONBLOCK) == -1) { ++ if (flags & O_NONBLOCK) { ++ /* This socket was created using SOCK_NONBLOCK... flip the ++ * bit for restoring flags later. */ ++ flags &= ~O_NONBLOCK; ++ } ++ else if (fcntl(fd, F_SETFL, flags | O_NONBLOCK) == -1) { + set_strerror(sock, errno); + return NE_SOCK_ERROR; + } + +- ret = connect(fd, sa, salen); ++ ret = raw_connect(fd, sa, salen); + if (ret == -1) { + errnum = ne_errno; + if (NE_ISINPROGRESS(errnum)) { +@@ -1070,7 +1089,7 @@ + } else + #endif /* USE_NONBLOCKING_CONNECT */ + { +- ret = connect(fd, sa, salen); ++ ret = raw_connect(fd, sa, salen); + + if (ret < 0) { + set_strerror(sock, errno); +@@ -1196,19 +1215,43 @@ + } + } + +-#ifndef SOCK_CLOEXEC +-#define SOCK_CLOEXEC 0 +-#define USE_CLOEXEC ++#ifdef SOCK_CLOEXEC ++/* sock_cloexec is initialized to SOCK_CLOEXEC and cleared to zero if ++ * a socket() call ever fails with EINVAL. */ ++static int sock_cloexec = SOCK_CLOEXEC; ++#define RETRY_ON_EINVAL ++#else ++#define sock_cloexec 0 + #endif + + int ne_sock_connect(ne_socket *sock, + const ne_inet_addr *addr, unsigned int port) + { + int fd, ret; ++ int type = SOCK_STREAM | sock_cloexec; ++ ++#if defined(RETRY_ON_EINVAL) && defined(SOCK_NONBLOCK) \ ++ && defined(USE_NONBLOCKING_CONNECT) ++ /* If the SOCK_NONBLOCK flag is defined, and the retry-on-EINVAL ++ * logic is enabled, and the socket has a configured timeout, then ++ * also use the SOCK_NONBLOCK flag to save enabling O_NONBLOCK ++ * later. */ ++ if (sock->cotimeout && sock_cloexec) { ++ type |= SOCK_NONBLOCK; ++ } ++#endif + + /* use SOCK_STREAM rather than ai_socktype: some getaddrinfo + * implementations do not set ai_socktype, e.g. RHL6.2. */ +- fd = socket(ia_family(addr), SOCK_STREAM | SOCK_CLOEXEC, ia_proto(addr)); ++ fd = socket(ia_family(addr), type, ia_proto(addr)); ++#ifdef RETRY_ON_EINVAL ++ /* Handle forwards compat for new glibc on an older kernels; clear ++ * the sock_cloexec flag and retry the call: */ ++ if (fd < 0 && sock_cloexec && errno == EINVAL) { ++ sock_cloexec = 0; ++ fd = socket(ia_family(addr), SOCK_STREAM, ia_proto(addr)); ++ } ++#endif + if (fd < 0) { + set_strerror(sock, ne_errno); + return -1; +@@ -1223,9 +1266,10 @@ + #endif + + #if defined(HAVE_FCNTL) && defined(F_GETFD) && defined(F_SETFD) \ +- && defined(FD_CLOEXEC) && defined(USE_CLOEXEC) +- /* Set the FD_CLOEXEC bit for the new fd. */ +- if ((ret = fcntl(fd, F_GETFD)) >= 0) { ++ && defined(FD_CLOEXEC) ++ /* Set the FD_CLOEXEC bit for the new fd, if the socket was not ++ * created with the CLOEXEC bit already set. */ ++ if (!sock_cloexec && (ret = fcntl(fd, F_GETFD)) >= 0) { + fcntl(fd, F_SETFD, ret | FD_CLOEXEC); + /* ignore failure; not a critical error. */ + } diff --git a/net-misc/neon/neon-0.28.4.ebuild b/net-misc/neon/neon-0.28.4.ebuild index 614fe52750e8..96dc2347bb25 100644 --- a/net-misc/neon/neon-0.28.4.ebuild +++ b/net-misc/neon/neon-0.28.4.ebuild @@ -1,6 +1,6 @@ # Copyright 1999-2009 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 -# $Header: /var/cvsroot/gentoo-x86/net-misc/neon/neon-0.28.4.ebuild,v 1.6 2009/05/03 18:38:47 maekke Exp $ +# $Header: /var/cvsroot/gentoo-x86/net-misc/neon/neon-0.28.4.ebuild,v 1.7 2009/06/12 23:10:32 arfrever Exp $ inherit autotools eutils libtool versionator @@ -46,6 +46,8 @@ src_unpack() { sed -i -e "s/ALL_LINGUAS=.*/ALL_LINGUAS=\"${linguas}\"/g" configure.in sed -i -e "s/socks5/socks/g" macros/neon.m4 + epatch "${FILESDIR}/${P}-SOCK_CLOEXEC.patch" + AT_M4DIR="macros" eautoreconf } |