1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
From 982e47df7b82c5ffe3c414cf5641f08dba0f0e64 Mon Sep 17 00:00:00 2001
From: Alexander Kanavin <alex.kanavin@gmail.com>
Date: Fri, 26 Jan 2018 16:32:04 +0200
Subject: [PATCH] Revert "Set FD_CLOEXEC on opened files before exec from lua
script is called"
This reverts commit 7a7c31f551ff167f8718aea6d5048f6288d60205.
The reason is that when _SC_OPEN_MAX is much higher than the usual 1024
(for example inside docker), the performance drops sharply.
Upstream has been notified:
https://bugzilla.redhat.com/show_bug.cgi?id=1537564
Upstream-Status: Inappropriate [upstream needs to come up with a better fix]
Signed-off-by: Alexander Kanavin <alex.kanavin@gmail.com>
---
luaext/lposix.c | 12 ------------
1 file changed, 12 deletions(-)
diff --git a/luaext/lposix.c b/luaext/lposix.c
index 0a7c26c71..c578c5a11 100644
--- a/luaext/lposix.c
+++ b/luaext/lposix.c
@@ -335,22 +335,10 @@ 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;
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++) {
- flag = fcntl(fdno, F_GETFD);
- if (flag == -1 || (flag & FD_CLOEXEC))
- continue;
- fcntl(fdno, F_SETFD, FD_CLOEXEC);
- }
-
argv = malloc((n+1)*sizeof(char*));
if (argv==NULL) return luaL_error(L,"not enough memory");
argv[0] = (char*)path;
--
2.15.1
|