switch to a 60 bit hash
[httpd-crcsyncproxy.git] / server / mpm / simple / simple_core.c
blob11b4f679a28a08ff07ffd11315f81bdb225c433d
1 /* Licensed to the Apache Software Foundation (ASF) under one or more
2 * contributor license agreements. See the NOTICE file distributed with
3 * this work for additional information regarding copyright ownership.
4 * The ASF licenses this file to You under the Apache License, Version 2.0
5 * (the "License"); you may not use this file except in compliance with
6 * the License. You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 /* Simple Core utility methods.
20 #include "simple_types.h"
21 #include "mpm.h"
22 #include "ap_mpm.h"
23 #include "httpd.h"
24 #include "http_log.h"
26 static simple_core_t g_simple_core;
28 #ifndef DEFAULT_MAX_REQUESTS_PER_CHILD
29 #define DEFAULT_MAX_REQUESTS_PER_CHILD 0
30 #endif
33 simple_core_t *simple_core_get()
35 return &g_simple_core;
38 apr_status_t simple_core_init(simple_core_t * sc, apr_pool_t * pool)
40 apr_status_t rv;
42 memset(sc, 0, sizeof(simple_core_t));
44 apr_pool_create(&sc->pool, pool);
46 apr_pool_tag(sc->pool, "simple-mpm-core");
48 sc->mpm_state = AP_MPMQ_STARTING;
49 sc->procmgr.proc_count = SIMPLE_DEF_PROC;
50 sc->procmgr.thread_count = SIMPLE_DEF_THREADS;
51 sc->procmgr.max_requests_per_child = DEFAULT_MAX_REQUESTS_PER_CHILD;
53 sc->children = apr_hash_make(sc->pool);
54 /* TODO: configurable spawning mech */
55 sc->spawn_via = SIMPLE_SPAWN_FORK;
57 APR_RING_INIT(&sc->timer_ring, simple_timer_t, link);
59 rv = apr_thread_mutex_create(&sc->mtx, 0, sc->pool);
61 if (rv) {
62 ap_log_error(APLOG_MARK, APLOG_CRIT, rv, NULL,
63 "simple_core_init: apr_thread_mutex_create failed.");
64 return rv;
67 return APR_SUCCESS;