[OE-core] [PATCH 2/2] rpm: Assume a max limit of 1024 open files
Peter Kjellerstedt
peter.kjellerstedt at axis.com
Thu May 10 22:20:42 UTC 2018
If sysconf(_SC_OPEN_MAX) is much greater than the usual 1024 (for
example inside a Docker container), the performance drops sharply.
Signed-off-by: Peter Kjellerstedt <peter.kjellerstedt at axis.com>
---
...001-Assume-a-max-limit-of-1024-open-files.patch | 61 ++++++++++++++++++++++
meta/recipes-devtools/rpm/rpm_4.14.1.bb | 2 +
2 files changed, 63 insertions(+)
create mode 100644 meta/recipes-devtools/rpm/files/0001-Assume-a-max-limit-of-1024-open-files.patch
diff --git a/meta/recipes-devtools/rpm/files/0001-Assume-a-max-limit-of-1024-open-files.patch b/meta/recipes-devtools/rpm/files/0001-Assume-a-max-limit-of-1024-open-files.patch
new file mode 100644
index 0000000000..c5ca892aa2
--- /dev/null
+++ b/meta/recipes-devtools/rpm/files/0001-Assume-a-max-limit-of-1024-open-files.patch
@@ -0,0 +1,61 @@
+From 0d40bae6c02799ea35c95acfaa8991ddf92ab232 Mon Sep 17 00:00:00 2001
+From: Peter Kjellerstedt <pkj at axis.com>
+Date: Fri, 4 May 2018 22:47:11 +0200
+Subject: [PATCH] Assume a max limit of 1024 open files
+
+If sysconf(_SC_OPEN_MAX) is much greater than the usual 1024 (for
+example inside a Docker container), the performance drops sharply.
+
+Upstream-Status: Inappropriate [upstream needs to come up with a better fix]
+Signed-off-by: Peter Kjellerstedt <peter.kjellerstedt at axis.com>
+---
+ lib/rpmscript.c | 7 +------
+ luaext/lposix.c | 8 ++------
+ 2 files changed, 3 insertions(+), 12 deletions(-)
+
+diff --git a/lib/rpmscript.c b/lib/rpmscript.c
+index 19a28fb75..ca7838835 100644
+--- a/lib/rpmscript.c
++++ b/lib/rpmscript.c
+@@ -160,17 +160,12 @@ static void doScriptExec(ARGV_const_t argv, ARGV_const_t prefixes,
+ int flag;
+ int fdno;
+ int xx;
+- int open_max;
+
+ /* SIGPIPE is ignored in rpm, reset to default for the scriptlet */
+ (void) signal(SIGPIPE, SIG_DFL);
+
+ /* XXX Force FD_CLOEXEC on all inherited fdno's. */
+- open_max = sysconf(_SC_OPEN_MAX);
+- if (open_max == -1) {
+- open_max = 1024;
+- }
+- for (fdno = 3; fdno < open_max; fdno++) {
++ for (fdno = 3; fdno < 1024; fdno++) {
+ flag = fcntl(fdno, F_GETFD);
+ if (flag == -1 || (flag & FD_CLOEXEC))
+ continue;
+diff --git a/luaext/lposix.c b/luaext/lposix.c
+index 0a7c26c71..2640db51c 100644
+--- a/luaext/lposix.c
++++ b/luaext/lposix.c
+@@ -335,16 +335,12 @@ static int Pexec(lua_State *L) /** exec(path,[args]) */
+ const char *path = luaL_checkstring(L, 1);
+ int i,n=lua_gettop(L);
+ char **argv;
+- int flag, fdno, open_max;
++ int flag, fdno;
+
+ if (!have_forked)
+ return luaL_error(L, "exec not permitted in this context");
+
+- open_max = sysconf(_SC_OPEN_MAX);
+- if (open_max == -1) {
+- open_max = 1024;
+- }
+- for (fdno = 3; fdno < open_max; fdno++) {
++ for (fdno = 3; fdno < 1024; fdno++) {
+ flag = fcntl(fdno, F_GETFD);
+ if (flag == -1 || (flag & FD_CLOEXEC))
+ continue;
diff --git a/meta/recipes-devtools/rpm/rpm_4.14.1.bb b/meta/recipes-devtools/rpm/rpm_4.14.1.bb
index 85d791ce5c..55b0396cd8 100644
--- a/meta/recipes-devtools/rpm/rpm_4.14.1.bb
+++ b/meta/recipes-devtools/rpm/rpm_4.14.1.bb
@@ -41,6 +41,8 @@ SRC_URI = "git://github.com/rpm-software-management/rpm;branch=rpm-4.14.x \
file://0001-perl-disable-auto-reqs.patch \
file://0001-configure.ac-add-option-for-dbus.patch \
"
+SRC_URI_append_class-native = " file://0001-Assume-a-max-limit-of-1024-open-files.patch"
+SRC_URI_append_class-nativesdk = " file://0001-Assume-a-max-limit-of-1024-open-files.patch"
PE = "1"
SRCREV = "bfee1410af51c1cc9724791fb8d985260a62102b"
--
2.12.0
More information about the Openembedded-core
mailing list