/* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License.
*/
#include"apr_strings.h" #include"apr_thread_proc.h"/* for RLIMIT stuff */
#define APR_WANT_STRFUNC #include"apr_want.h"
#include"httpd.h" #include"http_config.h" #include"http_connection.h" #include"http_core.h" #include"http_protocol.h"/* For index_of_response(). Grump. */ #include"http_request.h"
/* Stolen from mod_proxy.c */ if (ap_timeout_parameter_parse(arg, &timeout, "s") != APR_SUCCESS) return"KeepAliveTimeout has wrong format";
cmd->server->keep_alive_timeout = timeout;
/* We don't want to take into account whether or not KeepAliveTimeout is * set for the main server, because if no http_module directive is used * for a vhost, it will inherit the http_srv_cfg from the main server. * However keep_alive_timeout_set helps determine whether the vhost should * use its own configured timeout or the one from the vhost declared first * on the same IP:port (ie. c->base_server, and the legacy behaviour).
*/ if (cmd->server->is_virtual) {
cmd->server->keep_alive_timeout_set = 1;
} return NULL;
}
staticconst command_rec http_cmds[] = {
AP_INIT_TAKE1("KeepAliveTimeout", set_keep_alive_timeout, NULL, RSRC_CONF, "Keep-Alive timeout duration (sec)"),
AP_INIT_TAKE1("MaxKeepAliveRequests", set_keep_alive_max, NULL, RSRC_CONF, "Maximum number of Keep-Alive requests per connection, " "or 0 for infinite"),
AP_INIT_FLAG("KeepAlive", set_keep_alive, NULL, RSRC_CONF, "Whether persistent connections should be On or Off"),
{ NULL }
};
staticconstchar *http_scheme(const request_rec *r)
{ /* * The http module shouldn't return anything other than * "http" (the default) or "https".
*/ if (r->server->server_scheme &&
(strcmp(r->server->server_scheme, "https") == 0)) return"https";
if (cs->state == CONN_STATE_PROCESSING) {
ap_update_child_status_from_conn(c->sbh, SERVER_BUSY_READ, c); if (ap_extended_status) {
ap_set_conn_count(c->sbh, r, c->keepalives);
} if ((r = ap_read_request(c))) { if (r->status == HTTP_OK) {
cs->state = CONN_STATE_HANDLER; if (ap_extended_status) {
ap_set_conn_count(c->sbh, r, c->keepalives + 1);
}
ap_update_child_status(c->sbh, SERVER_BUSY_WRITE, r);
ap_process_async_request(r); /* After the call to ap_process_request, the * request pool may have been deleted. We set * r=NULL here to ensure that any dereference * of r that might be added later in this function * will result in a segfault immediately instead * of nondeterministic failures later.
*/
r = NULL;
}
if (cs->state != CONN_STATE_WRITE_COMPLETION &&
cs->state != CONN_STATE_SUSPENDED) { /* Something went wrong; close the connection */
cs->state = CONN_STATE_LINGER;
}
} else { /* ap_read_request failed - client may have closed */
cs->state = CONN_STATE_LINGER;
}
}
/* To preserve legacy behaviour, use the keepalive timeout from the * base server (first on this IP:port) when none is explicitly * configured on this server.
*/ if (!r->server->keep_alive_timeout_set) {
keep_alive_timeout = c->base_server->keep_alive_timeout;
}
if (r->status == HTTP_OK) { if (cs)
cs->state = CONN_STATE_HANDLER;
ap_update_child_status(c->sbh, SERVER_BUSY_WRITE, r);
ap_process_request(r); /* After the call to ap_process_request, the * request pool will have been deleted. We set * r=NULL here to ensure that any dereference * of r that might be added later in this function * will result in a segfault immediately instead * of nondeterministic failures later.
*/
r = NULL;
}
if (c->keepalive != AP_CONN_KEEPALIVE || c->aborted) break;
if (ap_mpm_query(AP_MPMQ_MPM_STATE, &mpm_state)) { break;
}
if (mpm_state == AP_MPMQ_STOPPING) { break;
}
if (!csd) {
csd = ap_get_conn_socket(c);
}
apr_socket_opt_set(csd, APR_INCOMPLETE_READ, 1);
apr_socket_timeout_set(csd, keep_alive_timeout); /* Go straight to select() to wait for the next request */
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.