From: Justin Cinkelj <justin.cink...@xlab.si>
Committer: Nadav Har'El <n...@scylladb.com>
Branch: master

wrk: remove check of file descriptor value

wrk expects to be the only user of file descriptors, and checks their
integer value for unexpectedly high values. On OSv are file descriptors
shared among all apps/threads, and fd value does get high if other apps
started before wrk. Fix this by commenting out the check.

Signed-off-by: Justin Cinkelj <justin.cink...@xlab.si>
Message-Id: <20170830184702.17777-1-justin.cink...@xlab.si>

---
diff --git a/wrk/0003-wrk-remove-check-of-file-descriptor-value.patch b/wrk/0003-wrk-remove-check-of-file-descriptor-value.patch
--- a/wrk/0003-wrk-remove-check-of-file-descriptor-value.patch
+++ b/wrk/0003-wrk-remove-check-of-file-descriptor-value.patch
@@ -0,0 +1,37 @@
+From 96322a4915582f69c5d7ef1816c215885b681ba7 Mon Sep 17 00:00:00 2001
+From: Justin Cinkelj <justin.cink...@xlab.si>
+Date: Wed, 30 Aug 2017 16:37:06 +0200
+Subject: [PATCH] wrk: remove check of file descriptor value
+
+The check incorrectly fails on OSv. With say 1 conection, max expected
+fd was 10+3*1. Once other apps consume some fds, the check fails.
+
+Signed-off-by: Justin Cinkelj <justin.cink...@xlab.si>
+---
+ src/ae.c | 9 +++++++--
+ 1 file changed, 7 insertions(+), 2 deletions(-)
+
+diff --git a/src/ae.c b/src/ae.c
+index 90be4e2..ef8ca01 100644
+--- a/src/ae.c
++++ b/src/ae.c
+@@ -105,9 +105,14 @@ void aeStop(aeEventLoop *eventLoop) {
+ int aeCreateFileEvent(aeEventLoop *eventLoop, int fd, int mask,
+         aeFileProc *proc, void *clientData)
+ {
++    // The eventLoop->setsize is set by:
++ // ./src/wrk.c:145: t->loop = aeCreateEventLoop(10 + cfg.connections * 3);
++    // This does not work on OSv. FD numbers are shared by all apps,
++    // and can get arbitrary large.
+     if (fd >= eventLoop->setsize) {
+-        errno = ERANGE;
+-        return AE_ERR;
++ //fprintf(stderr, "INFO: wrk, allow large fd=%d > %d in aeCreateFileEvent on OSv\n", fd, eventLoop->setsize);
++        //errno = ERANGE;
++        //return AE_ERR;
+     }
+     aeFileEvent *fe = &eventLoop->events[fd];
+
+--
+2.9.4
+
diff --git a/wrk/Makefile b/wrk/Makefile
--- a/wrk/Makefile
+++ b/wrk/Makefile
@@ -13,6 +13,7 @@ wrk: $(tarball)
        mv wrk-$(version) wrk
        cd wrk && patch -p1 < ../0001-make-build-as-DSO.patch
        cd wrk && patch -p1 < ../wrk-fix-uninit-connection.patch
+ cd wrk && patch -p1 < ../0003-wrk-remove-check-of-file-descriptor-value.patch

 clean:
        rm -rf wrk $(tarball)

--
You received this message because you are subscribed to the Google Groups "OSv 
Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to osv-dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to