From: Bill Stoddard Date: Thu, 27 Jan 2000 05:58:00 +0000 (+0000) Subject: More sendfile work. Use new sendfile API in Apache, update Windows MPM X-Git-Tag: 1.3.13~3 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e38f994a9d468a8c705146e887b4c1fbb5085a35;p=apache 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. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@84529 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/modules/http/http_protocol.c b/modules/http/http_protocol.c index 9f10c24aad..76b1386b5a 100644 --- a/modules/http/http_protocol.c +++ b/modules/http/http_protocol.c @@ -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."); } diff --git a/server/mpm/winnt/mpm_winnt.c b/server/mpm/winnt/mpm_winnt.c index 3cad021ef5..91bd9ed582 100644 --- a/server/mpm/winnt/mpm_winnt.c +++ b/server/mpm/winnt/mpm_winnt.c @@ -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..."); diff --git a/server/mpm/winnt/mpm_winnt.h b/server/mpm/winnt/mpm_winnt.h index d6ea03a623..32d9d1408b 100644 --- a/server/mpm/winnt/mpm_winnt.h +++ b/server/mpm/winnt/mpm_winnt.h @@ -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 */