]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: checks: use my_closefrom() to close all FDs
authorWilly Tarreau <w@1wt.eu>
Thu, 21 Feb 2019 21:22:06 +0000 (22:22 +0100)
committerWilly Tarreau <w@1wt.eu>
Thu, 21 Feb 2019 21:22:06 +0000 (22:22 +0100)
Instead of looping on all FDs, let's use my_closefrom() which does it
respecting the current process' limits and possibly doing it more
efficiently.

src/checks.c

index e4c7a4896dc53b437ee46da1db7ae1e6b893e382..6d7b6aa271df89e2751c865346d10dadce6316d1 100644 (file)
@@ -1970,8 +1970,7 @@ static int connect_proc_chk(struct task *t)
                /* close all FDs. Keep stdin/stdout/stderr in verbose mode */
                fd = (global.mode & (MODE_QUIET|MODE_VERBOSE)) == MODE_QUIET ? 0 : 3;
 
-               while (fd < global.rlimit_nofile)
-                       close(fd++);
+               my_closefrom(fd);
 
                environ = check->envp;
                extchk_setenv(check, EXTCHK_HAPROXY_SERVER_CURCONN, ultoa_r(s->cur_sess, buf, sizeof(buf)));