int maxw = h2_config_geti(config, H2_CONF_MAX_WORKERS);
int max_threads_per_child = 0;
- int threads_limit = 0;
int idle_secs = 0;
int i;
h2_config_init(pool);
ap_mpm_query(AP_MPMQ_MAX_THREADS, &max_threads_per_child);
- ap_mpm_query(AP_MPMQ_HARD_LIMIT_THREADS, &threads_limit);
for (i = 0; ap_loaded_modules[i]; ++i) {
module *m = ap_loaded_modules[i];
minw = max_threads_per_child;
}
if (maxw <= 0) {
- maxw = threads_limit;
- if (maxw < minw) {
- maxw = minw;
- }
+ maxw = minw;
}
ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s,
- "h2_workers: min=%d max=%d, mthrpchild=%d, thr_limit=%d",
- minw, maxw, max_threads_per_child, threads_limit);
+ "h2_workers: min=%d max=%d, mthrpchild=%d",
+ minw, maxw, max_threads_per_child);
workers = h2_workers_create(s, pool, minw, maxw);
idle_secs = h2_config_geti(config, H2_CONF_MAX_WORKER_IDLE_SECS);
apr_size_t readlen = 0;
*pdone = 0;
- while (status == APR_SUCCESS && !*pdone
- && !APR_BRIGADE_EMPTY(io->input)) {
+ while (status == APR_SUCCESS && !*pdone && !APR_BRIGADE_EMPTY(io->input)) {
apr_bucket* bucket = APR_BRIGADE_FIRST(io->input);
if (APR_BUCKET_IS_METADATA(bucket)) {
#include <apr_thread_cond.h>
+#include <mpm_common.h>
#include <httpd.h>
#include <http_core.h>
#include <http_log.h>
}
}
- status = worker->get_next(worker, &m, NULL, worker->ctx);
- m = NULL;
+ if (m) {
+ /* Hand "m" back to other workers */
+ status = worker->get_next(worker, &m, NULL, worker->ctx);
+ m = NULL;
+ }
if (worker->socket) {
apr_socket_close(worker->socket);
h2_worker *w;
apr_status_t status;
- status = apr_allocator_create(&allocator);
- if (status != APR_SUCCESS) {
- return NULL;
- }
-
- status = apr_pool_create_ex(&pool, parent_pool, NULL, allocator);
- if (status != APR_SUCCESS) {
- return NULL;
- }
+ apr_allocator_create(&allocator);
+ apr_allocator_max_free_set(allocator, ap_max_mem_free);
+ apr_pool_create_ex(&pool, parent_pool, NULL, allocator);
apr_allocator_owner_set(allocator, pool);
w = apr_pcalloc(pool, sizeof(h2_worker));
*/
if (!worker->task_pool) {
apr_pool_create(&worker->task_pool, worker->pool);
+ worker->pool_reuses = 100;
}
task = h2_task_create(m->id, req, worker->task_pool, m, eos);
{
task->io = NULL;
task->pool = NULL;
- apr_pool_clear(worker->task_pool);
+ if (worker->pool_reuses-- <= 0) {
+ apr_pool_destroy(worker->task_pool);
+ worker->task_pool = NULL;
+ }
+ else {
+ apr_pool_clear(worker->task_pool);
+ }
}
apr_socket_t *h2_worker_get_socket(h2_worker *worker)
void *ctx;
int aborted;
+ int pool_reuses;
struct h2_task *task;
};
#include <apr_thread_mutex.h>
#include <apr_thread_cond.h>
+#include <mpm_common.h>
#include <httpd.h>
#include <http_core.h>
#include <http_log.h>
apr_atomic_set32(&workers->max_idle_secs, 10);
apr_threadattr_create(&workers->thread_attr, workers->pool);
+ apr_threadattr_detach_set(workers->thread_attr, 0);
+ if (ap_thread_stacksize != 0) {
+ apr_threadattr_stacksize_set(workers->thread_attr,
+ ap_thread_stacksize);
+ ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s,
+ "h2_workers: using stacksize=%ld",
+ (long)ap_thread_stacksize);
+ }
APR_RING_INIT(&workers->workers, h2_worker, link);
APR_RING_INIT(&workers->zombies, h2_worker, link);