commit 438cc41: [Minor] Improve setrlimit logging

Vsevolod Stakhov vsevolod at highsecure.ru
Tue Mar 19 14:35:03 UTC 2019


Author: Vsevolod Stakhov
Date: 2019-03-19 14:28:19 +0000
URL: https://github.com/rspamd/rspamd/commit/438cc41ff70131c73c0c87e7532028684a249555 (HEAD -> master)

[Minor] Improve setrlimit logging

---
 src/libserver/worker_util.c | 33 ++++++++++++++++++++++++++-------
 1 file changed, 26 insertions(+), 7 deletions(-)

diff --git a/src/libserver/worker_util.c b/src/libserver/worker_util.c
index 26aacd160..827dc7fbb 100644
--- a/src/libserver/worker_util.c
+++ b/src/libserver/worker_util.c
@@ -539,6 +539,19 @@ rspamd_worker_set_limits (struct rspamd_main *rspamd_main,
 					cf->rlimit_nofile,
 					strerror (errno));
 		}
+
+		memset (&rlmt, 0, sizeof (rlmt));
+
+		if (getrlimit (RLIMIT_NOFILE, &rlmt) == -1) {
+			msg_warn_main ("cannot get max files rlimit: %HL, %s",
+					cf->rlimit_maxcore,
+					strerror (errno));
+		}
+		else {
+			msg_info_main ("set max file descriptors limit: %HL cur and %HL max",
+					(guint64) rlmt.rlim_cur,
+					(guint64) rlmt.rlim_max);
+		}
 	}
 
 	if (rspamd_main->cores_throttling) {
@@ -570,14 +583,20 @@ rspamd_worker_set_limits (struct rspamd_main *rspamd_main,
 						cf->rlimit_maxcore,
 						strerror (errno));
 			}
-
-			if (rlmt.rlim_cur != cf->rlimit_maxcore ||
+			else {
+				if (rlmt.rlim_cur != cf->rlimit_maxcore ||
 					rlmt.rlim_max != cf->rlimit_maxcore) {
-				msg_warn_main ("setting of limits was unsuccessful: %HL was wanted, "
-							   "but we have %HL cur and %HL max",
-						cf->rlimit_maxcore,
-						(guint64)rlmt.rlim_cur,
-						(guint64)rlmt.rlim_max);
+					msg_warn_main ("setting of limits was unsuccessful: %HL was wanted, "
+								   "but we have %HL cur and %HL max",
+							cf->rlimit_maxcore,
+							(guint64) rlmt.rlim_cur,
+							(guint64) rlmt.rlim_max);
+				}
+				else {
+					msg_info_main ("set core file limit: %HL cur and %HL max",
+							(guint64) rlmt.rlim_cur,
+							(guint64) rlmt.rlim_max);
+				}
 			}
 		}
 	}


More information about the Commits mailing list