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

Remove IOLs from Apache. They are no longer necessary, now that we have

filtering beginning to work.  There is a hack that has been repeated
through this patch, we morph a pipe into a socket, and put the socket
into the BUFF.  Everytime we do that, we are working with a pipe from
a CGI, and we should be creating a pipe bucket and passing that bucket
back.  Because we don't actually have pipe buckets yet, we are using this
hack.  When we get pipe buckets, this will be fixed.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@86136 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Ryan Bloom
2000-08-23 00:01:58 +00:00
parent 87f6dead16
commit ae7cca1bd9
20 changed files with 67 additions and 119 deletions

View File

@@ -98,7 +98,7 @@
unix/posix notes:
- The MPM does not set a SIGALRM handler, user code may use SIGALRM.
But the preferred method of handling timeouts is to use the
timeouts provided by the BUFF/iol abstraction.
timeouts provided by the BUFF abstraction.
- The proper setting for SIGPIPE is SIG_IGN, if user code changes it
for any of their own processing, it must be restored to SIG_IGN
prior to executing or returning to any apache code.

View File

@@ -836,7 +836,7 @@ static int include_cmd(char *s, request_rec *r)
apr_table_t *env = r->subprocess_env;
char **argv;
apr_file_t *file = NULL;
ap_iol *iol;
apr_socket_t *sock = NULL;
#if defined(RLIMIT_CPU) || defined(RLIMIT_NPROC) || \
defined(RLIMIT_DATA) || defined(RLIMIT_VMEM) || defined (RLIMIT_AS)
core_dir_config *conf;
@@ -908,11 +908,15 @@ static int include_cmd(char *s, request_rec *r)
apr_note_subprocess(r->pool, procnew, kill_after_timeout);
/* Fill in BUFF structure for parents pipe to child's stdout */
file = procnew->out;
iol = ap_create_file_iol(file);
if (!iol)
if (!file)
return APR_EBADF;
/* XXX This is a hack. The correct solution is to create a
* pipe bucket, and just pass it down. Since that bucket type
* hasn't been written, we can hack it for the moment.
*/
apr_socket_from_file(&sock, file);
script_in = ap_bcreate(r->pool, B_RD);
ap_bpush_iol(script_in, iol);
ap_bpush_socket(script_in, sock);
ap_send_fb(script_in, r);
ap_bclose(script_in);
}

View File

@@ -309,7 +309,7 @@ static apr_status_t run_cgi_child(BUFF **script_out, BUFF **script_in, BUFF **sc
apr_proc_t *procnew = apr_pcalloc(p, sizeof(*procnew));
apr_status_t rc = APR_SUCCESS;
apr_file_t *file = NULL;
ap_iol *iol;
apr_file_t *sock = NULL;
#if defined(RLIMIT_CPU) || defined(RLIMIT_NPROC) || \
defined(RLIMIT_DATA) || defined(RLIMIT_VMEM) || defined (RLIMIT_AS)
core_dir_config *conf;
@@ -379,29 +379,42 @@ static apr_status_t run_cgi_child(BUFF **script_out, BUFF **script_in, BUFF **sc
/* Fill in BUFF structure for parents pipe to child's stdout */
file = procnew->out;
iol = ap_create_file_iol(file);
if (!iol)
if (!file)
return APR_EBADF;
/* XXX This is a hack. The correct solution is to create a
* pipe bucket, and just pass it down. Since that bucket type
* hasn't been written, we can hack it for the moment.
*/
apr_socket_from_file(&sock, file);
*script_in = ap_bcreate(p, B_RD);
ap_bpush_iol(*script_in, iol);
ap_bpush_socket(*script_in, sock);
ap_bsetopt(*script_in, BO_TIMEOUT, &r->server->timeout);
/* Fill in BUFF structure for parents pipe to child's stdin */
file = procnew->in;
iol = ap_create_file_iol(file);
if (!iol)
if (!file)
return APR_EBADF;
/* XXX This is a hack. The correct solution is to create a
* pipe bucket, and just pass it down. Since that bucket type
* hasn't been written, we can hack it for the moment.
*/
apr_socket_from_file(&sock, file);
*script_out = ap_bcreate(p, B_WR);
ap_bpush_iol(*script_out, iol);
ap_bpush_socket(*script_out, sock);
ap_bsetopt(*script_out, BO_TIMEOUT, &r->server->timeout);
/* Fill in BUFF structure for parents pipe to child's stderr */
file = procnew->err;
iol = ap_create_file_iol(file);
if (!iol)
if (!file)
return APR_EBADF;
/* XXX This is a hack. The correct solution is to create a
* pipe bucket, and just pass it down. Since that bucket type
* hasn't been written, we can hack it for the moment.
*/
apr_socket_from_file(&sock, file);
*script_err = ap_bcreate(p, B_RD);
ap_bpush_iol(*script_err, iol);
ap_bpush_socket(*script_err, sock);
ap_bsetopt(*script_err, BO_TIMEOUT, &r->server->timeout);
}
}

