stoddard 00/01/26 21:58:14
Modified: src/lib/apr/network_io/win32 sendrecv.c sockets.c
src/main http_protocol.c
src/modules/mpm/winnt winnt.c winnt.h
src/os/win32 iol_socket.c
Log:
More sendfile work. Use new sendfile API in Apache, update Windows MPM
to begin using APR socket API.
Note:
sendfile on Unix side is broken. Need to detect for NULL hdtr. I'll do
it later this week if no one else steps up.
Revision Changes Path
1.6 +2 -4 apache-2.0/src/lib/apr/network_io/win32/sendrecv.c
Index: sendrecv.c
===================================================================
RCS file: /home/cvs/apache-2.0/src/lib/apr/network_io/win32/sendrecv.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- sendrecv.c 2000/01/26 05:56:40 1.5
+++ sendrecv.c 2000/01/27 05:57:34 1.6
@@ -216,7 +216,7 @@
/* TransmitFile can only send one header and one footer */
memset(&tfb, '0', sizeof (tfb));
- if (hdtr->numheaders) {
+ if (hdtr && hdtr->numheaders) {
ptfb = &tfb;
for (i = 0; i < hdtr->numheaders; i++) {
tfb.HeadLength += hdtr->headers[i].iov_len;
@@ -230,7 +230,7 @@
ptr += hdtr->headers[i].iov_len;
}
}
- if (hdtr->numtrailers) {
+ if (hdtr && hdtr->numtrailers) {
ptfb = &tfb;
for (i = 0; i < hdtr->numtrailers; i++) {
tfb.TailLength += hdtr->headers[i].iov_len;
@@ -243,8 +243,6 @@
hdtr->trailers[i].iov_len);
ptr += hdtr->trailers[i].iov_len;
}
-
-
}
#ifdef OVERLAPPED
memset(&overlapped,'0', sizeof(overlapped));
1.17 +12 -1 apache-2.0/src/lib/apr/network_io/win32/sockets.c
Index: sockets.c
===================================================================
RCS file: /home/cvs/apache-2.0/src/lib/apr/network_io/win32/sockets.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- sockets.c 1999/12/17 12:32:16 1.16
+++ sockets.c 2000/01/27 05:57:38 1.17
@@ -63,7 +63,7 @@
#include <windows.h>
-ap_status_t socket_cleanup(void *sock)
+static ap_status_t socket_cleanup(void *sock)
{
struct socket_t *thesocket = sock;
if (closesocket(thesocket->sock) != SOCKET_ERROR) {
@@ -271,6 +271,17 @@
if ((*sock) == NULL) {
(*sock) = (struct socket_t *)ap_palloc(cont, sizeof(struct
socket_t));
(*sock)->cntxt = cont;
+ (*sock)->local_addr = (struct sockaddr_in *)ap_palloc((*sock)->cntxt,
+ sizeof(struct sockaddr_in));
+ (*sock)->remote_addr = (struct sockaddr_in
*)ap_palloc((*sock)->cntxt,
+ sizeof(struct sockaddr_in));
+
+ if ((*sock)->local_addr == NULL || (*sock)->remote_addr == NULL) {
+ return APR_ENOMEM;
+ }
+
+ (*sock)->addr_len = sizeof(*(*sock)->local_addr);
+ (*sock)->timeout = -1;
}
(*sock)->sock = *thesock;
return APR_SUCCESS;
1.51 +6 -2 apache-2.0/src/main/http_protocol.c
Index: http_protocol.c
===================================================================
RCS file: /home/cvs/apache-2.0/src/main/http_protocol.c,v
retrieving revision 1.50
retrieving revision 1.51
diff -u -r1.50 -r1.51
--- http_protocol.c 2000/01/19 02:09:03 1.50
+++ http_protocol.c 2000/01/27 05:57:47 1.51
@@ -2019,8 +2019,12 @@
#ifdef HAVE_SENDFILE
if (!r->chunked) {
ap_bflush(r->connection->client);
- if (iol_sendfile(r->connection->client->iol, fd, len,
- NULL, 0, 0) != APR_SUCCESS) {
+ if (iol_sendfile(r->connection->client->iol,
+ fd, /* The file to send */
+ NULL, /* header and trailer iovecs */
+ 0, /* Offset in file to begin sending from */
+ &len,
+ 0) != APR_SUCCESS) {
ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r,
"ap_send_fd: iol_sendfile failed.");
}
1.36 +14 -7 apache-2.0/src/modules/mpm/winnt/winnt.c
Index: winnt.c
===================================================================
RCS file: /home/cvs/apache-2.0/src/modules/mpm/winnt/winnt.c,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -r1.35 -r1.36
--- winnt.c 1999/12/20 19:52:51 1.35
+++ winnt.c 2000/01/27 05:57:57 1.36
@@ -104,6 +104,15 @@
int my_pid;
int parent_pid;
+static ap_status_t socket_cleanup(void *sock)
+{
+ struct socket_t *thesocket = sock;
+ SOCKET sd;
+ if (ap_get_os_sock(&sd, thesocket) == APR_SUCCESS) {
+ closesocket(sd);
+ }
+ return APR_SUCCESS;
+}
/* A bunch or routines from os/win32/multithread.c that need to be merged
into APR
* or thrown out entirely...
@@ -995,6 +1004,7 @@
}
ap_clear_pool(context->ptrans);
+ context->sock = NULL;
context->conn_io = ap_bcreate(context->ptrans, B_RDWR);
context->recv_buf = context->conn_io->inbase;
context->recv_buf_size = context->conn_io->bufsiz - 2*PADDED_ADDR_SIZE;
@@ -1149,13 +1159,10 @@
if (!context)
break;
-
- /* TODO: Register cleanups for our sockets.*/
- /* ap_note_cleanups_for_socket(context->ptrans,
context->accept_socket); */
-
- sock_disable_nagle(context->accept_socket);
-
- iol = win32_attach_socket(context->ptrans, context->accept_socket);
+ sock_disable_nagle(context->accept_socket);
+ ap_put_os_sock(&context->sock, &context->accept_socket,
context->ptrans);
+ ap_register_cleanup(context->ptrans, context->sock, socket_cleanup,
ap_null_cleanup);
+ iol = win32_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...");
1.7 +1 -12 apache-2.0/src/modules/mpm/winnt/winnt.h
Index: winnt.h
===================================================================
RCS file: /home/cvs/apache-2.0/src/modules/mpm/winnt/winnt.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- winnt.h 1999/12/13 22:53:25 1.6
+++ winnt.h 2000/01/27 05:58:00 1.7
@@ -67,6 +67,7 @@
typedef struct CompContext {
OVERLAPPED Overlapped;
SOCKET accept_socket;
+ ap_socket_t *sock;
ap_listen_rec *lr;
BUFF *conn_io;
char *recv_buf;
@@ -77,16 +78,4 @@
struct sockaddr *sa_client;
int sa_client_len;
} COMP_CONTEXT, *PCOMP_CONTEXT;
-#if 0
-typedef struct CompContext {
- OVERLAPPED Overlapped;
- SOCKET accept_socket;
- BUFF* conn_io;
- ap_context_t *ptrans;
- struct sockaddr sa_server;
- int sa_server_len;
- struct sockaddr sa_client;
- int sa_client_len;
-} COMP_CONTEXT, *PCOMP_CONTEXT;
-#endif
#endif /* APACHE_MPM_WINNT_H */
1.10 +1 -1 apache-2.0/src/os/win32/iol_socket.c
Index: iol_socket.c
===================================================================
RCS file: /home/cvs/apache-2.0/src/os/win32/iol_socket.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- iol_socket.c 2000/01/26 05:56:41 1.9
+++ iol_socket.c 2000/01/27 05:58:09 1.10
@@ -141,7 +141,7 @@
iol_socket *iol;
// iol = malloc(sizeof(iol_socket));
- iol = ap_palloc(p,sizeof(iol_socket));
+ iol = ap_palloc(p, sizeof(iol_socket));
if (!iol)
return (ap_iol*) NULL;
iol->iol.methods = &socket_methods;