commit 7fa61a38: [Minor] Print limit values on start of the worker

Vsevolod Stakhov vsevolod at highsecure.ru
Tue Mar 19 18:00:05 UTC 2019


Author: Vsevolod Stakhov
Date: 2019-03-19 17:56:50 +0000
URL: https://github.com/rspamd/rspamd/commit/7fa61a389c9560d3afcb655fae441f24d07cb80a (HEAD -> master)

[Minor] Print limit values on start of the worker

---
 src/libserver/protocol.c    |  2 +-
 src/libserver/worker_util.c | 39 +++++++++++++++++++++++++++++++++------
 2 files changed, 34 insertions(+), 7 deletions(-)

diff --git a/src/libserver/protocol.c b/src/libserver/protocol.c
index 2a9cc605a..23690f45a 100644
--- a/src/libserver/protocol.c
+++ b/src/libserver/protocol.c
@@ -1328,7 +1328,7 @@ rspamd_protocol_http_reply (struct rspamd_http_message *msg,
 		msg_notice_task (
 				"regexp statistics: %ud pcre regexps scanned, %ud regexps matched,"
 				" %ud regexps total, %ud regexps cached,"
-				" %HL bytes scanned using pcre, %HL bytes scanned total",
+				" %HL scanned using pcre, %HL scanned total",
 				restat->regexp_checked,
 				restat->regexp_matched,
 				restat->regexp_total,
diff --git a/src/libserver/worker_util.c b/src/libserver/worker_util.c
index 827dc7fbb..a3601621f 100644
--- a/src/libserver/worker_util.c
+++ b/src/libserver/worker_util.c
@@ -553,14 +553,27 @@ rspamd_worker_set_limits (struct rspamd_main *rspamd_main,
 					(guint64) rlmt.rlim_max);
 		}
 	}
+	else {
+		/* Just report */
+		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 ("use system max file descriptors limit: %HL cur and %HL max",
+					(guint64) rlmt.rlim_cur,
+					(guint64) rlmt.rlim_max);
+		}
+	}
 
 	if (rspamd_main->cores_throttling) {
-		msg_info_main ("disable core files for the new worker, as limits are reached");
+		msg_info_main ("disable core files for the new worker as limits are reached");
 		rlmt.rlim_cur = 0;
 		rlmt.rlim_max = 0;
 
 		if (setrlimit (RLIMIT_CORE, &rlmt) == -1) {
-			msg_warn_main ("cannot disable core: %s",
+			msg_warn_main ("cannot disable core dumps: error when setting limits: %s",
 					strerror (errno));
 		}
 	}
@@ -570,7 +583,7 @@ rspamd_worker_set_limits (struct rspamd_main *rspamd_main,
 			rlmt.rlim_max = (rlim_t) cf->rlimit_maxcore;
 
 			if (setrlimit (RLIMIT_CORE, &rlmt) == -1) {
-				msg_warn_main ("cannot set max core rlimit: %HL, %s",
+				msg_warn_main ("cannot set max core size limit: %HL, %s",
 						cf->rlimit_maxcore,
 						strerror (errno));
 			}
@@ -579,26 +592,40 @@ rspamd_worker_set_limits (struct rspamd_main *rspamd_main,
 			memset (&rlmt, 0, sizeof (rlmt));
 
 			if (getrlimit (RLIMIT_CORE, &rlmt) == -1) {
-				msg_warn_main ("cannot get max core rlimit: %HL, %s",
+				msg_warn_main ("cannot get max core size rlimit: %HL, %s",
 						cf->rlimit_maxcore,
 						strerror (errno));
 			}
 			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, "
+					msg_warn_main ("setting of core file 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",
+					msg_info_main ("set max core size limit: %HL cur and %HL max",
 							(guint64) rlmt.rlim_cur,
 							(guint64) rlmt.rlim_max);
 				}
 			}
 		}
+		else {
+			/* Just report */
+			if (getrlimit (RLIMIT_CORE, &rlmt) == -1) {
+				msg_warn_main ("cannot get max core size limit: %HL, %s",
+						cf->rlimit_maxcore,
+						strerror (errno));
+			}
+			else {
+				msg_info_main ("use system max core size limit: %HL cur and %HL max",
+						(guint64) rlmt.rlim_cur,
+						(guint64) rlmt.rlim_max);
+			}
+		}
 	}
 }
 


More information about the Commits mailing list