dovecot-2.1: Added restrict_get_process_size()

dovecot at dovecot.org dovecot at dovecot.org
Tue Feb 21 11:35:27 EET 2012


details:   http://hg.dovecot.org/dovecot-2.1/rev/1c1c2a1c85d7
changeset: 14179:1c1c2a1c85d7
user:      Timo Sirainen <tss at iki.fi>
date:      Tue Feb 21 11:35:05 2012 +0200
description:
Added restrict_get_process_size()

diffstat:

 src/lib/restrict-process-size.c |  19 +++++++++++++++++++
 src/lib/restrict-process-size.h |   2 ++
 2 files changed, 21 insertions(+), 0 deletions(-)

diffs (41 lines):

diff -r a6a58512f0df -r 1c1c2a1c85d7 src/lib/restrict-process-size.c
--- a/src/lib/restrict-process-size.c	Tue Feb 21 11:15:56 2012 +0200
+++ b/src/lib/restrict-process-size.c	Tue Feb 21 11:35:05 2012 +0200
@@ -49,6 +49,25 @@
 #endif
 }
 
+int restrict_get_process_size(rlim_t *limit_r)
+{
+	struct rlimit rlim;
+
+#ifdef HAVE_RLIMIT_AS
+	if (getrlimit(RLIMIT_AS, &rlim) < 0) {
+		i_error("getrlimit(RLIMIT_AS): %m");
+		return -1;
+	}
+#else
+	if (getrlimit(RLIMIT_DATA, &rlim) < 0) {
+		i_error("getrlimit(RLIMIT_DATA): %m");
+		return -1;
+	}
+#endif
+	*limit_r = rlim.rlim_cur;
+	return 0;
+}
+
 int restrict_get_core_limit(rlim_t *limit_r)
 {
 #ifdef HAVE_RLIMIT_CORE
diff -r a6a58512f0df -r 1c1c2a1c85d7 src/lib/restrict-process-size.h
--- a/src/lib/restrict-process-size.h	Tue Feb 21 11:15:56 2012 +0200
+++ b/src/lib/restrict-process-size.h	Tue Feb 21 11:35:05 2012 +0200
@@ -15,6 +15,8 @@
 
 /* Get the core dump size limit. Returns 0 if ok, -1 if lookup failed. */
 int restrict_get_core_limit(rlim_t *limit_r);
+/* Get the process VSZ size limit. Returns 0 if ok, -1 if lookup failed. */
+int restrict_get_process_size(rlim_t *limit_r);
 /* Get the process count limit. Returns 0 if ok, -1 if lookup failed. */
 int restrict_get_process_limit(rlim_t *limit_r);
 /* Get the fd limit. Returns 0 if ok, -1 if lookup failed. */


More information about the dovecot-cvs mailing list