View File

@@ -89,7 +89,6 @@
#include "http_conf_globals.h"
#include "buff.h"
#include "ap_mpm.h"
#include "ap_iol.h"
#include "unixd.h"
#include <sys/stat.h>
#ifdef HAVE_SYS_SOCKET_H
@@ -840,7 +839,6 @@ static int cgid_handler(request_rec *r)
struct sockaddr_un unix_addr;
apr_socket_t *tempsock = NULL;
int nbytes;
ap_iol *iol;
script = ap_bcreate(r->pool, B_RDWR);
if (r->method_number == M_OPTIONS) {
@@ -920,9 +918,7 @@ static int cgid_handler(request_rec *r)
apr_put_os_sock(&tempsock, &sd, pcgi);
iol = ap_iol_attach_socket(pcgi, tempsock);
ap_bpush_iol(script, iol);
ap_bpush_socket(script, tempsock);
if ((retval = ap_setup_client_block(r, REQUEST_CHUNKED_ERROR)))
return retval;

View File

@@ -2966,7 +2966,7 @@ static int chunk_filter(ap_filter_t *f, ap_bucket_brigade *b)
/* Default filter. This filter should almost always be used. It's only job
* is to send the headers if they haven't already been sent, and then send
* the actual data. To send the data, we create an iovec out of the bucket
* brigade and then call the iol's writev function. On platforms that don't
* brigade and then call the sendv function. On platforms that don't
* have writev, we have the problem of creating a lot of potentially small
* packets that we are sending to the network.
*

View File

@@ -2311,7 +2311,7 @@ static apr_status_t static_send_file(apr_file_t *fd, request_rec *r, apr_off_t o
/*
* We want to send any data held in the client buffer on the
* call to iol_sendfile. So hijack it then set outcnt to 0
* call to apr_sendfile. So hijack it then set outcnt to 0
* to prevent the data from being sent to the client again
* when the buffer is flushed to the client at the end of the
* request.
@@ -2332,7 +2332,7 @@ static apr_status_t static_send_file(apr_file_t *fd, request_rec *r, apr_off_t o
flags |= APR_SENDFILE_DISCONNECT_SOCKET;
}
rv = iol_sendfile(r->connection->client->iol,
rv = apr_sendfile(r->connection->client->bsock,
fd, /* The file to send */
&hdtr, /* Header and trailer iovecs */
&offset, /* Offset in file to begin sending from */

View File

@@ -2149,7 +2149,7 @@ static int uncompress_child(struct uncompress_parms *parm, apr_pool_t *cntxt,
apr_pool_t *child_context = cntxt;
apr_procattr_t *procattr;
apr_proc_t *procnew;
ap_iol *iol;
apr_socket_t *sock;
env = ap_create_environment(child_context, r->subprocess_env);
@@ -2185,13 +2185,16 @@ static int uncompress_child(struct uncompress_parms *parm, apr_pool_t *cntxt,
else {
apr_note_subprocess(child_context, procnew, kill_after_timeout);
/* Fill in BUFF structure for parents pipe to child's stdout */
iol = ap_create_file_iol(procnew->out);
if (!iol)
return APR_EBADF;
/* XXX This is a hack. The correct solution is to create a
* pipe bucket, and just pass it down. Since that bucket type
* hasn't been written, we can hack it for the moment.
*/
apr_socket_from_file(&sock, procnew->out);
if (script_in) {
*script_in = ap_bcreate(child_context, B_RD);
}
ap_bpush_iol(*script_in, iol);
ap_bpush_socket(*script_in, sock);
}
}

View File

@@ -61,7 +61,6 @@
#include "mod_proxy.h"
#include "http_log.h"
#include "http_main.h"
#include "ap_iol.h"
#ifdef HAVE_BSTRING_H
#include <bstring.h> /* for IRIX, FD_SET calls bzero() */
@@ -211,7 +210,7 @@ int ap_proxy_connect_handler(request_rec *r, ap_cache_el *c, char *url,
}
sock_buff = ap_bcreate(r->pool, B_RDWR);
ap_bpush_iol(sock_buff, ap_iol_attach_socket(sock));
ap_bpush_socket(sock_buff, sock);
if(apr_setup_poll(&pollfd, 2, r->pool) != APR_SUCCESS)
{

View File

@@ -62,7 +62,6 @@
#include "http_main.h"
#include "http_log.h"
#include "http_core.h"
#include "ap_iol.h"
#define AUTODETECT_PWD
@@ -589,7 +588,7 @@ int ap_proxy_ftp_handler(request_rec *r, ap_cache_el *c, char *url)
}
f = ap_bcreate(p, B_RDWR);
ap_bpush_iol(f, ap_iol_attach_socket(sock));
ap_bpush_socket(f, sock);
/* shouldn't we implement telnet control options here? */
#ifdef CHARSET_EBCDIC
@@ -1146,11 +1145,11 @@ int ap_proxy_ftp_handler(request_rec *r, ap_cache_el *c, char *url)
}
}
data = ap_bcreate(p, B_RDWR);
ap_bpush_iol(f, ap_iol_attach_socket(csd));
ap_bpush_socket(f, csd);
}
else {
data = ap_bcreate(p, B_RDWR);
ap_bpush_iol(data, ap_iol_attach_socket(dsock));
ap_bpush_socket(data, dsock);
}
/* send response */

