PKGBUILDs/extra/mariadb/0001-MDEV-18360-Prevent-set_max_open_files-from-allocating-too-many-files.patch

32 lines
1.4 KiB
Diff
Raw Normal View History

2019-01-26 22:13:57 +00:00
From 8b87e87252f7d0599a99f18cd5f51914d2611397 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Vicen=C8=9Biu=20Ciorbaru?= <vicentiu@mariadb.org>
Date: Thu, 24 Jan 2019 00:58:20 +0200
Subject: MDEV-18360 Prevent set_max_open_files from allocating too many files
If the rlimit.rlim_cur value returned by getrlimit is not the
RLIM_INFINITY magic constant, but a *very* large number, we can allocate
too many open files. Restrict set_max_open_files to only return at most
max_file_limit, as passed via its parameter.
---
mysys/my_file.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
2019-01-25 13:45:41 +00:00
diff --git a/mysys/my_file.c b/mysys/my_file.c
2019-01-26 22:13:57 +00:00
index 8d01285a94b..b3aef8494cb 100644
2019-01-25 13:45:41 +00:00
--- a/mysys/my_file.c
+++ b/mysys/my_file.c
@@ -52,10 +52,9 @@ static uint set_max_open_files(uint max_file_limit)
DBUG_PRINT("info", ("rlim_cur: %u rlim_max: %u",
(uint) rlimit.rlim_cur,
(uint) rlimit.rlim_max));
- if ((ulonglong) rlimit.rlim_cur == (ulonglong) RLIM_INFINITY)
- rlimit.rlim_cur = max_file_limit;
- if (rlimit.rlim_cur >= max_file_limit)
- DBUG_RETURN(rlimit.rlim_cur); /* purecov: inspected */
+ if ((ulonglong) rlimit.rlim_cur == (ulonglong) RLIM_INFINITY ||
+ rlimit.rlim_cur >= max_file_limit)
+ DBUG_RETURN(max_file_limit);
rlimit.rlim_cur= rlimit.rlim_max= max_file_limit;
if (setrlimit(RLIMIT_NOFILE, &rlimit))
max_file_limit= old_cur; /* Use original value */