mirror of
https://github.com/apache/httpd.git
synced 2025-08-07 04:02:58 +03:00
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
This commit is contained in:
@@ -367,14 +367,15 @@
|
|||||||
* 20111025.2 (2.3.15-dev) Add ap_lua_ssl_val to mod_lua
|
* 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.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
|
* 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" */
|
#define MODULE_MAGIC_COOKIE 0x41503234UL /* "AP24" */
|
||||||
|
|
||||||
#ifndef MODULE_MAGIC_NUMBER_MAJOR
|
#ifndef MODULE_MAGIC_NUMBER_MAJOR
|
||||||
#define MODULE_MAGIC_NUMBER_MAJOR 20111118
|
#define MODULE_MAGIC_NUMBER_MAJOR 20111120
|
||||||
#endif
|
#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
|
* Determine if the server's current MODULE_MAGIC_NUMBER is at least a
|
||||||
|
@@ -1144,18 +1144,6 @@ typedef enum {
|
|||||||
* @brief A structure to contain connection state information
|
* @brief A structure to contain connection state information
|
||||||
*/
|
*/
|
||||||
struct conn_state_t {
|
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 */
|
/** Current state of the connection */
|
||||||
conn_state_e state;
|
conn_state_e state;
|
||||||
};
|
};
|
||||||
|
@@ -126,6 +126,7 @@ static int ap_process_http_async_connection(conn_rec *c)
|
|||||||
request_rec *r;
|
request_rec *r;
|
||||||
conn_state_t *cs = c->cs;
|
conn_state_t *cs = c->cs;
|
||||||
|
|
||||||
|
AP_DEBUG_ASSERT(cs != NULL);
|
||||||
AP_DEBUG_ASSERT(cs->state == CONN_STATE_READ_REQUEST_LINE);
|
AP_DEBUG_ASSERT(cs->state == CONN_STATE_READ_REQUEST_LINE);
|
||||||
|
|
||||||
while (cs->state == CONN_STATE_READ_REQUEST_LINE) {
|
while (cs->state == CONN_STATE_READ_REQUEST_LINE) {
|
||||||
|
@@ -260,7 +260,8 @@ AP_DECLARE(void) ap_process_request_after_handler(request_rec *r)
|
|||||||
* already by the EOR bucket's cleanup function.
|
* 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);
|
check_pipeline(c);
|
||||||
AP_PROCESS_REQUEST_RETURN((uintptr_t)r, r->uri, r->status);
|
AP_PROCESS_REQUEST_RETURN((uintptr_t)r, r->uri, r->status);
|
||||||
if (ap_extended_status) {
|
if (ap_extended_status) {
|
||||||
@@ -325,7 +326,8 @@ void ap_process_async_request(request_rec *r)
|
|||||||
if (ap_extended_status) {
|
if (ap_extended_status) {
|
||||||
ap_time_process_request(c->sbh, STOP_PREQUEST);
|
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
|
#if APR_HAS_THREADS
|
||||||
apr_thread_mutex_unlock(r->invoke_mtx);
|
apr_thread_mutex_unlock(r->invoke_mtx);
|
||||||
#endif
|
#endif
|
||||||
|
@@ -4511,13 +4511,6 @@ static conn_rec *core_create_conn(apr_pool_t *ptrans, server_rec *server,
|
|||||||
c->id = id;
|
c->id = id;
|
||||||
c->bucket_alloc = alloc;
|
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;
|
c->clogging_input_filters = 0;
|
||||||
|
|
||||||
return c;
|
return c;
|
||||||
|
@@ -192,13 +192,31 @@ typedef enum {
|
|||||||
TIMEOUT_SHORT_LINGER
|
TIMEOUT_SHORT_LINGER
|
||||||
} timeout_type_e;
|
} 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 {
|
typedef struct pollset_op_t {
|
||||||
timeout_type_e timeout_type;
|
timeout_type_e timeout_type;
|
||||||
conn_state_t *cs;
|
event_conn_state_t *cs;
|
||||||
const char *tag;
|
const char *tag;
|
||||||
} pollset_op_t;
|
} 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_queue {
|
||||||
struct timeout_head_t head;
|
struct timeout_head_t head;
|
||||||
int count;
|
int count;
|
||||||
@@ -220,10 +238,10 @@ static apr_pollfd_t *listener_pollfd;
|
|||||||
* Macros for accessing struct timeout_queue.
|
* Macros for accessing struct timeout_queue.
|
||||||
* For TO_QUEUE_APPEND and TO_QUEUE_REMOVE, timeout_mutex must be held.
|
* For TO_QUEUE_APPEND and TO_QUEUE_REMOVE, timeout_mutex must be held.
|
||||||
*/
|
*/
|
||||||
#define TO_QUEUE_APPEND(q, el) \
|
#define TO_QUEUE_APPEND(q, el) \
|
||||||
do { \
|
do { \
|
||||||
APR_RING_INSERT_TAIL(&(q).head, el, conn_state_t, timeout_list); \
|
APR_RING_INSERT_TAIL(&(q).head, el, event_conn_state_t, timeout_list); \
|
||||||
(q).count++; \
|
(q).count++; \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#define TO_QUEUE_REMOVE(q, el) \
|
#define TO_QUEUE_REMOVE(q, el) \
|
||||||
@@ -232,10 +250,10 @@ static apr_pollfd_t *listener_pollfd;
|
|||||||
(q).count--; \
|
(q).count--; \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#define TO_QUEUE_INIT(q) \
|
#define TO_QUEUE_INIT(q) \
|
||||||
do { \
|
do { \
|
||||||
APR_RING_INIT(&(q).head, conn_state_t, timeout_list); \
|
APR_RING_INIT(&(q).head, event_conn_state_t, timeout_list); \
|
||||||
(q).tag = #q; \
|
(q).tag = #q; \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#define TO_QUEUE_ELEM_INIT(el) APR_RING_ELEM_INIT(el, timeout_list)
|
#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)
|
static void process_pollop(pollset_op_t *op)
|
||||||
{
|
{
|
||||||
apr_status_t rv;
|
apr_status_t rv;
|
||||||
conn_state_t *cs = op->cs;
|
event_conn_state_t *cs = op->cs;
|
||||||
|
|
||||||
switch (op->timeout_type) {
|
switch (op->timeout_type) {
|
||||||
case TIMEOUT_WRITE_COMPLETION:
|
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,
|
* the eq may be null if called from the listener thread,
|
||||||
* and the pollset operations are done directly by this function.
|
* 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;
|
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);
|
apr_time_now() + apr_time_from_sec(SECONDS_TO_LINGER);
|
||||||
v->timeout_type = TIMEOUT_SHORT_LINGER;
|
v->timeout_type = TIMEOUT_SHORT_LINGER;
|
||||||
v->tag = "start_lingering_close(short)";
|
v->tag = "start_lingering_close(short)";
|
||||||
cs->state = CONN_STATE_LINGER_SHORT;
|
cs->pub.state = CONN_STATE_LINGER_SHORT;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
cs->expiration_time =
|
cs->expiration_time =
|
||||||
apr_time_now() + apr_time_from_sec(MAX_SECS_TO_LINGER);
|
apr_time_now() + apr_time_from_sec(MAX_SECS_TO_LINGER);
|
||||||
v->timeout_type = TIMEOUT_LINGER;
|
v->timeout_type = TIMEOUT_LINGER;
|
||||||
v->tag = "start_lingering_close(normal)";
|
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;
|
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
|
* Pre-condition: cs is not in any timeout queue and not in the pollset
|
||||||
* return: irrelevant (need same prototype as start_lingering_close)
|
* 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_status_t rv;
|
||||||
apr_socket_t *csd = ap_get_conn_socket(cs->c);
|
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
|
* 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,
|
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,
|
ap_equeue_t *eq,
|
||||||
int my_child_num,
|
int my_child_num,
|
||||||
int my_thread_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 */
|
if (cs == NULL) { /* This is a new connection */
|
||||||
listener_poll_type *pt = apr_pcalloc(p, sizeof(*pt));
|
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);
|
cs->bucket_alloc = apr_bucket_alloc_create(p);
|
||||||
c = ap_run_create_connection(p, ap_server_conf, sock,
|
c = ap_run_create_connection(p, ap_server_conf, sock,
|
||||||
conn_id, sbh, cs->bucket_alloc);
|
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);
|
apr_pool_cleanup_register(c->pool, NULL, decrement_connection_count, apr_pool_cleanup_null);
|
||||||
c->current_thread = thd;
|
c->current_thread = thd;
|
||||||
cs->c = c;
|
cs->c = c;
|
||||||
c->cs = cs;
|
c->cs = &(cs->pub);
|
||||||
cs->p = p;
|
cs->p = p;
|
||||||
cs->pfd.desc_type = APR_POLL_SOCKET;
|
cs->pfd.desc_type = APR_POLL_SOCKET;
|
||||||
cs->pfd.reqevents = APR_POLLIN;
|
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
|
* When the accept filter is active, sockets are kept in the
|
||||||
* kernel until a HTTP request is received.
|
* kernel until a HTTP request is received.
|
||||||
*/
|
*/
|
||||||
cs->state = CONN_STATE_READ_REQUEST_LINE;
|
cs->pub.state = CONN_STATE_READ_REQUEST_LINE;
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
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.
|
* like the Worker MPM does.
|
||||||
*/
|
*/
|
||||||
ap_run_process_connection(c);
|
ap_run_process_connection(c);
|
||||||
if (cs->state != CONN_STATE_SUSPENDED) {
|
if (cs->pub.state != CONN_STATE_SUSPENDED) {
|
||||||
cs->state = CONN_STATE_LINGER;
|
cs->pub.state = CONN_STATE_LINGER;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
read_request:
|
read_request:
|
||||||
if (cs->state == CONN_STATE_READ_REQUEST_LINE) {
|
if (cs->pub.state == CONN_STATE_READ_REQUEST_LINE) {
|
||||||
if (!c->aborted) {
|
if (!c->aborted) {
|
||||||
ap_run_process_connection(c);
|
ap_run_process_connection(c);
|
||||||
|
|
||||||
@@ -968,11 +986,11 @@ read_request:
|
|||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
else {
|
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;
|
ap_filter_t *output_filter = c->output_filters;
|
||||||
apr_status_t rv;
|
apr_status_t rv;
|
||||||
ap_update_child_status_from_conn(sbh, SERVER_BUSY_WRITE, c);
|
ap_update_child_status_from_conn(sbh, SERVER_BUSY_WRITE, c);
|
||||||
@@ -983,7 +1001,7 @@ read_request:
|
|||||||
if (rv != APR_SUCCESS) {
|
if (rv != APR_SUCCESS) {
|
||||||
ap_log_cerror(APLOG_MARK, APLOG_DEBUG, rv, c,
|
ap_log_cerror(APLOG_MARK, APLOG_DEBUG, rv, c,
|
||||||
"network write failure in core output filter");
|
"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) {
|
else if (c->data_in_output_filters) {
|
||||||
/* Still in WRITE_COMPLETION_STATE:
|
/* Still in WRITE_COMPLETION_STATE:
|
||||||
@@ -1005,23 +1023,23 @@ read_request:
|
|||||||
}
|
}
|
||||||
else if (c->keepalive != AP_CONN_KEEPALIVE || c->aborted ||
|
else if (c->keepalive != AP_CONN_KEEPALIVE || c->aborted ||
|
||||||
listener_may_exit) {
|
listener_may_exit) {
|
||||||
c->cs->state = CONN_STATE_LINGER;
|
cs->pub.state = CONN_STATE_LINGER;
|
||||||
}
|
}
|
||||||
else if (c->data_in_input_filters) {
|
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;
|
goto read_request;
|
||||||
}
|
}
|
||||||
else {
|
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)) {
|
if (!start_lingering_close(cs, eq)) {
|
||||||
return 0;
|
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;
|
pollset_op_t *v;
|
||||||
|
|
||||||
/* It greatly simplifies the logic to use a single timeout value here
|
/* 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)
|
apr_pollset_t * pollset)
|
||||||
{
|
{
|
||||||
listener_poll_type *pt = (listener_poll_type *) pfd->client_data;
|
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;
|
apr_status_t rc;
|
||||||
|
|
||||||
rc = ap_queue_push(worker_queue, cs->pfd.desc.s, cs, cs->p);
|
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;
|
* Only to be called in the listener thread;
|
||||||
* Pre-condition: cs is in one of the linger queues and in the pollset
|
* 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);
|
apr_socket_t *csd = ap_get_conn_socket(cs->c);
|
||||||
char dummybuf[2048];
|
char dummybuf[2048];
|
||||||
apr_size_t nbytes;
|
apr_size_t nbytes;
|
||||||
apr_status_t rv;
|
apr_status_t rv;
|
||||||
struct timeout_queue *q;
|
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 */
|
/* socket is already in non-blocking state */
|
||||||
do {
|
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,
|
static void process_timeout_queue(struct timeout_queue *q,
|
||||||
apr_time_t timeout_time,
|
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;
|
int count = 0;
|
||||||
conn_state_t *first, *cs, *last;
|
event_conn_state_t *first, *cs, *last;
|
||||||
apr_status_t rv;
|
apr_status_t rv;
|
||||||
if (!q->count) {
|
if (!q->count) {
|
||||||
return;
|
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);
|
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) {
|
&& cs->expiration_time < timeout_time) {
|
||||||
last = cs;
|
last = cs;
|
||||||
rv = apr_pollset_remove(event_pollset, &cs->pfd);
|
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 */
|
apr_pool_t *ptrans; /* Pool for per-transaction stuff */
|
||||||
ap_listen_rec *lr;
|
ap_listen_rec *lr;
|
||||||
int have_idle_worker = 0;
|
int have_idle_worker = 0;
|
||||||
conn_state_t *cs;
|
event_conn_state_t *cs;
|
||||||
const apr_pollfd_t *out_pfd;
|
const apr_pollfd_t *out_pfd;
|
||||||
apr_int32_t num = 0;
|
apr_int32_t num = 0;
|
||||||
apr_interval_time_t timeout_interval;
|
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 */
|
/* one of the sockets is readable */
|
||||||
struct timeout_queue *remove_from_q = &write_completion_q;
|
struct timeout_queue *remove_from_q = &write_completion_q;
|
||||||
int blocking = 1;
|
int blocking = 1;
|
||||||
cs = (conn_state_t *) pt->baton;
|
cs = (event_conn_state_t *)pt->baton;
|
||||||
switch (cs->state) {
|
switch (cs->pub.state) {
|
||||||
case CONN_STATE_CHECK_REQUEST_LINE_READABLE:
|
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;
|
remove_from_q = &keepalive_q;
|
||||||
/* don't wait for a worker for a keepalive request */
|
/* don't wait for a worker for a keepalive request */
|
||||||
blocking = 0;
|
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_log_error(APLOG_MARK, APLOG_CRIT, rc,
|
||||||
ap_server_conf,
|
ap_server_conf,
|
||||||
"event_loop: unexpected state %d",
|
"event_loop: unexpected state %d",
|
||||||
cs->state);
|
cs->pub.state);
|
||||||
ap_assert(0);
|
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 process_slot = ti->pid;
|
||||||
int thread_slot = ti->tid;
|
int thread_slot = ti->tid;
|
||||||
apr_socket_t *csd = NULL;
|
apr_socket_t *csd = NULL;
|
||||||
conn_state_t *cs;
|
event_conn_state_t *cs;
|
||||||
apr_pool_t *ptrans; /* Pool for per-transaction stuff */
|
apr_pool_t *ptrans; /* Pool for per-transaction stuff */
|
||||||
apr_status_t rv;
|
apr_status_t rv;
|
||||||
int is_idle = 0;
|
int is_idle = 0;
|
||||||
|
@@ -364,7 +364,7 @@ apr_status_t ap_queue_init(fd_queue_t * queue, int queue_capacity,
|
|||||||
* to reserve an idle worker thread
|
* to reserve an idle worker thread
|
||||||
*/
|
*/
|
||||||
apr_status_t ap_queue_push(fd_queue_t * queue, apr_socket_t * sd,
|
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;
|
fd_queue_elem_t *elem;
|
||||||
apr_status_t rv;
|
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)
|
if (queue->in >= queue->bounds)
|
||||||
queue->in -= queue->bounds;
|
queue->in -= queue->bounds;
|
||||||
elem->sd = sd;
|
elem->sd = sd;
|
||||||
elem->cs = cs;
|
elem->ecs = ecs;
|
||||||
elem->p = p;
|
elem->p = p;
|
||||||
queue->nelts++;
|
queue->nelts++;
|
||||||
|
|
||||||
@@ -422,7 +422,7 @@ apr_status_t ap_queue_push_timer(fd_queue_t * queue, timer_event_t *te)
|
|||||||
* 'sd'.
|
* 'sd'.
|
||||||
*/
|
*/
|
||||||
apr_status_t ap_queue_pop_something(fd_queue_t * queue, apr_socket_t ** 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)
|
timer_event_t ** te_out)
|
||||||
{
|
{
|
||||||
fd_queue_elem_t *elem;
|
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->out -= queue->bounds;
|
||||||
queue->nelts--;
|
queue->nelts--;
|
||||||
*sd = elem->sd;
|
*sd = elem->sd;
|
||||||
*cs = elem->cs;
|
*ecs = elem->ecs;
|
||||||
*p = elem->p;
|
*p = elem->p;
|
||||||
#ifdef AP_DEBUG
|
#ifdef AP_DEBUG
|
||||||
elem->sd = NULL;
|
elem->sd = NULL;
|
||||||
|
@@ -40,6 +40,7 @@
|
|||||||
#include "ap_mpm.h"
|
#include "ap_mpm.h"
|
||||||
|
|
||||||
typedef struct fd_queue_info_t fd_queue_info_t;
|
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_status_t ap_queue_info_create(fd_queue_info_t ** queue_info,
|
||||||
apr_pool_t * pool, int max_idlers,
|
apr_pool_t * pool, int max_idlers,
|
||||||
@@ -56,7 +57,7 @@ struct fd_queue_elem_t
|
|||||||
{
|
{
|
||||||
apr_socket_t *sd;
|
apr_socket_t *sd;
|
||||||
apr_pool_t *p;
|
apr_pool_t *p;
|
||||||
conn_state_t *cs;
|
event_conn_state_t *ecs;
|
||||||
};
|
};
|
||||||
typedef struct fd_queue_elem_t fd_queue_elem_t;
|
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_status_t ap_queue_init(fd_queue_t * queue, int queue_capacity,
|
||||||
apr_pool_t * a);
|
apr_pool_t * a);
|
||||||
apr_status_t ap_queue_push(fd_queue_t * queue, apr_socket_t * sd,
|
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_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,
|
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);
|
timer_event_t ** te);
|
||||||
apr_status_t ap_queue_interrupt_all(fd_queue_t * queue);
|
apr_status_t ap_queue_interrupt_all(fd_queue_t * queue);
|
||||||
apr_status_t ap_queue_term(fd_queue_t * queue);
|
apr_status_t ap_queue_term(fd_queue_t * queue);
|
||||||
|
@@ -36,7 +36,6 @@ static void simple_io_timeout_cb(simple_core_t * sc, void *baton)
|
|||||||
simple_conn_t *scon = (simple_conn_t *) baton;
|
simple_conn_t *scon = (simple_conn_t *) baton;
|
||||||
/* pqXXXXX: handle timeouts. */
|
/* pqXXXXX: handle timeouts. */
|
||||||
conn_rec *c = scon->c;
|
conn_rec *c = scon->c;
|
||||||
conn_state_t *cs = c->cs;
|
|
||||||
|
|
||||||
cs = NULL;
|
cs = NULL;
|
||||||
#endif
|
#endif
|
||||||
@@ -50,7 +49,6 @@ static apr_status_t simple_io_process(simple_conn_t * scon)
|
|||||||
apr_status_t rv;
|
apr_status_t rv;
|
||||||
simple_core_t *sc;
|
simple_core_t *sc;
|
||||||
conn_rec *c;
|
conn_rec *c;
|
||||||
conn_state_t *cs;
|
|
||||||
|
|
||||||
if (scon->c->clogging_input_filters && !scon->c->aborted) {
|
if (scon->c->clogging_input_filters && !scon->c->aborted) {
|
||||||
/* Since we have an input filter which 'cloggs' the input stream,
|
/* 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.
|
* like the Worker MPM does.
|
||||||
*/
|
*/
|
||||||
ap_run_process_connection(scon->c);
|
ap_run_process_connection(scon->c);
|
||||||
if (scon->c->cs->state != CONN_STATE_SUSPENDED) {
|
if (scon->cs.state != CONN_STATE_SUSPENDED) {
|
||||||
scon->c->cs->state = CONN_STATE_LINGER;
|
scon->cs.state = CONN_STATE_LINGER;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sc = scon->sc;
|
sc = scon->sc;
|
||||||
c = scon->c;
|
c = scon->c;
|
||||||
cs = c->cs;
|
|
||||||
|
|
||||||
while (!c->aborted) {
|
while (!c->aborted) {
|
||||||
|
|
||||||
if (cs->pfd.reqevents != 0) {
|
if (scon->pfd.reqevents != 0) {
|
||||||
rv = apr_pollcb_remove(sc->pollcb, &cs->pfd);
|
rv = apr_pollcb_remove(sc->pollcb, &scon->pfd);
|
||||||
if (rv) {
|
if (rv) {
|
||||||
ap_log_error(APLOG_MARK, APLOG_ERR, rv, ap_server_conf,
|
ap_log_error(APLOG_MARK, APLOG_ERR, rv, ap_server_conf,
|
||||||
"simple_io_process: apr_pollcb_remove failure");
|
"simple_io_process: apr_pollcb_remove failure");
|
||||||
/*AP_DEBUG_ASSERT(rv == APR_SUCCESS);*/
|
/*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) {
|
if (!c->aborted) {
|
||||||
ap_run_process_connection(c);
|
ap_run_process_connection(c);
|
||||||
/* state will be updated upon return
|
/* state will be updated upon return
|
||||||
@@ -88,11 +85,11 @@ static apr_status_t simple_io_process(simple_conn_t * scon)
|
|||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
else {
|
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;
|
ap_filter_t *output_filter = c->output_filters;
|
||||||
while (output_filter->next != NULL) {
|
while (output_filter->next != NULL) {
|
||||||
output_filter = output_filter->next;
|
output_filter = output_filter->next;
|
||||||
@@ -104,7 +101,7 @@ static apr_status_t simple_io_process(simple_conn_t * scon)
|
|||||||
if (rv != APR_SUCCESS) {
|
if (rv != APR_SUCCESS) {
|
||||||
ap_log_error(APLOG_MARK, APLOG_WARNING, rv, ap_server_conf,
|
ap_log_error(APLOG_MARK, APLOG_WARNING, rv, ap_server_conf,
|
||||||
"network write failure in core output filter");
|
"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) {
|
else if (c->data_in_output_filters) {
|
||||||
/* Still in WRITE_COMPLETION_STATE:
|
/* 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,
|
timeout : ap_server_conf->timeout,
|
||||||
scon->pool);
|
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) {
|
if (rv != APR_SUCCESS) {
|
||||||
ap_log_error(APLOG_MARK, APLOG_WARNING, rv,
|
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;
|
return APR_SUCCESS;
|
||||||
}
|
}
|
||||||
else if (c->keepalive != AP_CONN_KEEPALIVE || c->aborted) {
|
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) {
|
else if (c->data_in_input_filters) {
|
||||||
cs->state = CONN_STATE_READ_REQUEST_LINE;
|
scon->cs.state = CONN_STATE_READ_REQUEST_LINE;
|
||||||
}
|
}
|
||||||
else {
|
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);
|
ap_lingering_close(c);
|
||||||
apr_pool_destroy(scon->pool);
|
apr_pool_destroy(scon->pool);
|
||||||
return APR_SUCCESS;
|
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_register_timer(scon->sc,
|
||||||
simple_io_timeout_cb,
|
simple_io_timeout_cb,
|
||||||
scon,
|
scon,
|
||||||
@@ -158,9 +155,9 @@ static apr_status_t simple_io_process(simple_conn_t * scon)
|
|||||||
timeout : ap_server_conf->timeout,
|
timeout : ap_server_conf->timeout,
|
||||||
scon->pool);
|
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) {
|
if (rv) {
|
||||||
ap_log_error(APLOG_MARK, APLOG_ERR, rv, ap_server_conf,
|
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;
|
apr_status_t rv;
|
||||||
ap_sb_handle_t *sbh;
|
ap_sb_handle_t *sbh;
|
||||||
conn_state_t *cs;
|
|
||||||
long conn_id = 0;
|
long conn_id = 0;
|
||||||
simple_sb_t *sb;
|
simple_sb_t *sb;
|
||||||
simple_conn_t *scon = (simple_conn_t *) baton;
|
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);
|
conn_id, sbh, scon->ba);
|
||||||
/* XXX: handle failure */
|
/* XXX: handle failure */
|
||||||
|
|
||||||
scon->c->cs = apr_pcalloc(scon->pool, sizeof(conn_state_t));
|
scon->c->cs = &scon->cs;
|
||||||
cs = scon->c->cs;
|
|
||||||
sb = apr_pcalloc(scon->pool, sizeof(simple_sb_t));
|
sb = apr_pcalloc(scon->pool, sizeof(simple_sb_t));
|
||||||
|
|
||||||
scon->c->current_thread = thread;
|
scon->c->current_thread = thread;
|
||||||
|
|
||||||
cs->pfd.p = scon->pool;
|
scon->pfd.p = scon->pool;
|
||||||
cs->pfd.desc_type = APR_POLL_SOCKET;
|
scon->pfd.desc_type = APR_POLL_SOCKET;
|
||||||
cs->pfd.desc.s = scon->sock;
|
scon->pfd.desc.s = scon->sock;
|
||||||
cs->pfd.reqevents = APR_POLLIN;
|
scon->pfd.reqevents = APR_POLLIN;
|
||||||
|
|
||||||
sb->type = SIMPLE_PT_CORE_IO;
|
sb->type = SIMPLE_PT_CORE_IO;
|
||||||
sb->baton = scon;
|
sb->baton = scon;
|
||||||
cs->pfd.client_data = sb;
|
scon->pfd.client_data = sb;
|
||||||
|
|
||||||
ap_update_vhost_given_ip(scon->c);
|
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->aborted = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
scon->c->cs->state = CONN_STATE_READ_REQUEST_LINE;
|
scon->cs.state = CONN_STATE_READ_REQUEST_LINE;
|
||||||
|
|
||||||
rv = simple_io_process(scon);
|
rv = simple_io_process(scon);
|
||||||
|
|
||||||
|
@@ -122,6 +122,10 @@ struct simple_conn_t
|
|||||||
apr_socket_t *sock;
|
apr_socket_t *sock;
|
||||||
apr_bucket_alloc_t *ba;
|
apr_bucket_alloc_t *ba;
|
||||||
conn_rec *c;
|
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);
|
simple_core_t *simple_core_get(void);
|
||||||
|
Reference in New Issue
Block a user