On Sat, 12 Nov 2011, Stefan Fritsch wrote:
locking for the timeout queues. But what we really should do in 2.4.0 is
remove all the MPM-implementation specific details from conn_state_t. The
only field that is actually used outside of the MPMs is 'state'. If we make
the rest non-public and somehow change the logic for the conn_state_t to be
created by the MPM, we can switch to an improved implementation of timeout
queues in 2.4.x.
The attached patch does this and works with event. I can't test simple
because it just loops for me and eats all memory. If anyone can, please
do.diff --git a/include/ap_mmn.h b/include/ap_mmn.h
index dac9c1f..7b30335 100644
--- a/include/ap_mmn.h
+++ b/include/ap_mmn.h
@@ -365,14 +365,15 @@
* 20111025.1 (2.3.15-dev) Add ap_escape_urlencoded(), ap_escape_urlencoded_buffer()
* and ap_unescape_urlencoded().
* 20111025.2 (2.3.15-dev) Add ap_lua_ssl_val to mod_lua
+ * 20111112.0 (2.4.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 20111025
+#define MODULE_MAGIC_NUMBER_MAJOR 20111112
#endif
-#define MODULE_MAGIC_NUMBER_MINOR 2 /* 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 464f4a1..7c347c1 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 8970ae6..8421f42 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 0a25333..319be84 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 751c322..b96fe76 100644
--- a/server/core.c
+++ b/server/core.c
@@ -4525,13 +4525,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 75af4f4..09f61b0 100644
--- a/server/mpm/event/event.c
+++ b/server/mpm/event/event.c
@@ -183,8 +183,25 @@ static fd_queue_t *worker_queue;
static fd_queue_info_t *worker_queue_info;
static int mpm_state = AP_MPMQ_STARTING;
+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;
+};
+
static apr_thread_mutex_t *timeout_mutex;
-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;
@@ -206,10 +223,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) \
@@ -218,10 +235,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)
@@ -745,7 +762,7 @@ static void set_signals(void)
* 1 if connection is lingering
* may be called by listener or by worker thread
*/
-static int start_lingering_close(conn_state_t *cs)
+static int start_lingering_close(event_conn_state_t *cs)
{
apr_status_t rv;
if (ap_start_lingering_close(cs->c)) {
@@ -768,13 +785,13 @@ static int start_lingering_close(conn_state_t *cs)
cs->expiration_time =
apr_time_now() + apr_time_from_sec(SECONDS_TO_LINGER);
q = &short_linger_q;
- 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);
q = &linger_q;
- cs->state = CONN_STATE_LINGER_NORMAL;
+ cs->pub.state = CONN_STATE_LINGER_NORMAL;
}
apr_thread_mutex_lock(timeout_mutex);
TO_QUEUE_APPEND(*q, cs);
@@ -802,7 +819,7 @@ static int start_lingering_close(conn_state_t *cs)
* 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)
+static int stop_lingering_close(event_conn_state_t *cs)
{
apr_status_t rv;
apr_socket_t *csd = ap_get_conn_socket(cs->c);
@@ -824,7 +841,7 @@ static int stop_lingering_close(conn_state_t *cs)
* 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, int my_child_num,
+ event_conn_state_t * cs, int my_child_num,
int my_thread_num)
{
conn_rec *c;
@@ -836,7 +853,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);
@@ -850,7 +867,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;
@@ -882,7 +899,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 {
@@ -897,13 +914,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);
@@ -913,11 +930,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);
@@ -928,7 +945,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:
@@ -945,22 +962,22 @@ 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))
return 0;
}
- else if (cs->state == CONN_STATE_CHECK_REQUEST_LINE_READABLE) {
+ else if (cs->pub.state == CONN_STATE_CHECK_REQUEST_LINE_READABLE) {
apr_status_t rc;
/* It greatly simplifies the logic to use a single timeout value here
@@ -1132,7 +1149,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);
@@ -1254,14 +1271,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 {
@@ -1294,18 +1311,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 *))
+ int (*func)(event_conn_state_t *))
{
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);
@@ -1345,7 +1362,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;
@@ -1472,10 +1489,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;
@@ -1528,7 +1545,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);
}
}
@@ -1711,7 +1728,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 f7de0bf..3291175 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 5877ee7..955816b 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 50e2d6a..c3d5373 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 a71691f..de38ea4 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);