install_core_filters (please feel free to find another name) is a RUN_FIRST hook that
runs
after ap_update_vhost_given_ip(c) and right before ap_run_pre_connection. It's primary
purpose in life is to create the net_core_rec structure and install the CORE_IN|
CORE_OUT
filters (or alternate primary network i/o filters with hints from the vhost config if
needed). The client socket is removed from the conn_rec and placed in the net_core_rec
where only the primary network i/o filters can access it.
This is much the same as Ryan's 11/12 patch I -1'ed yesterday, only the hook name is
changed, its placement in the request cycle is changed and the arguments are a bit
different.
Bill
Index: include/http_connection.h
===================================================================
RCS file: /home/cvs/httpd-2.0/include/http_connection.h,v
retrieving revision 1.49
diff -u -r1.49 http_connection.h
--- include/http_connection.h 27 Jan 2002 12:52:07 -0000 1.49
+++ include/http_connection.h 28 Jan 2002 04:23:09 -0000
@@ -78,13 +78,14 @@
*/
AP_CORE_DECLARE(conn_rec *)ap_new_connection(apr_pool_t *ptrans, server_rec *server,
apr_socket_t *csd, long id, void *sbh);
+
/**
* This is the protocol module driver. This calls all of the
* pre-connection and connection hooks for all protocol modules.
* @param c The connection on which the request is read
* @deffunc void ap_process_connection(conn_rec *)
*/
-AP_CORE_DECLARE(void) ap_process_connection(conn_rec *);
+AP_CORE_DECLARE(void) ap_process_connection(conn_rec *, apr_socket_t *csd);
AP_CORE_DECLARE(void) ap_flush_conn(conn_rec *c);
@@ -107,6 +108,11 @@
#endif
/* Hooks */
+/**
+ * TODO: Doc...
+ */
+AP_DECLARE_HOOK(int, install_core_filters, (conn_rec *c, apr_socket_t *csd))
+
/**
* This hook gives protocol modules an opportunity to set everything up
* before calling the protocol handler. All pre-connection hooks are
Index: include/httpd.h
===================================================================
RCS file: /home/cvs/httpd-2.0/include/httpd.h,v
retrieving revision 1.175
diff -u -r1.175 httpd.h
--- include/httpd.h 27 Jan 2002 12:52:07 -0000 1.175
+++ include/httpd.h 28 Jan 2002 04:23:10 -0000
@@ -936,10 +936,6 @@
void *vhost_lookup_data;
/* Information about the connection itself */
-
- /** Connection to the client */
- apr_socket_t *client_socket;
-
/** local address */
apr_sockaddr_t *local_addr;
/** remote address */
@@ -1093,6 +1089,17 @@
typedef struct core_filter_ctx {
apr_bucket_brigade *b;
} core_ctx_t;
+
+typedef struct core_net_rec {
+ /** Connection to the client */
+ apr_socket_t *client_socket;
+
+ /** connection record */
+ conn_rec *c;
+
+ core_output_filter_ctx_t *out_ctx;
+ core_ctx_t *in_ctx;
+} core_net_rec;
/**
* Examine a field value (such as a media-/content-type) string and return
Index: modules/http/http_core.c
===================================================================
RCS file: /home/cvs/httpd-2.0/modules/http/http_core.c,v
retrieving revision 1.292
diff -u -r1.292 http_core.c
--- modules/http/http_core.c 27 Jan 2002 19:12:56 -0000 1.292
+++ modules/http/http_core.c 28 Jan 2002 04:23:13 -0000
@@ -266,12 +266,7 @@
static apr_port_t http_port(const request_rec *r)
{ return DEFAULT_HTTP_PORT; }
-static int ap_pre_http_connection(conn_rec *c)
-{
- ap_add_input_filter_handle(ap_core_input_filter_handle, NULL, NULL, c);
- ap_add_output_filter_handle(ap_core_output_filter_handle, NULL, NULL, c);
- return OK;
-}
+
static int ap_process_http_connection(conn_rec *c)
{
request_rec *r;
@@ -321,8 +316,6 @@
static void register_hooks(apr_pool_t *p)
{
- ap_hook_pre_connection(ap_pre_http_connection,NULL,NULL,
- APR_HOOK_REALLY_LAST);
ap_hook_process_connection(ap_process_http_connection,NULL,NULL,
APR_HOOK_REALLY_LAST);
ap_hook_map_to_storage(ap_send_http_trace,NULL,NULL,APR_HOOK_MIDDLE);
Index: server/connection.c
===================================================================
RCS file: /home/cvs/httpd-2.0/server/connection.c,v
retrieving revision 1.97
diff -u -r1.97 connection.c
--- server/connection.c 27 Jan 2002 12:52:07 -0000 1.97
+++ server/connection.c 28 Jan 2002 04:23:13 -0000
@@ -77,10 +77,13 @@
APR_HOOK_STRUCT(
APR_HOOK_LINK(pre_connection)
APR_HOOK_LINK(process_connection)
+ APR_HOOK_LINK(install_core_filters)
)
AP_IMPLEMENT_HOOK_RUN_ALL(int,pre_connection,(conn_rec *c),(c),OK,DECLINED)
AP_IMPLEMENT_HOOK_RUN_FIRST(int,process_connection,(conn_rec *c),(c),DECLINED)
+AP_IMPLEMENT_HOOK_RUN_FIRST(int, install_core_filters,
+ (conn_rec *c, apr_socket_t *csd),(c, csd), DECLINED)
/*
* More machine-dependent networking gooo... on some systems,
@@ -157,7 +160,7 @@
apr_status_t rc;
apr_int32_t timeout;
apr_int32_t total_linger_time = 0;
- apr_socket_t *csd = c->client_socket;
+ apr_socket_t *csd = ap_get_module_config(c->conn_config, &core_module);
if (!csd) {
return;
@@ -216,10 +219,12 @@
return;
}
-AP_CORE_DECLARE(void) ap_process_connection(conn_rec *c)
+AP_CORE_DECLARE(void) ap_process_connection(conn_rec *c, apr_socket_t *csd)
{
ap_update_vhost_given_ip(c);
+ ap_run_install_core_filters(c, csd);
+
ap_run_pre_connection(c);
if (!c->aborted) {
@@ -235,15 +240,6 @@
c->sbh = sbh;
(void) ap_update_child_status(c->sbh, SERVER_BUSY_READ, (request_rec *) NULL);
-#ifdef AP_MPM_DISABLE_NAGLE_ACCEPTED_SOCK
- /* BillS says perhaps this should be moved to the MPMs. Some OSes
- * allow listening socket attributes to be inherited by the
- * accept sockets which means this call only needs to be made
- * once on the listener
- */
- ap_sock_disable_nagle(csd);
-#endif
-
/* Got a connection structure, so initialize what fields we can
* (the rest are zeroed out by pcalloc).
*/
@@ -268,9 +264,7 @@
}
apr_sockaddr_ip_get(&c->remote_ip, c->remote_addr);
c->base_server = server;
- c->client_socket = csd;
c->id = id;
-
return c;
}
Index: server/core.c
===================================================================
RCS file: /home/cvs/httpd-2.0/server/core.c,v
retrieving revision 1.138
diff -u -r1.138 core.c
--- server/core.c 27 Jan 2002 12:52:07 -0000 1.138
+++ server/core.c 28 Jan 2002 04:23:15 -0000
@@ -2405,7 +2405,7 @@
*/
#if APR_HAS_SENDFILE
-static apr_status_t sendfile_it_all(conn_rec *c,
+static apr_status_t sendfile_it_all(core_net_rec *c,
apr_file_t *fd,
apr_hdtr_t *hdtr,
apr_off_t file_offset,
@@ -2490,7 +2490,7 @@
* to the network. emulate_sendfile will return only when all the bytes have been
* sent (i.e., it handles partial writes) or on a network error condition.
*/
-static apr_status_t emulate_sendfile(conn_rec *c, apr_file_t *fd,
+static apr_status_t emulate_sendfile(core_net_rec *c, apr_file_t *fd,
apr_hdtr_t *hdtr, apr_off_t offset,
apr_size_t length, apr_size_t *nbytes)
{
@@ -2994,7 +2994,7 @@
apr_off_t readbytes)
{
int keptalive = f->c->keepalive == 1;
- apr_socket_t *csd = f->c->client_socket;
+ apr_socket_t *csd = ap_get_module_config(f->c->conn_config, &core_module);
int *first_line = f->ctx;
if (!f->ctx) {
@@ -3026,7 +3026,8 @@
{
apr_bucket *e;
apr_status_t rv;
- core_ctx_t *ctx = f->ctx;
+ core_net_rec *net = f->ctx;
+ core_ctx_t *ctx = net->in_ctx;
const char *str;
apr_size_t len;
@@ -3046,12 +3047,13 @@
if (!ctx)
{
- f->ctx = ctx = apr_pcalloc(f->c->pool, sizeof(*ctx));
+ ctx = apr_pcalloc(f->c->pool, sizeof(*ctx));
ctx->b = apr_brigade_create(f->c->pool);
/* seed the brigade with the client socket. */
- e = apr_bucket_socket_create(f->c->client_socket);
+ e = apr_bucket_socket_create(net->client_socket);
APR_BRIGADE_INSERT_TAIL(ctx->b, e);
+ net->in_ctx = ctx;
}
else if (APR_BRIGADE_EMPTY(ctx->b)) {
/* hit EOF on socket already */
@@ -3200,10 +3202,12 @@
{
apr_status_t rv;
conn_rec *c = f->c;
- core_output_filter_ctx_t *ctx = f->ctx;
+ core_net_rec *net = f->ctx;
+ core_output_filter_ctx_t *ctx = net->out_ctx;
if (ctx == NULL) {
- f->ctx = ctx = apr_pcalloc(c->pool, sizeof(*ctx));
+ ctx = apr_pcalloc(net->c->pool, sizeof(*ctx));
+ net->out_ctx = ctx;
}
/* If we have a saved brigade, concatenate the new brigade to it */
@@ -3405,7 +3409,7 @@
* after the request_pool is cleared.
*/
if (ctx->b == NULL) {
- ctx->b = apr_brigade_create(c->pool);
+ ctx->b = apr_brigade_create(net->c->pool);
}
APR_BRIGADE_FOREACH(bucket, b) {
@@ -3459,7 +3463,7 @@
/* Prepare the socket to be reused */
flags |= APR_SENDFILE_DISCONNECT_SOCKET;
}
- rv = sendfile_it_all(c, /* the network information */
+ rv = sendfile_it_all(net, /* the network information */
fd, /* the file to send */
&hdtr, /* header and trailer iovecs */
foffset, /* offset in the file to begin
@@ -3478,7 +3482,7 @@
#endif
{
apr_size_t unused_bytes_sent;
- rv = emulate_sendfile(c, fd, &hdtr, foffset, flen,
+ rv = emulate_sendfile(net, fd, &hdtr, foffset, flen,
&unused_bytes_sent);
}
fd = NULL;
@@ -3486,7 +3490,7 @@
else {
apr_size_t unused_bytes_sent;
- rv = writev_it_all(c->client_socket,
+ rv = writev_it_all(net->client_socket,
vec, nvec,
nbytes, &unused_bytes_sent);
}
@@ -3608,8 +3612,32 @@
return core_create_req(pr);
}
+static int core_install_core_filters(conn_rec *c, apr_socket_t *csd)
+{
+ core_net_rec *net = apr_palloc(c->pool, sizeof(*net));
+
+#ifdef AP_MPM_DISABLE_NAGLE_ACCEPTED_SOCK
+ /* BillS says perhaps this should be moved to the MPMs. Some OSes
+ * allow listening socket attributes to be inherited by the
+ * accept sockets which means this call only needs to be made
+ * once on the listener
+ */
+ ap_sock_disable_nagle(csd);
+#endif
+ net->c = c;
+ net->in_ctx = NULL;
+ net->out_ctx = NULL;
+ net->client_socket = csd;
+
+ ap_set_module_config(net->c->conn_config, &core_module, csd);
+ ap_add_input_filter("CORE_IN", net, NULL, net->c);
+ ap_add_output_filter("CORE", net, NULL, net->c);
+ return OK;
+}
+
static void register_hooks(apr_pool_t *p)
{
+ ap_hook_install_core_filters(core_install_core_filters, NULL, NULL,
APR_HOOK_REALLY_LAST);
ap_hook_post_config(core_post_config,NULL,NULL,APR_HOOK_REALLY_FIRST);
ap_hook_translate_name(ap_core_translate,NULL,NULL,APR_HOOK_REALLY_LAST);
ap_hook_map_to_storage(core_map_to_storage,NULL,NULL,APR_HOOK_REALLY_LAST);
Index: server/mpm/beos/beos.c
===================================================================
RCS file: /home/cvs/httpd-2.0/server/mpm/beos/beos.c,v
retrieving revision 1.79
diff -u -r1.79 beos.c
--- server/mpm/beos/beos.c 28 Jan 2002 00:41:31 -0000 1.79
+++ server/mpm/beos/beos.c 28 Jan 2002 04:23:16 -0000
@@ -349,7 +349,7 @@
current_conn = ap_new_connection(p, ap_server_conf, sock, conn_id, sbh);
if (current_conn) {
- ap_process_connection(current_conn);
+ ap_process_connection(current_conn, sock);
ap_lingering_close(current_conn);
}
}
Index: server/mpm/mpmt_os2/mpmt_os2_child.c
===================================================================
RCS file: /home/cvs/httpd-2.0/server/mpm/mpmt_os2/mpmt_os2_child.c,v
retrieving revision 1.13
diff -u -r1.13 mpmt_os2_child.c
--- server/mpm/mpmt_os2/mpmt_os2_child.c 27 Jan 2002 12:52:07 -0000 1.13
+++ server/mpm/mpmt_os2/mpmt_os2_child.c 28 Jan 2002 04:23:16 -0000
@@ -434,7 +434,7 @@
if (current_conn) {
ap_process_connection(current_conn);
- ap_lingering_close(current_conn);
+ ap_lingering_close(current_conn, worker_args->conn_sd);
}
apr_pool_destroy(pconn);
Index: server/mpm/netware/mpm_netware.c
===================================================================
RCS file: /home/cvs/httpd-2.0/server/mpm/netware/mpm_netware.c,v
retrieving revision 1.26
diff -u -r1.26 mpm_netware.c
--- server/mpm/netware/mpm_netware.c 28 Jan 2002 00:41:31 -0000 1.26
+++ server/mpm/netware/mpm_netware.c 28 Jan 2002 04:23:17 -0000
@@ -526,7 +526,7 @@
current_conn = ap_new_connection(ptrans, ap_server_conf, csd,
my_worker_num, sbh);
if (current_conn) {
- ap_process_connection(current_conn);
+ ap_process_connection(current_conn, csd);
ap_lingering_close(current_conn);
}
request_count++;
Index: server/mpm/perchild/perchild.c
===================================================================
RCS file: /home/cvs/httpd-2.0/server/mpm/perchild/perchild.c,v
retrieving revision 1.102
diff -u -r1.102 perchild.c
--- server/mpm/perchild/perchild.c 28 Jan 2002 00:41:31 -0000 1.102
+++ server/mpm/perchild/perchild.c 28 Jan 2002 04:23:19 -0000
@@ -569,7 +569,7 @@
ap_create_sb_handle(&sbh, p, conn_id / thread_limit, thread_num);
current_conn = ap_new_connection(p, ap_server_conf, sock, conn_id, sbh);
if (current_conn) {
- ap_process_connection(current_conn);
+ ap_process_connection(current_conn, sock);
ap_lingering_close(current_conn);
}
}
Index: server/mpm/winnt/mpm_winnt.c
===================================================================
RCS file: /home/cvs/httpd-2.0/server/mpm/winnt/mpm_winnt.c,v
retrieving revision 1.211
diff -u -r1.211 mpm_winnt.c
--- server/mpm/winnt/mpm_winnt.c 28 Jan 2002 00:41:32 -0000 1.211
+++ server/mpm/winnt/mpm_winnt.c 28 Jan 2002 04:23:20 -0000
@@ -927,7 +927,7 @@
thread_num, sbh);
if (c) {
- ap_process_connection(c);
+ ap_process_connection(c, context->sock);
apr_getsocketopt(context->sock, APR_SO_DISCONNECTED, &disconnected);
if (!disconnected) {
context->accept_socket = INVALID_SOCKET;
Index: server/mpm/worker/worker.c
===================================================================
RCS file: /home/cvs/httpd-2.0/server/mpm/worker/worker.c,v
retrieving revision 1.63
diff -u -r1.63 worker.c
--- server/mpm/worker/worker.c 28 Jan 2002 00:49:04 -0000 1.63
+++ server/mpm/worker/worker.c 28 Jan 2002 04:23:22 -0000
@@ -559,7 +559,7 @@
current_conn = ap_new_connection(p, ap_server_conf, sock, conn_id, sbh);
if (current_conn) {
- ap_process_connection(current_conn);
+ ap_process_connection(current_conn, sock);
ap_lingering_close(current_conn);
}
}
Index: include/http_connection.h
===================================================================
RCS file: /home/cvs/httpd-2.0/include/http_connection.h,v
retrieving revision 1.49
diff -u -r1.49 http_connection.h
--- include/http_connection.h 27 Jan 2002 12:52:07 -0000 1.49
+++ include/http_connection.h 28 Jan 2002 04:23:09 -0000
@@ -78,13 +78,14 @@
*/
AP_CORE_DECLARE(conn_rec *)ap_new_connection(apr_pool_t *ptrans, server_rec *server,
apr_socket_t *csd, long id, void *sbh);
+
/**
* This is the protocol module driver. This calls all of the
* pre-connection and connection hooks for all protocol modules.
* @param c The connection on which the request is read
* @deffunc void ap_process_connection(conn_rec *)
*/
-AP_CORE_DECLARE(void) ap_process_connection(conn_rec *);
+AP_CORE_DECLARE(void) ap_process_connection(conn_rec *, apr_socket_t *csd);
AP_CORE_DECLARE(void) ap_flush_conn(conn_rec *c);
@@ -107,6 +108,11 @@
#endif
/* Hooks */
+/**
+ * TODO: Doc...
+ */
+AP_DECLARE_HOOK(int, install_core_filters, (conn_rec *c, apr_socket_t *csd))
+
/**
* This hook gives protocol modules an opportunity to set everything up
* before calling the protocol handler. All pre-connection hooks are
Index: include/httpd.h
===================================================================
RCS file: /home/cvs/httpd-2.0/include/httpd.h,v
retrieving revision 1.175
diff -u -r1.175 httpd.h
--- include/httpd.h 27 Jan 2002 12:52:07 -0000 1.175
+++ include/httpd.h 28 Jan 2002 04:23:10 -0000
@@ -936,10 +936,6 @@
void *vhost_lookup_data;
/* Information about the connection itself */
-
- /** Connection to the client */
- apr_socket_t *client_socket;
-
/** local address */
apr_sockaddr_t *local_addr;
/** remote address */
@@ -1093,6 +1089,17 @@
typedef struct core_filter_ctx {
apr_bucket_brigade *b;
} core_ctx_t;
+
+typedef struct core_net_rec {
+ /** Connection to the client */
+ apr_socket_t *client_socket;
+
+ /** connection record */
+ conn_rec *c;
+
+ core_output_filter_ctx_t *out_ctx;
+ core_ctx_t *in_ctx;
+} core_net_rec;
/**
* Examine a field value (such as a media-/content-type) string and return
Index: modules/http/http_core.c
===================================================================
RCS file: /home/cvs/httpd-2.0/modules/http/http_core.c,v
retrieving revision 1.292
diff -u -r1.292 http_core.c
--- modules/http/http_core.c 27 Jan 2002 19:12:56 -0000 1.292
+++ modules/http/http_core.c 28 Jan 2002 04:23:13 -0000
@@ -266,12 +266,7 @@
static apr_port_t http_port(const request_rec *r)
{ return DEFAULT_HTTP_PORT; }
-static int ap_pre_http_connection(conn_rec *c)
-{
- ap_add_input_filter_handle(ap_core_input_filter_handle, NULL, NULL, c);
- ap_add_output_filter_handle(ap_core_output_filter_handle, NULL, NULL, c);
- return OK;
-}
+
static int ap_process_http_connection(conn_rec *c)
{
request_rec *r;
@@ -321,8 +316,6 @@
static void register_hooks(apr_pool_t *p)
{
- ap_hook_pre_connection(ap_pre_http_connection,NULL,NULL,
- APR_HOOK_REALLY_LAST);
ap_hook_process_connection(ap_process_http_connection,NULL,NULL,
APR_HOOK_REALLY_LAST);
ap_hook_map_to_storage(ap_send_http_trace,NULL,NULL,APR_HOOK_MIDDLE);
Index: server/connection.c
===================================================================
RCS file: /home/cvs/httpd-2.0/server/connection.c,v
retrieving revision 1.97
diff -u -r1.97 connection.c
--- server/connection.c 27 Jan 2002 12:52:07 -0000 1.97
+++ server/connection.c 28 Jan 2002 04:23:13 -0000
@@ -77,10 +77,13 @@
APR_HOOK_STRUCT(
APR_HOOK_LINK(pre_connection)
APR_HOOK_LINK(process_connection)
+ APR_HOOK_LINK(install_core_filters)
)
AP_IMPLEMENT_HOOK_RUN_ALL(int,pre_connection,(conn_rec *c),(c),OK,DECLINED)
AP_IMPLEMENT_HOOK_RUN_FIRST(int,process_connection,(conn_rec *c),(c),DECLINED)
+AP_IMPLEMENT_HOOK_RUN_FIRST(int, install_core_filters,
+ (conn_rec *c, apr_socket_t *csd),(c, csd), DECLINED)
/*
* More machine-dependent networking gooo... on some systems,
@@ -157,7 +160,7 @@
apr_status_t rc;
apr_int32_t timeout;
apr_int32_t total_linger_time = 0;
- apr_socket_t *csd = c->client_socket;
+ apr_socket_t *csd = ap_get_module_config(c->conn_config, &core_module);
if (!csd) {
return;
@@ -216,10 +219,12 @@
return;
}
-AP_CORE_DECLARE(void) ap_process_connection(conn_rec *c)
+AP_CORE_DECLARE(void) ap_process_connection(conn_rec *c, apr_socket_t *csd)
{
ap_update_vhost_given_ip(c);
+ ap_run_install_core_filters(c, csd);
+
ap_run_pre_connection(c);
if (!c->aborted) {
@@ -235,15 +240,6 @@
c->sbh = sbh;
(void) ap_update_child_status(c->sbh, SERVER_BUSY_READ, (request_rec *) NULL);
-#ifdef AP_MPM_DISABLE_NAGLE_ACCEPTED_SOCK
- /* BillS says perhaps this should be moved to the MPMs. Some OSes
- * allow listening socket attributes to be inherited by the
- * accept sockets which means this call only needs to be made
- * once on the listener
- */
- ap_sock_disable_nagle(csd);
-#endif
-
/* Got a connection structure, so initialize what fields we can
* (the rest are zeroed out by pcalloc).
*/
@@ -268,9 +264,7 @@
}
apr_sockaddr_ip_get(&c->remote_ip, c->remote_addr);
c->base_server = server;
- c->client_socket = csd;
c->id = id;
-
return c;
}
Index: server/core.c
===================================================================
RCS file: /home/cvs/httpd-2.0/server/core.c,v
retrieving revision 1.138
diff -u -r1.138 core.c
--- server/core.c 27 Jan 2002 12:52:07 -0000 1.138
+++ server/core.c 28 Jan 2002 04:23:15 -0000
@@ -2405,7 +2405,7 @@
*/
#if APR_HAS_SENDFILE
-static apr_status_t sendfile_it_all(conn_rec *c,
+static apr_status_t sendfile_it_all(core_net_rec *c,
apr_file_t *fd,
apr_hdtr_t *hdtr,
apr_off_t file_offset,
@@ -2490,7 +2490,7 @@
* to the network. emulate_sendfile will return only when all the bytes have been
* sent (i.e., it handles partial writes) or on a network error condition.
*/
-static apr_status_t emulate_sendfile(conn_rec *c, apr_file_t *fd,
+static apr_status_t emulate_sendfile(core_net_rec *c, apr_file_t *fd,
apr_hdtr_t *hdtr, apr_off_t offset,
apr_size_t length, apr_size_t *nbytes)
{
@@ -2994,7 +2994,7 @@
apr_off_t readbytes)
{
int keptalive = f->c->keepalive == 1;
- apr_socket_t *csd = f->c->client_socket;
+ apr_socket_t *csd = ap_get_module_config(f->c->conn_config, &core_module);
int *first_line = f->ctx;
if (!f->ctx) {
@@ -3026,7 +3026,8 @@
{
apr_bucket *e;
apr_status_t rv;
- core_ctx_t *ctx = f->ctx;
+ core_net_rec *net = f->ctx;
+ core_ctx_t *ctx = net->in_ctx;
const char *str;
apr_size_t len;
@@ -3046,12 +3047,13 @@
if (!ctx)
{
- f->ctx = ctx = apr_pcalloc(f->c->pool, sizeof(*ctx));
+ ctx = apr_pcalloc(f->c->pool, sizeof(*ctx));
ctx->b = apr_brigade_create(f->c->pool);
/* seed the brigade with the client socket. */
- e = apr_bucket_socket_create(f->c->client_socket);
+ e = apr_bucket_socket_create(net->client_socket);
APR_BRIGADE_INSERT_TAIL(ctx->b, e);
+ net->in_ctx = ctx;
}
else if (APR_BRIGADE_EMPTY(ctx->b)) {
/* hit EOF on socket already */
@@ -3200,10 +3202,12 @@
{
apr_status_t rv;
conn_rec *c = f->c;
- core_output_filter_ctx_t *ctx = f->ctx;
+ core_net_rec *net = f->ctx;
+ core_output_filter_ctx_t *ctx = net->out_ctx;
if (ctx == NULL) {
- f->ctx = ctx = apr_pcalloc(c->pool, sizeof(*ctx));
+ ctx = apr_pcalloc(net->c->pool, sizeof(*ctx));
+ net->out_ctx = ctx;
}
/* If we have a saved brigade, concatenate the new brigade to it */
@@ -3405,7 +3409,7 @@
* after the request_pool is cleared.
*/
if (ctx->b == NULL) {
- ctx->b = apr_brigade_create(c->pool);
+ ctx->b = apr_brigade_create(net->c->pool);
}
APR_BRIGADE_FOREACH(bucket, b) {
@@ -3459,7 +3463,7 @@
/* Prepare the socket to be reused */
flags |= APR_SENDFILE_DISCONNECT_SOCKET;
}
- rv = sendfile_it_all(c, /* the network information */
+ rv = sendfile_it_all(net, /* the network information */
fd, /* the file to send */
&hdtr, /* header and trailer iovecs */
foffset, /* offset in the file to begin
@@ -3478,7 +3482,7 @@
#endif
{
apr_size_t unused_bytes_sent;
- rv = emulate_sendfile(c, fd, &hdtr, foffset, flen,
+ rv = emulate_sendfile(net, fd, &hdtr, foffset, flen,
&unused_bytes_sent);
}
fd = NULL;
@@ -3486,7 +3490,7 @@
else {
apr_size_t unused_bytes_sent;
- rv = writev_it_all(c->client_socket,
+ rv = writev_it_all(net->client_socket,
vec, nvec,
nbytes, &unused_bytes_sent);
}
@@ -3608,8 +3612,32 @@
return core_create_req(pr);
}
+static int core_install_core_filters(conn_rec *c, apr_socket_t *csd)
+{
+ core_net_rec *net = apr_palloc(c->pool, sizeof(*net));
+
+#ifdef AP_MPM_DISABLE_NAGLE_ACCEPTED_SOCK
+ /* BillS says perhaps this should be moved to the MPMs. Some OSes
+ * allow listening socket attributes to be inherited by the
+ * accept sockets which means this call only needs to be made
+ * once on the listener
+ */
+ ap_sock_disable_nagle(csd);
+#endif
+ net->c = c;
+ net->in_ctx = NULL;
+ net->out_ctx = NULL;
+ net->client_socket = csd;
+
+ ap_set_module_config(net->c->conn_config, &core_module, csd);
+ ap_add_input_filter("CORE_IN", net, NULL, net->c);
+ ap_add_output_filter("CORE", net, NULL, net->c);
+ return OK;
+}
+
static void register_hooks(apr_pool_t *p)
{
+ ap_hook_install_core_filters(core_install_core_filters, NULL, NULL,
+APR_HOOK_REALLY_LAST);
ap_hook_post_config(core_post_config,NULL,NULL,APR_HOOK_REALLY_FIRST);
ap_hook_translate_name(ap_core_translate,NULL,NULL,APR_HOOK_REALLY_LAST);
ap_hook_map_to_storage(core_map_to_storage,NULL,NULL,APR_HOOK_REALLY_LAST);
Index: server/mpm/beos/beos.c
===================================================================
RCS file: /home/cvs/httpd-2.0/server/mpm/beos/beos.c,v
retrieving revision 1.79
diff -u -r1.79 beos.c
--- server/mpm/beos/beos.c 28 Jan 2002 00:41:31 -0000 1.79
+++ server/mpm/beos/beos.c 28 Jan 2002 04:23:16 -0000
@@ -349,7 +349,7 @@
current_conn = ap_new_connection(p, ap_server_conf, sock, conn_id, sbh);
if (current_conn) {
- ap_process_connection(current_conn);
+ ap_process_connection(current_conn, sock);
ap_lingering_close(current_conn);
}
}
Index: server/mpm/mpmt_os2/mpmt_os2_child.c
===================================================================
RCS file: /home/cvs/httpd-2.0/server/mpm/mpmt_os2/mpmt_os2_child.c,v
retrieving revision 1.13
diff -u -r1.13 mpmt_os2_child.c
--- server/mpm/mpmt_os2/mpmt_os2_child.c 27 Jan 2002 12:52:07 -0000 1.13
+++ server/mpm/mpmt_os2/mpmt_os2_child.c 28 Jan 2002 04:23:16 -0000
@@ -434,7 +434,7 @@
if (current_conn) {
ap_process_connection(current_conn);
- ap_lingering_close(current_conn);
+ ap_lingering_close(current_conn, worker_args->conn_sd);
}
apr_pool_destroy(pconn);
Index: server/mpm/netware/mpm_netware.c
===================================================================
RCS file: /home/cvs/httpd-2.0/server/mpm/netware/mpm_netware.c,v
retrieving revision 1.26
diff -u -r1.26 mpm_netware.c
--- server/mpm/netware/mpm_netware.c 28 Jan 2002 00:41:31 -0000 1.26
+++ server/mpm/netware/mpm_netware.c 28 Jan 2002 04:23:17 -0000
@@ -526,7 +526,7 @@
current_conn = ap_new_connection(ptrans, ap_server_conf, csd,
my_worker_num, sbh);
if (current_conn) {
- ap_process_connection(current_conn);
+ ap_process_connection(current_conn, csd);
ap_lingering_close(current_conn);
}
request_count++;
Index: server/mpm/perchild/perchild.c
===================================================================
RCS file: /home/cvs/httpd-2.0/server/mpm/perchild/perchild.c,v
retrieving revision 1.102
diff -u -r1.102 perchild.c
--- server/mpm/perchild/perchild.c 28 Jan 2002 00:41:31 -0000 1.102
+++ server/mpm/perchild/perchild.c 28 Jan 2002 04:23:19 -0000
@@ -569,7 +569,7 @@
ap_create_sb_handle(&sbh, p, conn_id / thread_limit, thread_num);
current_conn = ap_new_connection(p, ap_server_conf, sock, conn_id, sbh);
if (current_conn) {
- ap_process_connection(current_conn);
+ ap_process_connection(current_conn, sock);
ap_lingering_close(current_conn);
}
}
Index: server/mpm/winnt/mpm_winnt.c
===================================================================
RCS file: /home/cvs/httpd-2.0/server/mpm/winnt/mpm_winnt.c,v
retrieving revision 1.211
diff -u -r1.211 mpm_winnt.c
--- server/mpm/winnt/mpm_winnt.c 28 Jan 2002 00:41:32 -0000 1.211
+++ server/mpm/winnt/mpm_winnt.c 28 Jan 2002 04:23:20 -0000
@@ -927,7 +927,7 @@
thread_num, sbh);
if (c) {
- ap_process_connection(c);
+ ap_process_connection(c, context->sock);
apr_getsocketopt(context->sock, APR_SO_DISCONNECTED, &disconnected);
if (!disconnected) {
context->accept_socket = INVALID_SOCKET;
Index: server/mpm/worker/worker.c
===================================================================
RCS file: /home/cvs/httpd-2.0/server/mpm/worker/worker.c,v
retrieving revision 1.63
diff -u -r1.63 worker.c
--- server/mpm/worker/worker.c 28 Jan 2002 00:49:04 -0000 1.63
+++ server/mpm/worker/worker.c 28 Jan 2002 04:23:22 -0000
@@ -559,7 +559,7 @@
current_conn = ap_new_connection(p, ap_server_conf, sock, conn_id, sbh);
if (current_conn) {
- ap_process_connection(current_conn);
+ ap_process_connection(current_conn, sock);
ap_lingering_close(current_conn);
}
}