struct iovec iov;
ap_hdtr_t hdtr;
ap_hdtr_t *phdtr = &hdtr;
+ ap_int32_t flags = 0;
+
+ if (!r->connection->keepalive) {
+ /* Prepare the socket to be reused. Ignored on systems
+ * that do not support reusing the accept socket
+ */
+ flags |= APR_SENDFILE_DISCONNECT_SOCKET;
+ }
/*
* We want to send any data held in the client buffer on the
phdtr,
&offset,
&length,
- 0);
+ flags);
}
else {
while (ap_each_byterange(r, &offset, &length)) {
phdtr,
&offset,
&length,
- 0);
+ flags);
phdtr = NULL;
}
}
{
ap_size_t len = r->finfo.size;
#if APR_HAS_SENDFILE
+ ap_int32_t flags = 0;
if (!r->chunked) {
ap_status_t rv;
ap_bsetopt(r->connection->client, BO_TIMEOUT,
? &r->server->keep_alive_timeout
: &r->server->timeout);
ap_bflush(r->connection->client);
+
+ if (!r->connection->keepalive) {
+ /* Prepare the socket to be reused. Ignored on systems
+ * that do not support reusing the accept socket
+ */
+ flags |= APR_SENDFILE_DISCONNECT_SOCKET;
+ }
+
rv = 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);
+ flags);
if (rv != APR_SUCCESS) {
ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r,
"ap_send_fd: iol_sendfile failed.");
"reset_acceptex_context: AcceptEx failed for "
"listening socket: %d and accept socket: %d",
nsd, context->accept_socket);
- context->accept_socket = INVALID_SOCKET;
return lasterror;
}
}
while (1) {
conn_rec *current_conn;
ap_iol *iol;
+ ap_int32_t disconnected;
/* Grab a connection off the network */
if (osver.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) {
child_num);
ap_process_connection(current_conn);
- ap_lingering_close(current_conn);
- context->accept_socket = INVALID_SOCKET;
+
+
+ ap_getsocketopt(context->sock, APR_SO_DISCONNECTED, &disconnected);
+ if (disconnected) {
+ /* Kill the clean-up registered by the iol. We want to leave
+ * the accept socket open because we are about to try to
+ * reuse it
+ */
+ ap_bpop_iol(&iol, context->conn_io);
+ }
+ else {
+ context->accept_socket = INVALID_SOCKET;
+ ap_lingering_close(current_conn);
+ }
}
ap_log_error(APLOG_MARK, APLOG_INFO, APR_SUCCESS, server_conf,