1
0
mirror of https://github.com/apache/httpd.git synced 2025-08-07 04:02:58 +03:00

Introduce new function ap_get_conn_socket() to access the socket of

a connection


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1135153 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Stefan Fritsch
2011-06-13 16:02:18 +00:00
parent 04d48349bb
commit fba947527f
13 changed files with 28 additions and 11 deletions

View File

@@ -2,6 +2,9 @@
Changes with Apache 2.3.13 Changes with Apache 2.3.13
*) core: Introduce new function ap_get_conn_socket() to access the socket of
a connection. [Stefan Fritsch]
*) mod_data: Introduce a filter to support RFC2397 data URLs. [Graham *) mod_data: Introduce a filter to support RFC2397 data URLs. [Graham
Leggett] Leggett]

View File

@@ -118,6 +118,9 @@
initial configuration preflight phase or not. This is both easier to initial configuration preflight phase or not. This is both easier to
use and more correct than the old method of creating a pool userdata use and more correct than the old method of creating a pool userdata
entry in the process pool.</li> entry in the process pool.</li>
<li>New function ap_get_conn_socket to get the socket descriptor for a
connection. This should be used instead of accessing the core
connection config directly.</li>
</ul> </ul>
</section> </section>

View File

@@ -332,6 +332,7 @@
* context_document_root, context_prefix. * context_document_root, context_prefix.
* Add ap_context_*(), ap_set_context_info(), ap_set_document_root() * Add ap_context_*(), ap_set_context_info(), ap_set_document_root()
* 20110605.1 (2.3.13-dev) add ap_(get|set)_core_module_config() * 20110605.1 (2.3.13-dev) add ap_(get|set)_core_module_config()
* 20110605.2 (2.3.13-dev) add ap_get_conn_socket()
*/ */
#define MODULE_MAGIC_COOKIE 0x41503234UL /* "AP24" */ #define MODULE_MAGIC_COOKIE 0x41503234UL /* "AP24" */
@@ -339,7 +340,7 @@
#ifndef MODULE_MAGIC_NUMBER_MAJOR #ifndef MODULE_MAGIC_NUMBER_MAJOR
#define MODULE_MAGIC_NUMBER_MAJOR 20110605 #define MODULE_MAGIC_NUMBER_MAJOR 20110605
#endif #endif
#define MODULE_MAGIC_NUMBER_MINOR 1 /* 0...n */ #define MODULE_MAGIC_NUMBER_MINOR 2 /* 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

View File

@@ -336,6 +336,13 @@ AP_DECLARE(void *) ap_get_core_module_config(const ap_conf_vector_t *cv);
*/ */
AP_DECLARE(void) ap_set_core_module_config(ap_conf_vector_t *cv, void *val); AP_DECLARE(void) ap_set_core_module_config(ap_conf_vector_t *cv, void *val);
/** Get the socket from the core network filter. This should be used instead of
* accessing the core connection config directly.
* @param c The connection record
* @return The socket
*/
AP_DECLARE(apr_socket_t *) ap_get_conn_socket(conn_rec *c);
#ifndef AP_DEBUG #ifndef AP_DEBUG
#define AP_CORE_MODULE_INDEX 0 #define AP_CORE_MODULE_INDEX 0
#define ap_get_core_module_config(v) \ #define ap_get_core_module_config(v) \

View File

@@ -168,7 +168,7 @@ static int process_echo_connection(conn_rec *c)
} }
if (!csd) { if (!csd) {
csd = ap_get_core_module_config(c->conn_config); csd = ap_get_conn_socket(c);
apr_socket_timeout_set(csd, c->base_server->keep_alive_timeout); apr_socket_timeout_set(csd, c->base_server->keep_alive_timeout);
} }

View File

