apr_pool_t *ptemp,
server_rec *s)
{
- ap_server_conf = s;
+ int nsock;
- int nsock = ap_setup_listeners(s);
+ ap_server_conf = s;
+
+ nsock = ap_setup_listeners(s);
if (nsock < 1) {
ap_log_error(APLOG_MARK, APLOG_ALERT, 0,
simple_pre_config(apr_pool_t *pconf, apr_pool_t *plog,
apr_pool_t *ptemp)
{
+ int run_debug;
apr_status_t rv;
simple_core_t* sc = simple_core_get();
sc->restart_num++;
- int run_debug = ap_exists_config_define("DEBUG");
+ run_debug = ap_exists_config_define("DEBUG");
if (run_debug) {
sc->run_foreground = 1;
static const char*
set_threadcount(cmd_parms *cmd, void *baton, const char *arg)
{
+ simple_core_t *sc = simple_core_get();
const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
+
if (err != NULL) {
return err;
}
- simple_core_get()->procmgr.thread_count = atoi(arg);
+ sc->procmgr.thread_count = atoi(arg);
return NULL;
}
static const char*
set_user(cmd_parms *cmd, void *baton, const char *arg)
{
+ simple_core_t *sc = simple_core_get();
const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
if (err != NULL) {
return err;
}
- simple_core_get()->procmgr.user_name = arg;
- simple_core_get()->procmgr.user_id = ap_uname2id(arg);
+ sc->procmgr.user_name = arg;
+ sc->procmgr.user_id = ap_uname2id(arg);
return NULL;
}
simple_check_children_size(simple_core_t *sc,
void *baton)
{
+ unsigned int count;
+ int wanted;
+ int i;
+
simple_register_timer(sc,
simple_check_children_size,
NULL,
SPAWN_CHILDREN_INTERVAL);
- unsigned int count;
- int wanted;
- int i;
if (sc->run_single_process && sc->restart_num == 2) {
static int run = 0;
* limitations under the License.
*/
-//#define APR_RING_DEBUG 1
+/* #define APR_RING_DEBUG 1 */
#include "simple_types.h"
#include "simple_event.h"
simple_io_process(simple_conn_t *scon)
{
apr_status_t rv;
+ simple_core_t *sc;
+ conn_rec *c;
+ conn_state_t *cs;
if (scon->c->clogging_input_filters && !scon->c->aborted) {
/* Since we have an input filter which 'cloggs' the input stream,
}
}
- simple_core_t *sc = scon->sc;
- conn_rec *c = scon->c;
- conn_state_t *cs = c->cs;
+ sc = scon->sc;
+ c = scon->c;
+ cs = c->cs;
while (!c->aborted) {
if (cs->state == CONN_STATE_READ_REQUEST_LINE) {
simple_io_setup_conn(apr_thread_t* thread, void *baton)
{
apr_status_t rv;
+ ap_sb_handle_t *sbh;
+ conn_state_t *cs;
+ long conn_id = 0;
+ simple_sb_t *sb;
simple_conn_t *scon = (simple_conn_t *)baton;
/* pqXXXXX: remove this. */
- ap_sb_handle_t *sbh;
ap_create_sb_handle(&sbh, scon->pool, 0, 0);
- long conn_id = 0;
scon->ba = apr_bucket_alloc_create(scon->pool);
conn_id, sbh, scon->ba);
scon->c->cs = apr_pcalloc(scon->pool, sizeof(conn_state_t));
- conn_state_t *cs = scon->c->cs;
- simple_sb_t *sb = apr_pcalloc(scon->pool, sizeof(simple_sb_t));
+ cs = scon->c->cs;
+ sb = apr_pcalloc(scon->pool, sizeof(simple_sb_t));
cs->pfd.p = scon->pool;
cs->pfd.desc_type = APR_POLL_SOCKET;
simple_io_accept(simple_core_t *sc, simple_sb_t *sb)
{
apr_status_t rv;
- ap_listen_rec *lr = (ap_listen_rec *)sb->baton;
apr_pool_t *ptrans;
+ apr_socket_t *socket;
+ ap_listen_rec *lr = (ap_listen_rec *)sb->baton;
/* pqXXXXXX: Consider doing pool recycling like the event/worker MPMs do. */
apr_pool_create(&ptrans, NULL);
- apr_socket_t *socket;
apr_pool_tag(ptrans, "transaction");
* limitations under the License.
*/
-//#define APR_RING_DEBUG 1
+/* #define APR_RING_DEBUG 1 */
#include "httpd.h"
#include "http_log.h"
simple_timer_t *ep = NULL;
while (sc->mpm_state == AP_MPMQ_RUNNING) {
- apr_time_t now = apr_time_now();
+ apr_time_t tnow = apr_time_now();
+ simple_timer_t *head;
apr_interval_time_t timeout = apr_time_from_msec(500);
-
+ APR_RING_HEAD(simple_temp_timer_ring_t, simple_timer_t) tmp_ring;
+
apr_thread_mutex_lock(sc->mtx);
- simple_timer_t *head = APR_RING_FIRST(&sc->timer_ring);
+ head = APR_RING_FIRST(&sc->timer_ring);
if (head != APR_RING_SENTINEL(&sc->timer_ring, simple_timer_t, link)) {
- if (now < head->expires) {
- timeout = (head->expires - now);
+ if (tnow < head->expires) {
+ timeout = (head->expires - tnow);
if (timeout > apr_time_from_msec(500)) {
/* pqXXXXX: I'm 95% sure that the Linux Powertop guys will slap me for this. */
timeout = apr_time_from_msec(500);
}
}
+ else {
+ /* We have already expired timers in the queue. */
+ timeout = 0;
+ }
}
apr_thread_mutex_unlock(sc->mtx);
simple_io_callback,
sc);
- now = apr_time_now();
+ tnow = apr_time_now();
if (rv) {
if (!APR_STATUS_IS_EINTR(rv) && !APR_STATUS_IS_TIMEUP(rv)) {
}
}
- APR_RING_HEAD(simple_temp_timer_ring_t, simple_timer_t) tmp_ring;
APR_RING_INIT(&tmp_ring, simple_timer_t, link);
apr_thread_mutex_lock(sc->mtx);
simple_timer_t, link);
ep = APR_RING_NEXT(ep, link))
{
- if (ep->expires < now) {
+ if (ep->expires < tnow) {
simple_timer_t *next = APR_RING_PREV(ep, link);
/* push this task */
APR_RING_REMOVE(ep, link);
SIMPLE_PT_CORE_ACCEPT,
SIMPLE_PT_CORE_IO,
/* pqXXXXXX: User IO not defined yet. */
- SIMPLE_PT_USER,
+ SIMPLE_PT_USER
} simple_poll_type_e;
struct simple_sb_t {