#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.");
}
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...
}
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;
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...");
typedef struct CompContext {
OVERLAPPED Overlapped;
SOCKET accept_socket;
+ ap_socket_t *sock;
ap_listen_rec *lr;
BUFF *conn_io;
char *recv_buf;
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 */