View File

@@ -63,7 +63,6 @@
#include "http_main.h"
#include "http_core.h"
#include "util_date.h"
#include "ap_iol.h"
/*
* Canonicalise http-like URLs.
@@ -269,7 +268,7 @@ int ap_proxy_http_handler(request_rec *r, ap_cache_el *c, char *url,
clear_connection(r->pool, r->headers_in); /* Strip connection-based headers */
f = ap_bcreate(p, B_RDWR);
ap_bpush_iol(f, ap_iol_attach_socket(sock));
ap_bpush_socket(f, sock);
ap_bvputs(f, r->method, " ", proxyhost ? url : urlptr, " HTTP/1.0" CRLF,
NULL);

View File

@@ -7,7 +7,7 @@ LTLIBRARY_SOURCES = \
buff.c http_config.c http_core.c http_log.c http_main.c \
http_protocol.c http_request.c http_vhost.c util.c util_date.c \
util_script.c util_uri.c util_md5.c util_cfgtree.c util_ebcdic.c \
rfc1413.c http_connection.c iol_file.c iol_socket.c listen.c \
rfc1413.c http_connection.c listen.c \
mpm_common.c util_charset.c util_debug.c util_xml.c \
util_filter.c

View File

@@ -76,7 +76,6 @@
#include "http_connection.h"
#include "ap_mpm.h"
#include "beosd.h"
#include "ap_iol.h"
#include "ap_listen.h"
#include "scoreboard.h"
#include <kernel/OS.h>
@@ -308,7 +307,6 @@ static void process_socket(apr_pool_t *p, apr_socket_t *sock, int my_child_num)
{
BUFF *conn_io;
conn_rec *current_conn;
ap_iol *iol;
long conn_id = my_child_num;
int csd;
@@ -323,16 +321,8 @@ static void process_socket(apr_pool_t *p, apr_socket_t *sock, int my_child_num)
return;
}
iol = ap_iol_attach_socket(p, sock);
if (iol == NULL) {
ap_log_error(APLOG_MARK, APLOG_WARNING, errno, NULL,
"error attaching to socket");
apr_close_socket(sock);
return;
}
conn_io = ap_bcreate(p, B_RDWR);
ap_bpush_iol(conn_io, iol);
ap_bpush_socket(conn_io, sock);
current_conn = ap_new_apr_connection(p, ap_server_conf, conn_io, sock,
conn_id);

