]> granicus.if.org Git - apache/commitdiff
More sendfile work. Use new sendfile API in Apache, update Windows MPM
authorBill Stoddard <stoddard@apache.org>
Thu, 27 Jan 2000 05:58:00 +0000 (05:58 +0000)
committerBill Stoddard <stoddard@apache.org>
Thu, 27 Jan 2000 05:58:00 +0000 (05:58 +0000)
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.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@84529 13f79535-47bb-0310-9956-ffa450edef68

modules/http/http_protocol.c
server/mpm/winnt/mpm_winnt.c
server/mpm/winnt/mpm_winnt.h

index 9f10c24aadccf4a7a2db38b644f7ee27b86f05c9..76b1386b5a2625952b26857b553ae4477aab096a 100644 (file)
@@ -2019,8 +2019,12 @@ API_EXPORT(long) ap_send_fd(ap_file_t *fd, request_rec *r)
 #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.");
         }
index 3cad021ef5a06d5a6beb8124e5676c7b62ba9e3b..91bd9ed582e92a1c0da88bc04825aa4bcbb06fed 100644 (file)
@@ -104,6 +104,15 @@ ap_lock_t *start_mutex;
 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 @@ static ap_inline int reset_acceptex_context(PCOMP_CONTEXT context)
     }
 
     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 @@ static void worker_main(int child_num)
 
         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...");
index d6ea03a623c2234dc123614e93b5d6de98b5486d..32d9d1408be1084e14cfacef257c8b0f2e95cc5a 100644 (file)
@@ -67,6 +67,7 @@ extern void clean_child_exit(int);
 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 @@ typedef struct CompContext {
     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 */