@@ -68,7 +68,7 @@ static int noloris_conn(conn_rec *conn)
shm_rec = apr_shm_baseaddr_get(shm); shm_rec = apr_shm_baseaddr_get(shm);
while (shm_rec[0] != '\0') { while (shm_rec[0] != '\0') {
if (!strcmp(shm_rec, conn->remote_ip)) { if (!strcmp(shm_rec, conn->remote_ip)) {
apr_socket_t *csd = ap_get_core_module_config(conn->conn_config); apr_socket_t *csd = ap_get_conn_socket(conn);
ap_log_cerror(APLOG_MARK, APLOG_ERR, 0, conn, ap_log_cerror(APLOG_MARK, APLOG_ERR, 0, conn,
"Dropping connection from banned IP %s", "Dropping connection from banned IP %s",
conn->remote_ip); conn->remote_ip);

View File

@@ -186,7 +186,7 @@ static apr_status_t reqtimeout_filter(ap_filter_t *f,
} }
if (!ccfg->socket) { if (!ccfg->socket) {
ccfg->socket = ap_get_core_module_config(f->c->conn_config); ccfg->socket = ap_get_conn_socket(f->c);
} }
rv = check_time_left(ccfg, &time_left); rv = check_time_left(ccfg, &time_left);

View File

@@ -208,7 +208,7 @@ static int ap_process_http_sync_connection(conn_rec *c)
} }
if (!csd) { if (!csd) {
csd = ap_get_core_module_config(c->conn_config); csd = ap_get_conn_socket(c);
} }
apr_socket_opt_set(csd, APR_INCOMPLETE_READ, 1); apr_socket_opt_set(csd, APR_INCOMPLETE_READ, 1);
apr_socket_timeout_set(csd, c->base_server->keep_alive_timeout); apr_socket_timeout_set(csd, c->base_server->keep_alive_timeout);

View File

@@ -209,7 +209,7 @@ static int proxy_connect_handler(request_rec *r, proxy_worker *worker,
apr_status_t err, rv; apr_status_t err, rv;
apr_size_t nbytes; apr_size_t nbytes;
char buffer[HUGE_STRING_LEN]; char buffer[HUGE_STRING_LEN];
apr_socket_t *client_socket = ap_get_core_module_config(c->conn_config); apr_socket_t *client_socket = ap_get_conn_socket(c);
int failed, rc; int failed, rc;
int client_error = 0; int client_error = 0;
apr_pollset_t *pollset; apr_pollset_t *pollset;

View File

@@ -221,9 +221,7 @@ static int proxy_fdpass_handler(request_rec *r, proxy_worker *worker,
} }
} }
/* XXXXX: THIS IS AN EVIL HACK */ clientsock = ap_get_conn_socket(r->connection);
/* There should really be a (documented) public API for this ! */
clientsock = ap_get_core_module_config(r->connection->conn_config);
rv = send_socket(r->pool, sock, clientsock); rv = send_socket(r->pool, sock, clientsock);
if (rv != APR_SUCCESS) { if (rv != APR_SUCCESS) {

View File

@@ -98,7 +98,7 @@ AP_DECLARE(void) ap_lingering_close(conn_rec *c)
char dummybuf[512]; char dummybuf[512];
apr_size_t nbytes; apr_size_t nbytes;
apr_time_t timeup = 0; apr_time_t timeup = 0;
apr_socket_t *csd = ap_get_core_module_config(c->conn_config); apr_socket_t *csd = ap_get_conn_socket(c);
if (!csd) { if (!csd) {
return; return;

View File

@@ -4302,6 +4302,11 @@ AP_DECLARE(void **) ap_get_request_note(request_rec *r, apr_size_t note_num)
return &(req_cfg->notes[note_num]); return &(req_cfg->notes[note_num]);
} }
AP_DECLARE(apr_socket_t *) ap_get_conn_socket(conn_rec *c)
{
return ap_get_core_module_config(c->conn_config);
}
static int core_create_req(request_rec *r) static int core_create_req(request_rec *r)
{ {
/* Alloc the config struct and the array of request notes in /* Alloc the config struct and the array of request notes in

View File

@@ -953,7 +953,7 @@ request_rec *ap_read_request(conn_rec *conn)
* to the normal timeout mode as we fetch the header lines, * to the normal timeout mode as we fetch the header lines,
* as necessary. * as necessary.
*/ */
csd = ap_get_core_module_config(conn->conn_config); csd = ap_get_conn_socket(conn);
apr_socket_timeout_get(csd, &cur_timeout); apr_socket_timeout_get(csd, &cur_timeout);
if (cur_timeout != conn->base_server->timeout) { if (cur_timeout != conn->base_server->timeout) {
apr_socket_timeout_set(csd, conn->base_server->timeout); apr_socket_timeout_set(csd, conn->base_server->timeout);