mirror of
https://github.com/apache/httpd.git
synced 2025-08-08 15:02:10 +03:00
Change conn_rec->keepalive to an enumerated value of
AP_CONN_UNKNOWN AP_CONN_CLOSE AP_CONN_KEEPALIVE This also fixes a problem where ap_discard_request_body would not discard the body when keepalive was 0. This actually meant the keepalive status was unknown *not* closed, but no one ever remembered that. This problem was seen with mod_dav sending error responses (as reported by Karl Fogel). Suggested by: Greg "this isn't the '80s" Stein Reviewed by: Greg Ames git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@95891 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
3
CHANGES
3
CHANGES
@@ -1,5 +1,8 @@
|
|||||||
Changes with Apache 2.0.40
|
Changes with Apache 2.0.40
|
||||||
|
|
||||||
|
*) Switch conn_rec->keepalive to an enumeration rather than a bitfield.
|
||||||
|
[Justin Erenkrantz]
|
||||||
|
|
||||||
*) Fix mod_ext_filter to look in the main server for filter definitions
|
*) Fix mod_ext_filter to look in the main server for filter definitions
|
||||||
when running in a vhost if the filter definition is not found in
|
when running in a vhost if the filter definition is not found in
|
||||||
the vhost. PR 10147 [Jeff Trawick]
|
the vhost. PR 10147 [Jeff Trawick]
|
||||||
|
@@ -108,14 +108,15 @@
|
|||||||
* 20020529 (2.0.37-dev) Standardized the names of some apr_pool_*_set funcs
|
* 20020529 (2.0.37-dev) Standardized the names of some apr_pool_*_set funcs
|
||||||
* 20020602 (2.0.37-dev) Bucket API change (metadata buckets)
|
* 20020602 (2.0.37-dev) Bucket API change (metadata buckets)
|
||||||
* 20020612 (2.0.38-dev) Changed server_rec->[keep_alive_]timeout to apr time
|
* 20020612 (2.0.38-dev) Changed server_rec->[keep_alive_]timeout to apr time
|
||||||
|
* 20020625 (2.0.40-dev) Changed conn_rec->keepalive to an enumeration
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define MODULE_MAGIC_COOKIE 0x41503230UL /* "AP20" */
|
#define MODULE_MAGIC_COOKIE 0x41503230UL /* "AP20" */
|
||||||
|
|
||||||
#ifndef MODULE_MAGIC_NUMBER_MAJOR
|
#ifndef MODULE_MAGIC_NUMBER_MAJOR
|
||||||
#define MODULE_MAGIC_NUMBER_MAJOR 20020612
|
#define MODULE_MAGIC_NUMBER_MAJOR 20020625
|
||||||
#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
|
||||||
|
@@ -951,6 +951,11 @@ struct request_rec {
|
|||||||
|
|
||||||
/* @} */
|
/* @} */
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
AP_CONN_UNKNOWN,
|
||||||
|
AP_CONN_CLOSE,
|
||||||
|
AP_CONN_KEEPALIVE
|
||||||
|
} ap_conn_keepalive_e;
|
||||||
|
|
||||||
/** Structure to store things which are per connection */
|
/** Structure to store things which are per connection */
|
||||||
struct conn_rec {
|
struct conn_rec {
|
||||||
@@ -981,8 +986,8 @@ struct conn_rec {
|
|||||||
unsigned aborted:1;
|
unsigned aborted:1;
|
||||||
|
|
||||||
/** Are we going to keep the connection alive for another request?
|
/** Are we going to keep the connection alive for another request?
|
||||||
* -1 fatal error, 0 undecided, 1 yes */
|
* @see ap_conn_keepalive_e */
|
||||||
signed int keepalive:2;
|
ap_conn_keepalive_e keepalive;
|
||||||
|
|
||||||
/** have we done double-reverse DNS? -1 yes/failure, 0 not yet,
|
/** have we done double-reverse DNS? -1 yes/failure, 0 not yet,
|
||||||
* 1 yes/success */
|
* 1 yes/success */
|
||||||
|
@@ -1093,7 +1093,7 @@ int APR_THREAD_FUNC ServerSupportFunction(isapi_cid *cid,
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
case HSE_REQ_IS_KEEP_CONN:
|
case HSE_REQ_IS_KEEP_CONN:
|
||||||
*((int *)buf_data) = (r->connection->keepalive == 1);
|
*((int *)buf_data) = (r->connection->keepalive == AP_CONN_KEEPALIVE);
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
case HSE_REQ_ASYNC_READ_CLIENT:
|
case HSE_REQ_ASYNC_READ_CLIENT:
|
||||||
|
@@ -283,7 +283,7 @@ static int ap_process_http_connection(conn_rec *c)
|
|||||||
ap_update_child_status(c->sbh, SERVER_BUSY_READ, NULL);
|
ap_update_child_status(c->sbh, SERVER_BUSY_READ, NULL);
|
||||||
while ((r = ap_read_request(c)) != NULL) {
|
while ((r = ap_read_request(c)) != NULL) {
|
||||||
|
|
||||||
c->keepalive = 0;
|
c->keepalive = AP_CONN_UNKNOWN;
|
||||||
/* process the request if it was read without error */
|
/* process the request if it was read without error */
|
||||||
|
|
||||||
ap_update_child_status(c->sbh, SERVER_BUSY_WRITE, r);
|
ap_update_child_status(c->sbh, SERVER_BUSY_WRITE, r);
|
||||||
@@ -293,7 +293,7 @@ static int ap_process_http_connection(conn_rec *c)
|
|||||||
if (ap_extended_status)
|
if (ap_extended_status)
|
||||||
ap_increment_counts(c->sbh, r);
|
ap_increment_counts(c->sbh, r);
|
||||||
|
|
||||||
if (!c->keepalive || c->aborted)
|
if (c->keepalive != AP_CONN_KEEPALIVE || c->aborted)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
ap_update_child_status(c->sbh, SERVER_BUSY_KEEPALIVE, r);
|
ap_update_child_status(c->sbh, SERVER_BUSY_KEEPALIVE, r);
|
||||||
|
@@ -223,7 +223,7 @@ AP_DECLARE(int) ap_set_keepalive(request_rec *r)
|
|||||||
*
|
*
|
||||||
* Note that the condition evaluation order is extremely important.
|
* Note that the condition evaluation order is extremely important.
|
||||||
*/
|
*/
|
||||||
if ((r->connection->keepalive != -1)
|
if ((r->connection->keepalive != AP_CONN_CLOSE)
|
||||||
&& ((r->status == HTTP_NOT_MODIFIED)
|
&& ((r->status == HTTP_NOT_MODIFIED)
|
||||||
|| (r->status == HTTP_NO_CONTENT)
|
|| (r->status == HTTP_NO_CONTENT)
|
||||||
|| r->header_only
|
|| r->header_only
|
||||||
@@ -247,7 +247,7 @@ AP_DECLARE(int) ap_set_keepalive(request_rec *r)
|
|||||||
|| (r->proto_num >= HTTP_VERSION(1,1)))) {
|
|| (r->proto_num >= HTTP_VERSION(1,1)))) {
|
||||||
int left = r->server->keep_alive_max - r->connection->keepalives;
|
int left = r->server->keep_alive_max - r->connection->keepalives;
|
||||||
|
|
||||||
r->connection->keepalive = 1;
|
r->connection->keepalive = AP_CONN_KEEPALIVE;
|
||||||
r->connection->keepalives++;
|
r->connection->keepalives++;
|
||||||
|
|
||||||
/* If they sent a Keep-Alive token, send one back */
|
/* If they sent a Keep-Alive token, send one back */
|
||||||
@@ -281,7 +281,7 @@ AP_DECLARE(int) ap_set_keepalive(request_rec *r)
|
|||||||
apr_table_mergen(r->headers_out, "Connection", "close");
|
apr_table_mergen(r->headers_out, "Connection", "close");
|
||||||
}
|
}
|
||||||
|
|
||||||
r->connection->keepalive = 0;
|
r->connection->keepalive = AP_CONN_CLOSE;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -1162,7 +1162,7 @@ static void basic_http_header_check(request_rec *r,
|
|||||||
if (r->proto_num == HTTP_VERSION(1,0)
|
if (r->proto_num == HTTP_VERSION(1,0)
|
||||||
&& apr_table_get(r->subprocess_env, "force-response-1.0")) {
|
&& apr_table_get(r->subprocess_env, "force-response-1.0")) {
|
||||||
*protocol = "HTTP/1.0";
|
*protocol = "HTTP/1.0";
|
||||||
r->connection->keepalive = -1;
|
r->connection->keepalive = AP_CONN_CLOSE;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
*protocol = AP_SERVER_PROTOCOL;
|
*protocol = AP_SERVER_PROTOCOL;
|
||||||
@@ -1835,7 +1835,7 @@ AP_DECLARE(long) ap_get_client_block(request_rec *r, char *buffer,
|
|||||||
/* if we actually fail here, we want to just return and
|
/* if we actually fail here, we want to just return and
|
||||||
* stop trying to read data from the client.
|
* stop trying to read data from the client.
|
||||||
*/
|
*/
|
||||||
r->connection->keepalive = -1;
|
r->connection->keepalive = AP_CONN_CLOSE;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1882,8 +1882,8 @@ AP_DECLARE(int) ap_discard_request_body(request_rec *r)
|
|||||||
*
|
*
|
||||||
* This function is also a no-op on a subrequest.
|
* This function is also a no-op on a subrequest.
|
||||||
*/
|
*/
|
||||||
if (r->main || !r->connection->keepalive
|
if (r->main || r->connection->keepalive == AP_CONN_CLOSE ||
|
||||||
|| ap_status_drops_connection(r->status)) {
|
ap_status_drops_connection(r->status)) {
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -143,7 +143,7 @@ AP_DECLARE(void) ap_die(int type, request_rec *r)
|
|||||||
* connection, be sure that the request body (if any) has been read.
|
* connection, be sure that the request body (if any) has been read.
|
||||||
*/
|
*/
|
||||||
if (ap_status_drops_connection(r->status)) {
|
if (ap_status_drops_connection(r->status)) {
|
||||||
r->connection->keepalive = 0;
|
r->connection->keepalive = AP_CONN_CLOSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -216,7 +216,7 @@ static void check_pipeline_flush(request_rec *r)
|
|||||||
*/
|
*/
|
||||||
/* ### shouldn't this read from the connection input filters? */
|
/* ### shouldn't this read from the connection input filters? */
|
||||||
/* ### is zero correct? that means "read one line" */
|
/* ### is zero correct? that means "read one line" */
|
||||||
if (!r->connection->keepalive ||
|
if (r->connection->keepalive == AP_CONN_CLOSE ||
|
||||||
ap_get_brigade(r->input_filters, bb, AP_MODE_EATCRLF,
|
ap_get_brigade(r->input_filters, bb, AP_MODE_EATCRLF,
|
||||||
APR_NONBLOCK_READ, 0) != APR_SUCCESS) {
|
APR_NONBLOCK_READ, 0) != APR_SUCCESS) {
|
||||||
apr_bucket *e = apr_bucket_flush_create(c->bucket_alloc);
|
apr_bucket *e = apr_bucket_flush_create(c->bucket_alloc);
|
||||||
|
@@ -585,7 +585,7 @@ static const char *log_connection_status(request_rec *r, char *a)
|
|||||||
if (r->connection->aborted)
|
if (r->connection->aborted)
|
||||||
return "X";
|
return "X";
|
||||||
|
|
||||||
if (r->connection->keepalive &&
|
if (r->connection->keepalive == AP_CONN_KEEPALIVE &&
|
||||||
(!r->server->keep_alive_max ||
|
(!r->server->keep_alive_max ||
|
||||||
(r->server->keep_alive_max - r->connection->keepalives) > 0)) {
|
(r->server->keep_alive_max - r->connection->keepalives) > 0)) {
|
||||||
return "+";
|
return "+";
|
||||||
|
@@ -446,7 +446,7 @@ apr_status_t ap_proxy_http_request(apr_pool_t *p, request_rec *r,
|
|||||||
ap_proxy_clear_connection(p, r->headers_in);
|
ap_proxy_clear_connection(p, r->headers_in);
|
||||||
if (p_conn->close) {
|
if (p_conn->close) {
|
||||||
apr_table_setn(r->headers_in, "Connection", "close");
|
apr_table_setn(r->headers_in, "Connection", "close");
|
||||||
origin->keepalive = 0;
|
origin->keepalive = AP_CONN_CLOSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( apr_table_get(r->subprocess_env,"force-proxy-request-1.0")) {
|
if ( apr_table_get(r->subprocess_env,"force-proxy-request-1.0")) {
|
||||||
@@ -456,7 +456,7 @@ apr_status_t ap_proxy_http_request(apr_pool_t *p, request_rec *r,
|
|||||||
}
|
}
|
||||||
if ( apr_table_get(r->subprocess_env,"proxy-nokeepalive")) {
|
if ( apr_table_get(r->subprocess_env,"proxy-nokeepalive")) {
|
||||||
apr_table_unset(r->headers_in, "Connection");
|
apr_table_unset(r->headers_in, "Connection");
|
||||||
origin->keepalive = 0;
|
origin->keepalive = AP_CONN_CLOSE;
|
||||||
}
|
}
|
||||||
ap_xlate_proto_to_ascii(buf, strlen(buf));
|
ap_xlate_proto_to_ascii(buf, strlen(buf));
|
||||||
e = apr_bucket_pool_create(buf, strlen(buf), p, c->bucket_alloc);
|
e = apr_bucket_pool_create(buf, strlen(buf), p, c->bucket_alloc);
|
||||||
@@ -798,7 +798,7 @@ apr_status_t ap_proxy_http_process_response(apr_pool_t * p, request_rec *r,
|
|||||||
/* cancel keepalive if HTTP/1.0 or less */
|
/* cancel keepalive if HTTP/1.0 or less */
|
||||||
if ((major < 1) || (minor < 1)) {
|
if ((major < 1) || (minor < 1)) {
|
||||||
p_conn->close += 1;
|
p_conn->close += 1;
|
||||||
origin->keepalive = 0;
|
origin->keepalive = AP_CONN_CLOSE;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* an http/0.9 response */
|
/* an http/0.9 response */
|
||||||
|
@@ -3293,7 +3293,7 @@ static int net_time_filter(ap_filter_t *f, apr_bucket_brigade *b,
|
|||||||
ap_input_mode_t mode, apr_read_type_e block,
|
ap_input_mode_t mode, apr_read_type_e block,
|
||||||
apr_off_t readbytes)
|
apr_off_t readbytes)
|
||||||
{
|
{
|
||||||
int keptalive = f->c->keepalive == 1;
|
int keptalive = f->c->keepalive == AP_CONN_KEEPALIVE;
|
||||||
apr_socket_t *csd = ap_get_module_config(f->c->conn_config, &core_module);
|
apr_socket_t *csd = ap_get_module_config(f->c->conn_config, &core_module);
|
||||||
int *first_line = f->ctx;
|
int *first_line = f->ctx;
|
||||||
|
|
||||||
@@ -3755,7 +3755,8 @@ static apr_status_t core_output_filter(ap_filter_t *f, apr_bucket_brigade *b)
|
|||||||
&& (nbytes + flen < AP_MIN_BYTES_TO_WRITE)
|
&& (nbytes + flen < AP_MIN_BYTES_TO_WRITE)
|
||||||
&& !APR_BUCKET_IS_FLUSH(last_e))
|
&& !APR_BUCKET_IS_FLUSH(last_e))
|
||||||
|| (nbytes + flen < AP_MIN_BYTES_TO_WRITE
|
|| (nbytes + flen < AP_MIN_BYTES_TO_WRITE
|
||||||
&& APR_BUCKET_IS_EOS(last_e) && c->keepalive)) {
|
&& APR_BUCKET_IS_EOS(last_e)
|
||||||
|
&& c->keepalive == AP_CONN_KEEPALIVE)) {
|
||||||
|
|
||||||
/* NEVER save an EOS in here. If we are saving a brigade with
|
/* NEVER save an EOS in here. If we are saving a brigade with
|
||||||
* an EOS bucket, then we are doing keepalive connections, and
|
* an EOS bucket, then we are doing keepalive connections, and
|
||||||
@@ -3824,7 +3825,7 @@ static apr_status_t core_output_filter(ap_filter_t *f, apr_bucket_brigade *b)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if APR_HAS_SENDFILE
|
#if APR_HAS_SENDFILE
|
||||||
if (!c->keepalive && APR_BUCKET_IS_EOS(last_e)) {
|
if (c->keepalive == AP_CONN_CLOSE && APR_BUCKET_IS_EOS(last_e)) {
|
||||||
/* Prepare the socket to be reused */
|
/* Prepare the socket to be reused */
|
||||||
flags |= APR_SENDFILE_DISCONNECT_SOCKET;
|
flags |= APR_SENDFILE_DISCONNECT_SOCKET;
|
||||||
}
|
}
|
||||||
|
@@ -1187,7 +1187,8 @@ AP_CORE_DECLARE_NONSTD(apr_status_t) ap_content_length_filter(ap_filter_t *f,
|
|||||||
* We should be able to force connection close from this filter
|
* We should be able to force connection close from this filter
|
||||||
* when we see we are buffering too much.
|
* when we see we are buffering too much.
|
||||||
*/
|
*/
|
||||||
if ((r->proto_num >= HTTP_VERSION(1, 1)) || (!r->connection->keepalive)) {
|
if ((r->proto_num >= HTTP_VERSION(1, 1)) ||
|
||||||
|
(r->connection->keepalive == AP_CONN_CLOSE)) {
|
||||||
partial_send_okay = 1;
|
partial_send_okay = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user