Commit a0597568 authored by Bill Stoddard's avatar Bill Stoddard
Browse files

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
parent 8a5d79fc
Loading
Loading
Loading
Loading
+6 −2
Changes for modules/http/http_protocol.c: 6 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -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.");
        }
+13 −6
Changes for server/mpm/winnt/mpm_winnt.c: 13 added lines, 6 removed lines.
Original line number Diff line number Diff line
@@ -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);
        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 −12
Changes for server/mpm/winnt/mpm_winnt.h: 1 added line, 12 removed lines.
Original line number Diff line number Diff line
@@ -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 */