summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorrbb <rbb@13f79535-47bb-0310-9956-ffa450edef68>2000-06-06 21:45:11 +0000
committerrbb <rbb@13f79535-47bb-0310-9956-ffa450edef68>2000-06-06 21:45:11 +0000
commit611dd9f08b73dc4668e7dcd3b1cd38440b01bd0b (patch)
tree0058673381a07ed45e735a3eeb4775c038e26e73 /include
parent5e8f0c1c7c885753b068ed5190a613a9dcd158be (diff)
downloadlibapr-611dd9f08b73dc4668e7dcd3b1cd38440b01bd0b.tar.gz
Add the resource limiting code back to Apache 2.0. This only works on
Unix because I can't find any other platforms with rlimit. If there are other platforms that need this code, then some of the code needs to move. This has just barely been tested, so it could probably use some good testing. git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@60147 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'include')
-rw-r--r--include/apr.h.in1
-rw-r--r--include/apr_thread_proc.h29
-rw-r--r--include/arch/unix/threadproc.h12
3 files changed, 41 insertions, 1 deletions
diff --git a/include/apr.h.in b/include/apr.h.in
index 1252a0524..c7d3056d3 100644
--- a/include/apr.h.in
+++ b/include/apr.h.in
@@ -51,6 +51,7 @@
#define APR_HAVE_INET_ADDR @inet_addr@
#define APR_HAVE_INET_NETWORK @inet_network@
#define APR_HAVE_UNION_SEMUN @have_union_semun@
+#define APR_HAVE_STRUCT_RLIMIT @struct_rlimit@
#if APR_HAVE_SYS_TYPES_H
#include <sys/types.h>
diff --git a/include/apr_thread_proc.h b/include/apr_thread_proc.h
index bcf3b5013..35e06f78d 100644
--- a/include/apr_thread_proc.h
+++ b/include/apr_thread_proc.h
@@ -58,6 +58,9 @@
#include "apr_file_io.h"
#include "apr_general.h"
#include "apr_errno.h"
+#if APR_HAVE_STRUCT_RLIMIT
+#include <sys/resource.h>
+#endif
#ifdef __cplusplus
extern "C" {
@@ -72,6 +75,10 @@ typedef enum {APR_WAIT, APR_NOWAIT} ap_wait_how_e;
#define APR_PARENT_BLOCK 3
#define APR_CHILD_BLOCK 4
+#define APR_LIMIT_CPU 0
+#define APR_LIMIT_MEM 1
+#define APR_LIMIT_NPROC 2
+
#if APR_HAS_OTHER_CHILD
#define APR_OC_REASON_DEATH 0 /* child has died, caller must call
* unregister still */
@@ -332,7 +339,7 @@ ap_status_t ap_createprocattr_init(ap_procattr_t **new, ap_pool_t *cont);
/*
-=head1 ap_status_t ap_setprocattr_io(ap_procattr_t *attr, ap_int32_t in, ap_int32_t *out, ap_int32_t err)
+=head1 ap_status_t ap_setprocattr_io(ap_procattr_t *attr, ap_int32_t in, ap_int32_t out, ap_int32_t err)
B<Determine if any of stdin, stdout, or stderr should be linked to pipes when starting a child process.>
@@ -453,6 +460,26 @@ B<Determine if the chlid should start in detached state.>
*/
ap_status_t ap_setprocattr_detach(ap_procattr_t *attr, ap_int32_t detach);
+#if APR_HAVE_STRUCT_RLIMIT
+/*
+
+=head1 ap_status_t ap_setprocattr_limit(ap_procattr_t *attr, ap_int32_t what, struct rlimit *limit)
+
+B<Set the Resource Utilization limits when starting a new process.>
+
+ arg 1) The procattr we care about.
+ arg 2) Which limit to set, one of:
+ APR_LIMIT_CPU
+ APR_LIMIT_MEM
+ APR_LIMIT_NPROC
+ arg 3) Value to set the limit to.
+
+=cut
+ */
+ap_status_t ap_setprocattr_limit(ap_procattr_t *attr, ap_int32_t what,
+ struct rlimit *limit);
+#endif
+
#if APR_HAS_FORK
/*
diff --git a/include/arch/unix/threadproc.h b/include/arch/unix/threadproc.h
index 0fdb6119e..07c97b966 100644
--- a/include/arch/unix/threadproc.h
+++ b/include/arch/unix/threadproc.h
@@ -61,6 +61,9 @@
#if HAVE_PTHREAD_H
#include <pthread.h>
#endif
+#if HAVE_SYS_RESOURCE_H
+#include <sys/resource.h>
+#endif
#if HAVE_SIGNAL_H
#include <signal.h>
#endif
@@ -109,6 +112,15 @@ struct ap_procattr_t {
char *currdir;
ap_int32_t cmdtype;
ap_int32_t detached;
+#ifdef RLIMIT_CPU
+ struct rlimit *limit_cpu;
+#endif
+#if defined (RLIMIT_DATA) || defined (RLIMIT_VMEM) || defined(RLIMIT_AS)
+ struct rlimit *limit_mem;
+#endif
+#ifdef RLIMIT_NPROC
+ struct rlimit *limit_nproc;
+#endif
};
/*This will move to ap_threadproc.h in time, but I need to figure it out