View File

@@ -71,7 +71,6 @@
#include "ap_mpm.h"
#include "unixd.h"
#include "mpm_common.h"
#include "ap_iol.h"
#include "ap_listen.h"
#include "mpm_default.h"
#include "mpm.h"
@@ -398,7 +397,6 @@ static void process_socket(apr_pool_t *p, apr_socket_t *sock, long conn_id)
{
BUFF *conn_io;
conn_rec *current_conn;
ap_iol *iol;
int csd;
apr_status_t rv;
@@ -417,9 +415,9 @@ static void process_socket(apr_pool_t *p, apr_socket_t *sock, long conn_id)
}
ap_sock_disable_nagle(sock);
iol = ap_iol_attach_socket(p, sock);
conn_io = ap_bcreate(p, B_RDWR);
ap_bpush_iol(conn_io, iol);
ap_bpush_socket(conn_io, sock);
current_conn = ap_new_apr_connection(p, ap_server_conf, conn_io, sock,
conn_id);

View File

@@ -73,7 +73,6 @@
#include "ap_mpm.h"
#include "unixd.h"
#include "mpm_common.h"
#include "ap_iol.h"
#include "ap_listen.h"
#include "mpm_default.h"
#include "mpm.h"
@@ -433,7 +432,6 @@ static void process_socket(apr_pool_t *p, apr_socket_t *sock, long conn_id)
{
BUFF *conn_io;
conn_rec *current_conn;
ap_iol *iol;
int csd;
apr_status_t rv;
int thread_num = conn_id % HARD_THREAD_LIMIT;
@@ -455,9 +453,8 @@ static void process_socket(apr_pool_t *p, apr_socket_t *sock, long conn_id)
if (thread_socket_table[thread_num] < 0) {
ap_sock_disable_nagle(sock);
}
iol = ap_iol_attach_socket(p, sock);
conn_io = ap_bcreate(p, B_RDWR);
ap_bpush_iol(conn_io, iol);
ap_bpush_socket(conn_io, sock);
current_conn = ap_new_apr_connection(p, ap_server_conf, conn_io, sock,
conn_id);
@@ -1346,7 +1343,7 @@ static void perchild_pre_config(apr_pool_t *p, apr_pool_t *plog, apr_pool_t *pte
static int pass_request(request_rec *r)
{
apr_socket_t *thesock = ap_iol_get_socket(r->connection->client->iol);
apr_socket_t *thesock = r->connection->client->bsock;
struct msghdr msg;
struct cmsghdr *cmsg;
int sfd;
@@ -1439,13 +1436,11 @@ static int perchild_post_read(request_rec *r)
if (thread_socket_table[thread_num] != -1) {
apr_socket_t *csd = NULL;
ap_iol *iol;
apr_put_os_sock(&csd, &thread_socket_table[thread_num],
r->connection->client->pool);
ap_sock_disable_nagle(thread_socket_table[thread_num]);
iol = ap_iol_attach_socket(r->connection->client->pool, csd);
ap_bpush_iol(r->connection->client, iol);
ap_bpush_socket(r->connection->client, csd);
return OK;
}
else {

View File

@@ -72,7 +72,6 @@
#include "http_connection.h"
#include "ap_mpm.h"
#include "beosd.h"
#include "ap_iol.h"
#include "ap_listen.h"
#include "scoreboard.h"
#include "poll.h"
@@ -298,28 +297,11 @@ static void process_socket(apr_pool_t *p, apr_socket_t *sock, int my_child_num,
{
BUFF *conn_io;
conn_rec *current_conn;
ap_iol *iol;
long conn_id = my_child_num * HARD_THREAD_LIMIT + my_thread_num;
int csd;
iol = ap_iol_attach_socket(p, sock);
if (iol == NULL) {
if (errno == EBADF) {
ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_WARNING, errno, NULL,
"filedescriptor (%u) larger than FD_SETSIZE (%u) "
"found, you probably need to rebuild Apache with a "
"larger FD_SETSIZE", csd, FD_SETSIZE);
}
else {
ap_log_error(APLOG_MARK, APLOG_WARNING, errno, NULL,
"error attaching to socket");
}
apr_close_socket(sock);
return;
}
conn_io = ap_bcreate(p, B_RDWR);
ap_bpush_iol(conn_io, iol);
ap_bpush_socket(conn_io, sock);
current_conn = ap_new_apr_connection(p, ap_server_conf, conn_io, sock,
conn_id);

View File

@@ -72,7 +72,6 @@
#include "ap_mpm.h"
#include "unixd.h"
#include "mpm_common.h"
#include "ap_iol.h"
#include "ap_listen.h"
#include "scoreboard.h"
@@ -395,7 +394,6 @@ static void process_socket(apr_pool_t *p, apr_socket_t *sock, int my_child_num,
{
BUFF *conn_io;
conn_rec *current_conn;
ap_iol *iol;
long conn_id = my_child_num * HARD_THREAD_LIMIT + my_thread_num;
int csd;
@@ -413,12 +411,10 @@ static void process_socket(apr_pool_t *p, apr_socket_t *sock, int my_child_num,
ap_sock_disable_nagle(sock);
iol = ap_iol_attach_socket(p, sock);
(void) ap_update_child_status(my_child_num, my_thread_num,
SERVER_BUSY_READ, (request_rec *) NULL);
conn_io = ap_bcreate(p, B_RDWR);
ap_bpush_iol(conn_io, iol);
ap_bpush_socket(conn_io, sock);
current_conn = ap_new_apr_connection(p, ap_server_conf, conn_io, sock,
conn_id);

View File

@@ -73,7 +73,6 @@
#include "ap_mpm.h"
#include "unixd.h"
#include "mpm_common.h"
#include "ap_iol.h"
#include "ap_listen.h"
#include "mpm_default.h"
#include "mpm.h"
@@ -433,7 +432,6 @@ static void process_socket(apr_pool_t *p, apr_socket_t *sock, long conn_id)
{
BUFF *conn_io;
conn_rec *current_conn;
ap_iol *iol;
int csd;
apr_status_t rv;
int thread_num = conn_id % HARD_THREAD_LIMIT;
@@ -455,9 +453,8 @@ static void process_socket(apr_pool_t *p, apr_socket_t *sock, long conn_id)
if (thread_socket_table[thread_num] < 0) {
ap_sock_disable_nagle(sock);
}
iol = ap_iol_attach_socket(p, sock);
conn_io = ap_bcreate(p, B_RDWR);
ap_bpush_iol(conn_io, iol);
ap_bpush_socket(conn_io, sock);
current_conn = ap_new_apr_connection(p, ap_server_conf, conn_io, sock,
conn_id);
@@ -1346,7 +1343,7 @@ static void perchild_pre_config(apr_pool_t *p, apr_pool_t *plog, apr_pool_t *pte
static int pass_request(request_rec *r)
{
apr_socket_t *thesock = ap_iol_get_socket(r->connection->client->iol);
apr_socket_t *thesock = r->connection->client->bsock;
struct msghdr msg;
struct cmsghdr *cmsg;
int sfd;
@@ -1439,13 +1436,11 @@ static int perchild_post_read(request_rec *r)
if (thread_socket_table[thread_num] != -1) {
apr_socket_t *csd = NULL;
ap_iol *iol;
apr_put_os_sock(&csd, &thread_socket_table[thread_num],
r->connection->client->pool);
ap_sock_disable_nagle(thread_socket_table[thread_num]);
iol = ap_iol_attach_socket(r->connection->client->pool, csd);
ap_bpush_iol(r->connection->client, iol);
ap_bpush_socket(r->connection->client, csd);
return OK;
}
else {

View File

@@ -103,7 +103,6 @@
#include "ap_mpm.h"
#include "unixd.h"
#include "mpm_common.h"
#include "ap_iol.h"
#include "ap_listen.h"
#include "ap_mmn.h"
#ifdef HAVE_SYS_TYPES_H
@@ -748,7 +747,6 @@ static void child_main(int child_num_arg)
ap_listen_rec *first_lr;
apr_pool_t *ptrans;
conn_rec *current_conn;
ap_iol *iol;
apr_status_t stat = APR_EINIT;
int sockdes;
@@ -1022,13 +1020,12 @@ static void child_main(int child_num_arg)
ap_sock_disable_nagle(csd);
iol = ap_iol_attach_socket(ptrans, csd);
(void) ap_update_child_status(my_child_num, SERVER_BUSY_READ,
(request_rec *) NULL);
conn_io = ap_bcreate(ptrans, B_RDWR);
ap_bpush_iol(conn_io, iol);
ap_bpush_socket(conn_io, csd);
current_conn = ap_new_apr_connection(ptrans, ap_server_conf, conn_io, csd,
my_child_num);

View File

@@ -71,7 +71,6 @@
#include "scoreboard.h"
#include "ap_mpm.h"
#include "ap_listen.h"
#include "ap_iol.h"
#include "apr_portable.h"
#include "mpm_common.h"
#include "apr_strings.h"
@@ -742,7 +741,6 @@ static void child_main(void *child_num_arg)
ap_listen_rec *first_lr = NULL;
apr_pool_t *ptrans;
conn_rec *current_conn;
ap_iol *iol;
apr_pool_t *pchild;
parent_score *sc_parent_rec;
int requests_this_child = 0;
@@ -968,20 +966,11 @@ static void child_main(void *child_num_arg)
ap_sock_disable_nagle(csd);
iol = ap_iol_attach_socket(ptrans, csd);
if (iol == NULL) {
ap_log_error(APLOG_MARK, APLOG_WARNING|APLOG_NOERRNO, 0, NULL,
"error attaching to socket");
apr_close_socket(csd);
continue;
}
(void) ap_update_child_status(THREAD_GLOBAL(child_num), SERVER_BUSY_READ,
(request_rec *) NULL);
conn_io = ap_bcreate(ptrans, B_RDWR);
ap_bpush_iol(conn_io, iol);
ap_bpush_socket(conn_io, csd);
current_conn = ap_new_apr_connection(ptrans, ap_server_conf, conn_io, csd,
THREAD_GLOBAL(child_num));

View File

@@ -70,7 +70,6 @@
#include "ap_config.h"
#include "ap_listen.h"
#include "mpm_default.h"
#include "ap_iol.h"
#include "mpm_winnt.h"
#include "mpm_common.h"
@@ -1123,7 +1122,6 @@ static void worker_main(int child_num)
while (1) {
conn_rec *c;
ap_iol *iol;
apr_int32_t disconnected;
/* Grab a connection off the network */
@@ -1139,14 +1137,7 @@ static void worker_main(int child_num)
sock_disable_nagle(context->accept_socket);
apr_put_os_sock(&context->sock, &context->accept_socket, context->ptrans);
iol = ap_iol_attach_socket(context->ptrans, context->sock);
if (iol == NULL) {
ap_log_error(APLOG_MARK, APLOG_ERR, APR_ENOMEM, server_conf,
"worker_main: attach_socket() failed. Continuing...");
closesocket(context->accept_socket);
continue;
}
ap_bpush_iol(context->conn_io, iol);
ap_bpush_socket(context->conn_io, context->sock);
c = ap_new_connection(context->ptrans, server_conf, context->conn_io,
(struct sockaddr_in *) context->sa_client,
(struct sockaddr_in *) context->sa_server,
@@ -1157,11 +1148,13 @@ static void worker_main(int child_num)
apr_getsocketopt(context->sock, APR_SO_DISCONNECTED, &disconnected);
if (disconnected) {
/* I have no idea if we should do anything here, so I leave this
* for a windows guy
*/
/* Kill the clean-up registered by the iol. We want to leave
* the accept socket open because we are about to try to
* reuse it
*/
ap_bpop_iol(&iol, context->conn_io);
}
else {
context->accept_socket = INVALID_SOCKET;