summaryrefslogtreecommitdiffstats
path: root/server/mpm/experimental
diff options
context:
space:
mode:
authorJeff Trawick <trawick@apache.org>2001-12-18 14:48:54 +0100
committerJeff Trawick <trawick@apache.org>2001-12-18 14:48:54 +0100
commit187e9ae3b9d2e7c62d535c928db73fee597080d0 (patch)
tree3be241b138d3a0309dd63a8bfaaef7eab0b6b2e7 /server/mpm/experimental
parentStop using HARD_SERVER_LIMIT/HARD_THREAD_LIMIT all over the place (diff)
downloadapache2-187e9ae3b9d2e7c62d535c928db73fee597080d0.tar.xz
apache2-187e9ae3b9d2e7c62d535c928db73fee597080d0.zip
Change core code to allow an MPM to set hard thread/server
limits at startup. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@92512 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'server/mpm/experimental')
-rw-r--r--server/mpm/experimental/perchild/mpm.h1
-rw-r--r--server/mpm/experimental/perchild/mpm_default.h29
-rw-r--r--server/mpm/experimental/perchild/perchild.c55
3 files changed, 44 insertions, 41 deletions
diff --git a/server/mpm/experimental/perchild/mpm.h b/server/mpm/experimental/perchild/mpm.h
index c1bbf0ae8f..646a6aeae3 100644
--- a/server/mpm/experimental/perchild/mpm.h
+++ b/server/mpm/experimental/perchild/mpm.h
@@ -93,7 +93,6 @@ typedef struct ap_ctable{
extern int ap_threads_per_child;
extern int ap_max_daemons_limit;
-extern ap_ctable ap_child_table[HARD_SERVER_LIMIT];
extern server_rec *ap_server_conf;
#endif /* APACHE_MPM_PERCHILD_H */
diff --git a/server/mpm/experimental/perchild/mpm_default.h b/server/mpm/experimental/perchild/mpm_default.h
index f462ea8f90..46fb097701 100644
--- a/server/mpm/experimental/perchild/mpm_default.h
+++ b/server/mpm/experimental/perchild/mpm_default.h
@@ -59,9 +59,6 @@
#ifndef APACHE_MPM_DEFAULT_H
#define APACHE_MPM_DEFAULT_H
-#define AP_ID_FROM_CHILD_THREAD(c, t) ((c * HARD_THREAD_LIMIT) + t)
-#define AP_CHILD_THREAD_FROM_ID(i) (i / HARD_THREAD_LIMIT), (i % HARD_THREAD_LIMIT)
-
/* Number of threads to spawn off by default --- also, if fewer than
* this free when the caretaker checks, it will spawn more.
*/
@@ -83,38 +80,12 @@
#define DEFAULT_MIN_SPARE_THREAD 5
#endif
-/* Limit on the threads per process. Clients will be locked out if more than
- * this * HARD_SERVER_LIMIT are needed.
- *
- * We keep this for one reason it keeps the size of the scoreboard file small
- * enough that we can read the whole thing without worrying too much about
- * the overhead.
- */
-#ifndef HARD_THREAD_LIMIT
-#define HARD_THREAD_LIMIT 64
-#endif
-
/* Number of servers to spawn off by default
*/
#ifndef DEFAULT_NUM_DAEMON
#define DEFAULT_NUM_DAEMON 2
#endif
-/* Limit on the total --- clients will be locked out if more servers than
- * this are needed. It is intended solely to keep the server from crashing
- * when things get out of hand.
- *
- * We keep a hard maximum number of servers, for two reasons --- first off,
- * in case something goes seriously wrong, we want to stop the fork bomb
- * short of actually crashing the machine we're running on by filling some
- * kernel table. Secondly, it keeps the size of the scoreboard file small
- * enough that we can read the whole thing without worrying too much about
- * the overhead.
- */
-#ifndef HARD_SERVER_LIMIT
-#define HARD_SERVER_LIMIT 8
-#endif
-
/* File used for accept locking, when we use a file */
#ifndef DEFAULT_LOCKFILE
#define DEFAULT_LOCKFILE "logs/accept.lock"
diff --git a/server/mpm/experimental/perchild/perchild.c b/server/mpm/experimental/perchild/perchild.c
index fb83a84a1f..c7693d1f15 100644
--- a/server/mpm/experimental/perchild/perchild.c
+++ b/server/mpm/experimental/perchild/perchild.c
@@ -107,6 +107,35 @@
#include <sys/processor.h> /* for bindprocessor() */
#endif
+#define AP_ID_FROM_CHILD_THREAD(c, t) ((c * HARD_THREAD_LIMIT) + t)
+#define AP_CHILD_THREAD_FROM_ID(i) (i / HARD_THREAD_LIMIT), (i % HARD_THREAD_LIMIT)
+
+/* Limit on the threads per process. Clients will be locked out if more than
+ * this * HARD_SERVER_LIMIT are needed.
+ *
+ * We keep this for one reason it keeps the size of the scoreboard file small
+ * enough that we can read the whole thing without worrying too much about
+ * the overhead.
+ */
+#ifndef HARD_THREAD_LIMIT
+#define HARD_THREAD_LIMIT 64
+#endif
+
+/* Limit on the total --- clients will be locked out if more servers than
+ * this are needed. It is intended solely to keep the server from crashing
+ * when things get out of hand.
+ *
+ * We keep a hard maximum number of servers, for two reasons --- first off,
+ * in case something goes seriously wrong, we want to stop the fork bomb
+ * short of actually crashing the machine we're running on by filling some
+ * kernel table. Secondly, it keeps the size of the scoreboard file small
+ * enough that we can read the whole thing without worrying too much about
+ * the overhead.
+ */
+#ifndef HARD_SERVER_LIMIT
+#define HARD_SERVER_LIMIT 8
+#endif
+
/*
* Actual definitions of config globals
*/
@@ -496,6 +525,7 @@ static void process_socket(apr_pool_t *p, apr_socket_t *sock, long conn_id)
int csd;
apr_status_t rv;
int thread_num = conn_id % HARD_THREAD_LIMIT;
+ void *sbh;
if ((rv = apr_os_sock_get(&csd, sock)) != APR_SUCCESS) {
ap_log_error(APLOG_MARK, APLOG_ERR, rv, NULL, "apr_os_sock_get");
@@ -515,7 +545,8 @@ static void process_socket(apr_pool_t *p, apr_socket_t *sock, long conn_id)
ap_sock_disable_nagle(sock);
}
- current_conn = ap_run_create_connection(p, ap_server_conf, sock, conn_id);
+ ap_create_sb_handle(&sbh, p, conn_id / HARD_SERVER_LIMIT, thread_num);
+ current_conn = ap_run_create_connection(p, ap_server_conf, sock, conn_id, sbh);
if (current_conn) {
ap_process_connection(current_conn);
ap_lingering_close(current_conn);
@@ -613,8 +644,9 @@ static void *worker_thread(apr_thread_t *thd, void *arg)
apr_lock_release(thread_pool_parent_mutex);
apr_pool_create(&ptrans, tpool);
- (void) ap_update_child_status(child_num, thread_num, SERVER_STARTING,
- (request_rec *) NULL);
+ (void) ap_update_child_status_from_indexes(child_num, thread_num,
+ SERVER_STARTING,
+ (request_rec *) NULL);
apr_poll_setup(&pollset, num_listenfds+1, tpool);
for(n = 0; n <= num_listenfds; ++n) {
@@ -640,8 +672,9 @@ static void *worker_thread(apr_thread_t *thd, void *arg)
thread_just_started = 0;
}
- (void) ap_update_child_status(child_num, thread_num, SERVER_READY,
- (request_rec *) NULL);
+ (void) ap_update_child_status_from_indexes(child_num, thread_num,
+ SERVER_READY,
+ (request_rec *) NULL);
apr_lock_acquire(thread_accept_mutex);
if (workers_may_exit) {
@@ -793,8 +826,8 @@ static void *worker_thread(apr_thread_t *thd, void *arg)
}
apr_lock_acquire(thread_pool_parent_mutex);
- ap_update_child_status(child_num, thread_num, SERVER_DEAD,
- (request_rec *) NULL);
+ ap_update_child_status_from_indexes(child_num, thread_num, SERVER_DEAD,
+ (request_rec *) NULL);
apr_pool_destroy(tpool);
apr_lock_release(thread_pool_parent_mutex);
apr_lock_acquire(worker_thread_count_mutex);
@@ -995,8 +1028,8 @@ static int make_child(server_rec *s, int slot)
ap_child_table[slot].status = SERVER_ALIVE;
child_main(slot);
}
- (void) ap_update_child_status(slot, 0, SERVER_STARTING,
- (request_rec *) NULL);
+ (void) ap_update_child_status_from_indexes(slot, 0, SERVER_STARTING,
+ (request_rec *) NULL);
if ((pid = fork()) == -1) {
ap_log_error(APLOG_MARK, APLOG_ERR, errno, s,
@@ -1142,8 +1175,8 @@ static void server_main_loop(int remaining_children_to_start)
}
if (child_slot >= 0) {
ap_child_table[child_slot].pid = 0;
- ap_update_child_status(child_slot, i, SERVER_DEAD,
- (request_rec *) NULL);
+ ap_update_child_status_from_indexes(child_slot, i, SERVER_DEAD,
+ (request_rec *) NULL);
if (remaining_children_to_start