From 40ac38ff050679c90fb07f1b262bcb51b72bb171 Mon Sep 17 00:00:00 2001 From: Stefan Fritsch Date: Sat, 19 Nov 2011 23:35:46 +0000 Subject: [PATCH] Remove MPM-private stuff from conn_state_t git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1204104 13f79535-47bb-0310-9956-ffa450edef68 --- include/ap_mmn.h | 5 +- include/httpd.h | 12 ---- modules/http/http_core.c | 1 + modules/http/http_request.c | 6 +- server/core.c | 7 --- server/mpm/event/event.c | 104 ++++++++++++++++++------------- server/mpm/event/fdqueue.c | 8 +-- server/mpm/event/fdqueue.h | 7 ++- server/mpm/simple/simple_io.c | 55 ++++++++-------- server/mpm/simple/simple_types.h | 4 ++ 10 files changed, 106 insertions(+), 103 deletions(-) diff --git a/include/ap_mmn.h b/include/ap_mmn.h index 6c09f0a2cd..0bed710307 100644 --- a/include/ap_mmn.h +++ b/include/ap_mmn.h @@ -367,14 +367,15 @@ * 20111025.2 (2.3.15-dev) Add ap_lua_ssl_val to mod_lua * 20111118.0 (2.5.0-dev) Add conn_rec to error_log hook * 20111118.1 (2.5.0-dev) Add reclvl to ap_expr_eval_ctx_t + * 20111120.0 (2.5.0-dev) Remove parts of conn_state_t that are private to the MPM */ #define MODULE_MAGIC_COOKIE 0x41503234UL /* "AP24" */ #ifndef MODULE_MAGIC_NUMBER_MAJOR -#define MODULE_MAGIC_NUMBER_MAJOR 20111118 +#define MODULE_MAGIC_NUMBER_MAJOR 20111120 #endif -#define MODULE_MAGIC_NUMBER_MINOR 1 /* 0...n */ +#define MODULE_MAGIC_NUMBER_MINOR 0 /* 0...n */ /** * Determine if the server's current MODULE_MAGIC_NUMBER is at least a diff --git a/include/httpd.h b/include/httpd.h index 464f4a1286..7c347c1497 100644 --- a/include/httpd.h +++ b/include/httpd.h @@ -1144,18 +1144,6 @@ typedef enum { * @brief A structure to contain connection state information */ struct conn_state_t { - /** APR_RING of expiration timeouts */ - APR_RING_ENTRY(conn_state_t) timeout_list; - /** the expiration time of the next keepalive timeout */ - apr_time_t expiration_time; - /** connection record this struct refers to */ - conn_rec *c; - /** memory pool to allocate from */ - apr_pool_t *p; - /** bucket allocator */ - apr_bucket_alloc_t *bucket_alloc; - /** poll file descriptor information */ - apr_pollfd_t pfd; /** Current state of the connection */ conn_state_e state; }; diff --git a/modules/http/http_core.c b/modules/http/http_core.c index 8970ae6dc4..8421f42b97 100644 --- a/modules/http/http_core.c +++ b/modules/http/http_core.c @@ -126,6 +126,7 @@ static int ap_process_http_async_connection(conn_rec *c) request_rec *r; conn_state_t *cs = c->cs; + AP_DEBUG_ASSERT(cs != NULL); AP_DEBUG_ASSERT(cs->state == CONN_STATE_READ_REQUEST_LINE); while (cs->state == CONN_STATE_READ_REQUEST_LINE) { diff --git a/modules/http/http_request.c b/modules/http/http_request.c index 0a25333ee4..319be84f0d 100644 --- a/modules/http/http_request.c +++ b/modules/http/http_request.c @@ -260,7 +260,8 @@ AP_DECLARE(void) ap_process_request_after_handler(request_rec *r) * already by the EOR bucket's cleanup function. */ - c->cs->state = CONN_STATE_WRITE_COMPLETION; + if (c->cs) + c->cs->state = CONN_STATE_WRITE_COMPLETION; check_pipeline(c); AP_PROCESS_REQUEST_RETURN((uintptr_t)r, r->uri, r->status); if (ap_extended_status) { @@ -325,7 +326,8 @@ void ap_process_async_request(request_rec *r) if (ap_extended_status) { ap_time_process_request(c->sbh, STOP_PREQUEST); } - c->cs->state = CONN_STATE_SUSPENDED; + if (c->cs) + c->cs->state = CONN_STATE_SUSPENDED; #if APR_HAS_THREADS apr_thread_mutex_unlock(r->invoke_mtx); #endif diff --git a/server/core.c b/server/core.c index eb196937d0..fb1013965c 100644 --- a/server/core.c +++ b/server/core.c @@ -4511,13 +4511,6 @@ static conn_rec *core_create_conn(apr_pool_t *ptrans, server_rec *server, c->id = id; c->bucket_alloc = alloc; - c->cs = (conn_state_t *)apr_pcalloc(ptrans, sizeof(conn_state_t)); - APR_RING_INIT(&(c->cs->timeout_list), conn_state_t, timeout_list); - c->cs->expiration_time = 0; - c->cs->state = CONN_STATE_CHECK_REQUEST_LINE_READABLE; - c->cs->c = c; - c->cs->p = ptrans; - c->cs->bucket_alloc = alloc; c->clogging_input_filters = 0; return c; diff --git a/server/mpm/event/event.c b/server/mpm/event/event.c index e49a6c3e3d..d0f40d027c 100644 --- a/server/mpm/event/event.c +++ b/server/mpm/event/event.c @@ -192,13 +192,31 @@ typedef enum { TIMEOUT_SHORT_LINGER } timeout_type_e; +struct event_conn_state_t { + /** APR_RING of expiration timeouts */ + APR_RING_ENTRY(event_conn_state_t) timeout_list; + /** the expiration time of the next keepalive timeout */ + apr_time_t expiration_time; + /** connection record this struct refers to */ + conn_rec *c; + /** memory pool to allocate from */ + apr_pool_t *p; + /** bucket allocator */ + apr_bucket_alloc_t *bucket_alloc; + /** poll file descriptor information */ + apr_pollfd_t pfd; + /** public parts of the connection state */ + conn_state_t pub; +}; + typedef struct pollset_op_t { timeout_type_e timeout_type; - conn_state_t *cs; + event_conn_state_t *cs; const char *tag; } pollset_op_t; -APR_RING_HEAD(timeout_head_t, conn_state_t); + +APR_RING_HEAD(timeout_head_t, event_conn_state_t); struct timeout_queue { struct timeout_head_t head; int count; @@ -220,10 +238,10 @@ static apr_pollfd_t *listener_pollfd; * Macros for accessing struct timeout_queue. * For TO_QUEUE_APPEND and TO_QUEUE_REMOVE, timeout_mutex must be held. */ -#define TO_QUEUE_APPEND(q, el) \ - do { \ - APR_RING_INSERT_TAIL(&(q).head, el, conn_state_t, timeout_list); \ - (q).count++; \ +#define TO_QUEUE_APPEND(q, el) \ + do { \ + APR_RING_INSERT_TAIL(&(q).head, el, event_conn_state_t, timeout_list); \ + (q).count++; \ } while (0) #define TO_QUEUE_REMOVE(q, el) \ @@ -232,10 +250,10 @@ static apr_pollfd_t *listener_pollfd; (q).count--; \ } while (0) -#define TO_QUEUE_INIT(q) \ - do { \ - APR_RING_INIT(&(q).head, conn_state_t, timeout_list); \ - (q).tag = #q; \ +#define TO_QUEUE_INIT(q) \ + do { \ + APR_RING_INIT(&(q).head, event_conn_state_t, timeout_list); \ + (q).tag = #q; \ } while (0) #define TO_QUEUE_ELEM_INIT(el) APR_RING_ELEM_INIT(el, timeout_list) @@ -755,7 +773,7 @@ static void set_signals(void) static void process_pollop(pollset_op_t *op) { apr_status_t rv; - conn_state_t *cs = op->cs; + event_conn_state_t *cs = op->cs; switch (op->timeout_type) { case TIMEOUT_WRITE_COMPLETION: @@ -790,7 +808,7 @@ static void process_pollop(pollset_op_t *op) * the eq may be null if called from the listener thread, * and the pollset operations are done directly by this function. */ -static int start_lingering_close(conn_state_t *cs, ap_equeue_t *eq) +static int start_lingering_close(event_conn_state_t *cs, ap_equeue_t *eq) { apr_status_t rv; @@ -827,14 +845,14 @@ static int start_lingering_close(conn_state_t *cs, ap_equeue_t *eq) apr_time_now() + apr_time_from_sec(SECONDS_TO_LINGER); v->timeout_type = TIMEOUT_SHORT_LINGER; v->tag = "start_lingering_close(short)"; - cs->state = CONN_STATE_LINGER_SHORT; + cs->pub.state = CONN_STATE_LINGER_SHORT; } else { cs->expiration_time = apr_time_now() + apr_time_from_sec(MAX_SECS_TO_LINGER); v->timeout_type = TIMEOUT_LINGER; v->tag = "start_lingering_close(normal)"; - cs->state = CONN_STATE_LINGER_NORMAL; + cs->pub.state = CONN_STATE_LINGER_NORMAL; } cs->pfd.reqevents = APR_POLLIN | APR_POLLHUP | APR_POLLERR; @@ -856,7 +874,7 @@ static int start_lingering_close(conn_state_t *cs, ap_equeue_t *eq) * Pre-condition: cs is not in any timeout queue and not in the pollset * return: irrelevant (need same prototype as start_lingering_close) */ -static int stop_lingering_close(conn_state_t *cs, ap_equeue_t *eq) +static int stop_lingering_close(event_conn_state_t *cs, ap_equeue_t *eq) { apr_status_t rv; apr_socket_t *csd = ap_get_conn_socket(cs->c); @@ -878,7 +896,7 @@ static int stop_lingering_close(conn_state_t *cs, ap_equeue_t *eq) * 0 if it is still open and waiting for some event */ static int process_socket(apr_thread_t *thd, apr_pool_t * p, apr_socket_t * sock, - conn_state_t * cs, + event_conn_state_t * cs, ap_equeue_t *eq, int my_child_num, int my_thread_num) @@ -892,7 +910,7 @@ static int process_socket(apr_thread_t *thd, apr_pool_t * p, apr_socket_t * sock if (cs == NULL) { /* This is a new connection */ listener_poll_type *pt = apr_pcalloc(p, sizeof(*pt)); - cs = apr_pcalloc(p, sizeof(conn_state_t)); + cs = apr_pcalloc(p, sizeof(event_conn_state_t)); cs->bucket_alloc = apr_bucket_alloc_create(p); c = ap_run_create_connection(p, ap_server_conf, sock, conn_id, sbh, cs->bucket_alloc); @@ -906,7 +924,7 @@ static int process_socket(apr_thread_t *thd, apr_pool_t * p, apr_socket_t * sock apr_pool_cleanup_register(c->pool, NULL, decrement_connection_count, apr_pool_cleanup_null); c->current_thread = thd; cs->c = c; - c->cs = cs; + c->cs = &(cs->pub); cs->p = p; cs->pfd.desc_type = APR_POLL_SOCKET; cs->pfd.reqevents = APR_POLLIN; @@ -937,7 +955,7 @@ static int process_socket(apr_thread_t *thd, apr_pool_t * p, apr_socket_t * sock * When the accept filter is active, sockets are kept in the * kernel until a HTTP request is received. */ - cs->state = CONN_STATE_READ_REQUEST_LINE; + cs->pub.state = CONN_STATE_READ_REQUEST_LINE; } else { @@ -952,13 +970,13 @@ static int process_socket(apr_thread_t *thd, apr_pool_t * p, apr_socket_t * sock * like the Worker MPM does. */ ap_run_process_connection(c); - if (cs->state != CONN_STATE_SUSPENDED) { - cs->state = CONN_STATE_LINGER; + if (cs->pub.state != CONN_STATE_SUSPENDED) { + cs->pub.state = CONN_STATE_LINGER; } } read_request: - if (cs->state == CONN_STATE_READ_REQUEST_LINE) { + if (cs->pub.state == CONN_STATE_READ_REQUEST_LINE) { if (!c->aborted) { ap_run_process_connection(c); @@ -968,11 +986,11 @@ read_request: */ } else { - cs->state = CONN_STATE_LINGER; + cs->pub.state = CONN_STATE_LINGER; } } - if (cs->state == CONN_STATE_WRITE_COMPLETION) { + if (cs->pub.state == CONN_STATE_WRITE_COMPLETION) { ap_filter_t *output_filter = c->output_filters; apr_status_t rv; ap_update_child_status_from_conn(sbh, SERVER_BUSY_WRITE, c); @@ -983,7 +1001,7 @@ read_request: if (rv != APR_SUCCESS) { ap_log_cerror(APLOG_MARK, APLOG_DEBUG, rv, c, "network write failure in core output filter"); - cs->state = CONN_STATE_LINGER; + cs->pub.state = CONN_STATE_LINGER; } else if (c->data_in_output_filters) { /* Still in WRITE_COMPLETION_STATE: @@ -1005,23 +1023,23 @@ read_request: } else if (c->keepalive != AP_CONN_KEEPALIVE || c->aborted || listener_may_exit) { - c->cs->state = CONN_STATE_LINGER; + cs->pub.state = CONN_STATE_LINGER; } else if (c->data_in_input_filters) { - cs->state = CONN_STATE_READ_REQUEST_LINE; + cs->pub.state = CONN_STATE_READ_REQUEST_LINE; goto read_request; } else { - cs->state = CONN_STATE_CHECK_REQUEST_LINE_READABLE; + cs->pub.state = CONN_STATE_CHECK_REQUEST_LINE_READABLE; } } - if (cs->state == CONN_STATE_LINGER) { + if (cs->pub.state == CONN_STATE_LINGER) { if (!start_lingering_close(cs, eq)) { return 0; } } - else if (cs->state == CONN_STATE_CHECK_REQUEST_LINE_READABLE) { + else if (cs->pub.state == CONN_STATE_CHECK_REQUEST_LINE_READABLE) { pollset_op_t *v; /* It greatly simplifies the logic to use a single timeout value here @@ -1189,7 +1207,7 @@ static apr_status_t push2worker(const apr_pollfd_t * pfd, apr_pollset_t * pollset) { listener_poll_type *pt = (listener_poll_type *) pfd->client_data; - conn_state_t *cs = (conn_state_t *) pt->baton; + event_conn_state_t *cs = (event_conn_state_t *) pt->baton; apr_status_t rc; rc = ap_queue_push(worker_queue, cs->pfd.desc.s, cs, cs->p); @@ -1311,14 +1329,14 @@ static apr_status_t event_register_timed_callback(apr_time_t t, * Only to be called in the listener thread; * Pre-condition: cs is in one of the linger queues and in the pollset */ -static void process_lingering_close(conn_state_t *cs, const apr_pollfd_t *pfd) +static void process_lingering_close(event_conn_state_t *cs, const apr_pollfd_t *pfd) { apr_socket_t *csd = ap_get_conn_socket(cs->c); char dummybuf[2048]; apr_size_t nbytes; apr_status_t rv; struct timeout_queue *q; - q = (cs->state == CONN_STATE_LINGER_SHORT) ? &short_linger_q : &linger_q; + q = (cs->pub.state == CONN_STATE_LINGER_SHORT) ? &short_linger_q : &linger_q; /* socket is already in non-blocking state */ do { @@ -1349,18 +1367,18 @@ static void process_lingering_close(conn_state_t *cs, const apr_pollfd_t *pfd) */ static void process_timeout_queue(struct timeout_queue *q, apr_time_t timeout_time, - int (*func)(conn_state_t *, ap_equeue_t *eq)) + int (*func)(event_conn_state_t *, ap_equeue_t *eq)) { int count = 0; - conn_state_t *first, *cs, *last; + event_conn_state_t *first, *cs, *last; apr_status_t rv; if (!q->count) { return; } - AP_DEBUG_ASSERT(!APR_RING_EMPTY(&q->head, conn_state_t, timeout_list)); + AP_DEBUG_ASSERT(!APR_RING_EMPTY(&q->head, event_conn_state_t, timeout_list)); cs = first = APR_RING_FIRST(&q->head); - while (cs != APR_RING_SENTINEL(&q->head, conn_state_t, timeout_list) + while (cs != APR_RING_SENTINEL(&q->head, event_conn_state_t, timeout_list) && cs->expiration_time < timeout_time) { last = cs; rv = apr_pollset_remove(event_pollset, &cs->pfd); @@ -1398,7 +1416,7 @@ static void * APR_THREAD_FUNC listener_thread(apr_thread_t * thd, void *dummy) apr_pool_t *ptrans; /* Pool for per-transaction stuff */ ap_listen_rec *lr; int have_idle_worker = 0; - conn_state_t *cs; + event_conn_state_t *cs; const apr_pollfd_t *out_pfd; apr_int32_t num = 0; apr_interval_time_t timeout_interval; @@ -1520,10 +1538,10 @@ static void * APR_THREAD_FUNC listener_thread(apr_thread_t * thd, void *dummy) /* one of the sockets is readable */ struct timeout_queue *remove_from_q = &write_completion_q; int blocking = 1; - cs = (conn_state_t *) pt->baton; - switch (cs->state) { + cs = (event_conn_state_t *)pt->baton; + switch (cs->pub.state) { case CONN_STATE_CHECK_REQUEST_LINE_READABLE: - cs->state = CONN_STATE_READ_REQUEST_LINE; + cs->pub.state = CONN_STATE_READ_REQUEST_LINE; remove_from_q = &keepalive_q; /* don't wait for a worker for a keepalive request */ blocking = 0; @@ -1573,7 +1591,7 @@ static void * APR_THREAD_FUNC listener_thread(apr_thread_t * thd, void *dummy) ap_log_error(APLOG_MARK, APLOG_CRIT, rc, ap_server_conf, "event_loop: unexpected state %d", - cs->state); + cs->pub.state); ap_assert(0); } } @@ -1768,7 +1786,7 @@ static void *APR_THREAD_FUNC worker_thread(apr_thread_t * thd, void *dummy) int process_slot = ti->pid; int thread_slot = ti->tid; apr_socket_t *csd = NULL; - conn_state_t *cs; + event_conn_state_t *cs; apr_pool_t *ptrans; /* Pool for per-transaction stuff */ apr_status_t rv; int is_idle = 0; diff --git a/server/mpm/event/fdqueue.c b/server/mpm/event/fdqueue.c index f24ba3eb5b..028bca106e 100644 --- a/server/mpm/event/fdqueue.c +++ b/server/mpm/event/fdqueue.c @@ -364,7 +364,7 @@ apr_status_t ap_queue_init(fd_queue_t * queue, int queue_capacity, * to reserve an idle worker thread */ apr_status_t ap_queue_push(fd_queue_t * queue, apr_socket_t * sd, - conn_state_t * cs, apr_pool_t * p) + event_conn_state_t * ecs, apr_pool_t * p) { fd_queue_elem_t *elem; apr_status_t rv; @@ -381,7 +381,7 @@ apr_status_t ap_queue_push(fd_queue_t * queue, apr_socket_t * sd, if (queue->in >= queue->bounds) queue->in -= queue->bounds; elem->sd = sd; - elem->cs = cs; + elem->ecs = ecs; elem->p = p; queue->nelts++; @@ -422,7 +422,7 @@ apr_status_t ap_queue_push_timer(fd_queue_t * queue, timer_event_t *te) * 'sd'. */ apr_status_t ap_queue_pop_something(fd_queue_t * queue, apr_socket_t ** sd, - conn_state_t ** cs, apr_pool_t ** p, + event_conn_state_t ** ecs, apr_pool_t ** p, timer_event_t ** te_out) { fd_queue_elem_t *elem; @@ -465,7 +465,7 @@ apr_status_t ap_queue_pop_something(fd_queue_t * queue, apr_socket_t ** sd, queue->out -= queue->bounds; queue->nelts--; *sd = elem->sd; - *cs = elem->cs; + *ecs = elem->ecs; *p = elem->p; #ifdef AP_DEBUG elem->sd = NULL; diff --git a/server/mpm/event/fdqueue.h b/server/mpm/event/fdqueue.h index 5877ee74fb..955816b7d2 100644 --- a/server/mpm/event/fdqueue.h +++ b/server/mpm/event/fdqueue.h @@ -40,6 +40,7 @@ #include "ap_mpm.h" typedef struct fd_queue_info_t fd_queue_info_t; +typedef struct event_conn_state_t event_conn_state_t; apr_status_t ap_queue_info_create(fd_queue_info_t ** queue_info, apr_pool_t * pool, int max_idlers, @@ -56,7 +57,7 @@ struct fd_queue_elem_t { apr_socket_t *sd; apr_pool_t *p; - conn_state_t *cs; + event_conn_state_t *ecs; }; typedef struct fd_queue_elem_t fd_queue_elem_t; @@ -91,10 +92,10 @@ void ap_push_pool(fd_queue_info_t * queue_info, apr_status_t ap_queue_init(fd_queue_t * queue, int queue_capacity, apr_pool_t * a); apr_status_t ap_queue_push(fd_queue_t * queue, apr_socket_t * sd, - conn_state_t * cs, apr_pool_t * p); + event_conn_state_t * ecs, apr_pool_t * p); apr_status_t ap_queue_push_timer(fd_queue_t *queue, timer_event_t *te); apr_status_t ap_queue_pop_something(fd_queue_t * queue, apr_socket_t ** sd, - conn_state_t ** cs, apr_pool_t ** p, + event_conn_state_t ** ecs, apr_pool_t ** p, timer_event_t ** te); apr_status_t ap_queue_interrupt_all(fd_queue_t * queue); apr_status_t ap_queue_term(fd_queue_t * queue); diff --git a/server/mpm/simple/simple_io.c b/server/mpm/simple/simple_io.c index 50e2d6ad27..c3d5373e54 100644 --- a/server/mpm/simple/simple_io.c +++ b/server/mpm/simple/simple_io.c @@ -36,7 +36,6 @@ static void simple_io_timeout_cb(simple_core_t * sc, void *baton) simple_conn_t *scon = (simple_conn_t *) baton; /* pqXXXXX: handle timeouts. */ conn_rec *c = scon->c; - conn_state_t *cs = c->cs; cs = NULL; #endif @@ -50,7 +49,6 @@ static apr_status_t 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, @@ -58,28 +56,27 @@ static apr_status_t simple_io_process(simple_conn_t * scon) * like the Worker MPM does. */ ap_run_process_connection(scon->c); - if (scon->c->cs->state != CONN_STATE_SUSPENDED) { - scon->c->cs->state = CONN_STATE_LINGER; + if (scon->cs.state != CONN_STATE_SUSPENDED) { + scon->cs.state = CONN_STATE_LINGER; } } sc = scon->sc; c = scon->c; - cs = c->cs; while (!c->aborted) { - if (cs->pfd.reqevents != 0) { - rv = apr_pollcb_remove(sc->pollcb, &cs->pfd); + if (scon->pfd.reqevents != 0) { + rv = apr_pollcb_remove(sc->pollcb, &scon->pfd); if (rv) { ap_log_error(APLOG_MARK, APLOG_ERR, rv, ap_server_conf, "simple_io_process: apr_pollcb_remove failure"); /*AP_DEBUG_ASSERT(rv == APR_SUCCESS);*/ } - cs->pfd.reqevents = 0; + scon->pfd.reqevents = 0; } - if (cs->state == CONN_STATE_READ_REQUEST_LINE) { + if (scon->cs.state == CONN_STATE_READ_REQUEST_LINE) { if (!c->aborted) { ap_run_process_connection(c); /* state will be updated upon return @@ -88,11 +85,11 @@ static apr_status_t simple_io_process(simple_conn_t * scon) */ } else { - cs->state = CONN_STATE_LINGER; + scon->cs.state = CONN_STATE_LINGER; } } - if (cs->state == CONN_STATE_WRITE_COMPLETION) { + if (scon->cs.state == CONN_STATE_WRITE_COMPLETION) { ap_filter_t *output_filter = c->output_filters; while (output_filter->next != NULL) { output_filter = output_filter->next; @@ -104,7 +101,7 @@ static apr_status_t simple_io_process(simple_conn_t * scon) if (rv != APR_SUCCESS) { ap_log_error(APLOG_MARK, APLOG_WARNING, rv, ap_server_conf, "network write failure in core output filter"); - cs->state = CONN_STATE_LINGER; + scon->cs.state = CONN_STATE_LINGER; } else if (c->data_in_output_filters) { /* Still in WRITE_COMPLETION_STATE: @@ -120,9 +117,9 @@ static apr_status_t simple_io_process(simple_conn_t * scon) timeout : ap_server_conf->timeout, scon->pool); - cs->pfd.reqevents = APR_POLLOUT | APR_POLLHUP | APR_POLLERR; + scon->pfd.reqevents = APR_POLLOUT | APR_POLLHUP | APR_POLLERR; - rv = apr_pollcb_add(sc->pollcb, &cs->pfd); + rv = apr_pollcb_add(sc->pollcb, &scon->pfd); if (rv != APR_SUCCESS) { ap_log_error(APLOG_MARK, APLOG_WARNING, rv, @@ -133,23 +130,23 @@ static apr_status_t simple_io_process(simple_conn_t * scon) return APR_SUCCESS; } else if (c->keepalive != AP_CONN_KEEPALIVE || c->aborted) { - c->cs->state = CONN_STATE_LINGER; + scon->cs.state = CONN_STATE_LINGER; } else if (c->data_in_input_filters) { - cs->state = CONN_STATE_READ_REQUEST_LINE; + scon->cs.state = CONN_STATE_READ_REQUEST_LINE; } else { - cs->state = CONN_STATE_CHECK_REQUEST_LINE_READABLE; + scon->cs.state = CONN_STATE_CHECK_REQUEST_LINE_READABLE; } } - if (cs->state == CONN_STATE_LINGER) { + if (scon->cs.state == CONN_STATE_LINGER) { ap_lingering_close(c); apr_pool_destroy(scon->pool); return APR_SUCCESS; } - if (cs->state == CONN_STATE_CHECK_REQUEST_LINE_READABLE) { + if (scon->cs.state == CONN_STATE_CHECK_REQUEST_LINE_READABLE) { simple_register_timer(scon->sc, simple_io_timeout_cb, scon, @@ -158,9 +155,9 @@ static apr_status_t simple_io_process(simple_conn_t * scon) timeout : ap_server_conf->timeout, scon->pool); - cs->pfd.reqevents = APR_POLLIN; + scon->pfd.reqevents = APR_POLLIN; - rv = apr_pollcb_add(sc->pollcb, &cs->pfd); + rv = apr_pollcb_add(sc->pollcb, &scon->pfd); if (rv) { ap_log_error(APLOG_MARK, APLOG_ERR, rv, ap_server_conf, @@ -199,7 +196,6 @@ static void *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; @@ -213,20 +209,19 @@ static void *simple_io_setup_conn(apr_thread_t * thread, void *baton) conn_id, sbh, scon->ba); /* XXX: handle failure */ - scon->c->cs = apr_pcalloc(scon->pool, sizeof(conn_state_t)); - cs = scon->c->cs; + scon->c->cs = &scon->cs; sb = apr_pcalloc(scon->pool, sizeof(simple_sb_t)); scon->c->current_thread = thread; - cs->pfd.p = scon->pool; - cs->pfd.desc_type = APR_POLL_SOCKET; - cs->pfd.desc.s = scon->sock; - cs->pfd.reqevents = APR_POLLIN; + scon->pfd.p = scon->pool; + scon->pfd.desc_type = APR_POLL_SOCKET; + scon->pfd.desc.s = scon->sock; + scon->pfd.reqevents = APR_POLLIN; sb->type = SIMPLE_PT_CORE_IO; sb->baton = scon; - cs->pfd.client_data = sb; + scon->pfd.client_data = sb; ap_update_vhost_given_ip(scon->c); @@ -237,7 +232,7 @@ static void *simple_io_setup_conn(apr_thread_t * thread, void *baton) scon->c->aborted = 1; } - scon->c->cs->state = CONN_STATE_READ_REQUEST_LINE; + scon->cs.state = CONN_STATE_READ_REQUEST_LINE; rv = simple_io_process(scon); diff --git a/server/mpm/simple/simple_types.h b/server/mpm/simple/simple_types.h index a71691f5f7..de38ea4cca 100644 --- a/server/mpm/simple/simple_types.h +++ b/server/mpm/simple/simple_types.h @@ -122,6 +122,10 @@ struct simple_conn_t apr_socket_t *sock; apr_bucket_alloc_t *ba; conn_rec *c; + /** poll file descriptor information */ + apr_pollfd_t pfd; + /** public parts of the connection state */ + conn_state_t cs; }; simple_core_t *simple_core_get(void); -- 2.40.0