Date: Thursday, October 5, 2017 @ 09:37:16 Author: bpiotrowski Revision: 261619
20-2: fix uv__getiovmax returning -1 (FS#55587) https://github.com/cjdelisle/cjdns/pull/1107 Added: cjdns/trunk/1107.patch Modified: cjdns/trunk/PKGBUILD ------------+ 1107.patch | 143 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ PKGBUILD | 14 ++++- 2 files changed, 153 insertions(+), 4 deletions(-) Added: 1107.patch =================================================================== --- 1107.patch (rev 0) +++ 1107.patch 2017-10-05 09:37:16 UTC (rev 261619) @@ -0,0 +1,143 @@ +From 249c5b7e57f4d383978eab1d6340a1f31994a606 Mon Sep 17 00:00:00 2001 +From: PoroCYon <[email protected]> +Date: Mon, 11 Sep 2017 17:47:34 +0200 +Subject: [PATCH 1/4] fix uv__getiovmax returning -1 + +--- + node_build/dependencies/libuv/src/unix/stream.c | 14 ++++++++++++-- + 1 file changed, 12 insertions(+), 2 deletions(-) + +diff --git a/node_build/dependencies/libuv/src/unix/stream.c b/node_build/dependencies/libuv/src/unix/stream.c +index 1175f9bcf..711f16baa 100644 +--- a/node_build/dependencies/libuv/src/unix/stream.c ++++ b/node_build/dependencies/libuv/src/unix/stream.c +@@ -714,8 +714,18 @@ static int uv__getiovmax() { + return IOV_MAX; + #elif defined(_SC_IOV_MAX) + static int iovmax = -1; +- if (iovmax == -1) ++ if (iovmax == -1) { ++ errno = 0; + iovmax = sysconf(_SC_IOV_MAX); ++ if (iovmax == -1) { ++ if (errno) { ++ iovmax = 1; ++ } ++ /*else { ++ iovmax = 1024; ++ }*/ ++ } ++ } + return iovmax; + #else + return 1024; +@@ -752,7 +762,7 @@ static void uv__write(uv_stream_t* stream) { + iovmax = uv__getiovmax(); + + /* Limit iov count to avoid EINVALs from writev() */ +- if (iovcnt > iovmax) ++ if (iovcnt > iovmax && iovmax != -1) + iovcnt = iovmax; + + /* + +From fc73f49ebdf668d4185dcd4f89807d4444562655 Mon Sep 17 00:00:00 2001 +From: PoroCYon <[email protected]> +Date: Mon, 11 Sep 2017 17:53:56 +0200 +Subject: [PATCH 2/4] fix uv__getiovmax calling sysconf(3) even after a 'valid' + -1 + +--- + node_build/dependencies/libuv/src/unix/stream.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/node_build/dependencies/libuv/src/unix/stream.c b/node_build/dependencies/libuv/src/unix/stream.c +index 711f16baa..b721570d8 100644 +--- a/node_build/dependencies/libuv/src/unix/stream.c ++++ b/node_build/dependencies/libuv/src/unix/stream.c +@@ -713,8 +713,8 @@ static int uv__getiovmax() { + #if defined(IOV_MAX) + return IOV_MAX; + #elif defined(_SC_IOV_MAX) +- static int iovmax = -1; +- if (iovmax == -1) { ++ static int iovmax = -2; ++ if (iovmax == -2) { + errno = 0; + iovmax = sysconf(_SC_IOV_MAX); + if (iovmax == -1) { + +From b119f17342a806d48a750c56adb32c17316f931e Mon Sep 17 00:00:00 2001 +From: PoroCYon <[email protected]> +Date: Tue, 12 Sep 2017 17:35:01 +0200 +Subject: [PATCH 3/4] On Linux, take UIO_IOVMAX into account. + +--- + node_build/dependencies/libuv/src/unix/stream.c | 14 ++++++++++++++ + 1 file changed, 14 insertions(+) + +diff --git a/node_build/dependencies/libuv/src/unix/stream.c b/node_build/dependencies/libuv/src/unix/stream.c +index b721570d8..09add6387 100644 +--- a/node_build/dependencies/libuv/src/unix/stream.c ++++ b/node_build/dependencies/libuv/src/unix/stream.c +@@ -19,6 +19,10 @@ + * IN THE SOFTWARE. + */ + ++#if !defined(_GNU_SOURCE) && defined(__linux__) ++#define _GNU_SOURCE ++#endif ++ + #include "uv.h" + #include "internal.h" + +@@ -35,6 +39,10 @@ + #include <unistd.h> + #include <limits.h> /* IOV_MAX */ + ++#if !defined(IOV_MAX) && defined(__linux__) ++#include <linux/uio.h> ++#endif ++ + #if defined(__APPLE__) + # include <sys/event.h> + # include <sys/time.h> +@@ -721,9 +729,15 @@ static int uv__getiovmax() { + if (errno) { + iovmax = 1; + } ++#ifdef __linux__ ++ else { ++ iovmax = UIO_IOVMAX; ++ } ++#else + /*else { + iovmax = 1024; + }*/ ++#endif + } + } + return iovmax; + +From 690d80c6a3e11cf6731b589d8d7752f8b2540594 Mon Sep 17 00:00:00 2001 +From: PoroCYon <[email protected]> +Date: Tue, 12 Sep 2017 17:43:17 +0200 +Subject: [PATCH 4/4] Fix buid on arm64-v8a + +--- + node_build/dependencies/libuv/src/unix/stream.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/node_build/dependencies/libuv/src/unix/stream.c b/node_build/dependencies/libuv/src/unix/stream.c +index 09add6387..c4a2c529e 100644 +--- a/node_build/dependencies/libuv/src/unix/stream.c ++++ b/node_build/dependencies/libuv/src/unix/stream.c +@@ -729,7 +729,7 @@ static int uv__getiovmax() { + if (errno) { + iovmax = 1; + } +-#ifdef __linux__ ++#if defined(__linux__) && defined(UIO_IOVMAX) + else { + iovmax = UIO_IOVMAX; + } Modified: PKGBUILD =================================================================== --- PKGBUILD 2017-10-05 09:33:19 UTC (rev 261618) +++ PKGBUILD 2017-10-05 09:37:16 UTC (rev 261619) @@ -6,7 +6,7 @@ pkgname=cjdns pkgver=20 -pkgrel=1 +pkgrel=2 pkgdesc='Routing engine designed for security, scalability, speed and ease of use' url='https://github.com/cjdelisle/cjdns' arch=('i686' 'x86_64') @@ -15,10 +15,16 @@ optdepends=('nodejs: optional utilities support') makedepends=('nodejs' 'python2') install=cjdns.install -source=(${pkgname}-${pkgver}.tar.gz::https://github.com/cjdelisle/${pkgname}/archive/cjdns-v${pkgver}.tar.gz) -sha256sums=('08a1029d47f3b666eec9d901b2e2fe6e8f971348c10465427db95e4153ecd8b7') -sha512sums=('7da6537ed417d33ebd9ffa27a9e08758c48ea99930a85497853f0ee43cc87501434ab76bee0e69dc935b3338959d86bcb4bef527f1b93887b0a3662b4ab55879') +source=(${pkgname}-${pkgver}.tar.gz::https://github.com/cjdelisle/${pkgname}/archive/cjdns-v${pkgver}.tar.gz + 1107.patch) +sha256sums=('e8c849fca47012412c640969f09a44300010ef5e9649e08a0d39f87795d124f5' + '0af8770c9b9948cb90fe9b4823a4abed4db9b72f6e13a26435000a4ea6cad732') +prepare() { + cd ${pkgname}-${pkgname}-v${pkgver} + patch -p1 -i "${srcdir}/1107.patch" +} + build() { cd ${pkgname}-${pkgname}-v${pkgver} CJDNS_RELEASE_VERSION="${pkgver}" \
