mirror of
https://github.com/apache/httpd.git
synced 2025-09-02 13:21:21 +03:00
WinNT: Implement acceptex socket reuse. Make sure that the ap_sendfile flags
argument is properly initialized for all platforms. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@85775 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
12
modules/cache/mod_file_cache.c
vendored
12
modules/cache/mod_file_cache.c
vendored
@@ -421,6 +421,14 @@ static int sendfile_handler(request_rec *r, a_file *file, int rangestatus)
|
|||||||
struct iovec iov;
|
struct iovec iov;
|
||||||
ap_hdtr_t hdtr;
|
ap_hdtr_t hdtr;
|
||||||
ap_hdtr_t *phdtr = &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
|
* We want to send any data held in the client buffer on the
|
||||||
@@ -446,7 +454,7 @@ static int sendfile_handler(request_rec *r, a_file *file, int rangestatus)
|
|||||||
phdtr,
|
phdtr,
|
||||||
&offset,
|
&offset,
|
||||||
&length,
|
&length,
|
||||||
0);
|
flags);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
while (ap_each_byterange(r, &offset, &length)) {
|
while (ap_each_byterange(r, &offset, &length)) {
|
||||||
@@ -455,7 +463,7 @@ static int sendfile_handler(request_rec *r, a_file *file, int rangestatus)
|
|||||||
phdtr,
|
phdtr,
|
||||||
&offset,
|
&offset,
|
||||||
&length,
|
&length,
|
||||||
0);
|
flags);
|
||||||
phdtr = NULL;
|
phdtr = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -2250,6 +2250,7 @@ API_EXPORT(long) ap_send_fd(ap_file_t *fd, request_rec *r)
|
|||||||
{
|
{
|
||||||
ap_size_t len = r->finfo.size;
|
ap_size_t len = r->finfo.size;
|
||||||
#if APR_HAS_SENDFILE
|
#if APR_HAS_SENDFILE
|
||||||
|
ap_int32_t flags = 0;
|
||||||
if (!r->chunked) {
|
if (!r->chunked) {
|
||||||
ap_status_t rv;
|
ap_status_t rv;
|
||||||
ap_bsetopt(r->connection->client, BO_TIMEOUT,
|
ap_bsetopt(r->connection->client, BO_TIMEOUT,
|
||||||
@@ -2257,12 +2258,20 @@ API_EXPORT(long) ap_send_fd(ap_file_t *fd, request_rec *r)
|
|||||||
? &r->server->keep_alive_timeout
|
? &r->server->keep_alive_timeout
|
||||||
: &r->server->timeout);
|
: &r->server->timeout);
|
||||||
ap_bflush(r->connection->client);
|
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,
|
rv = iol_sendfile(r->connection->client->iol,
|
||||||
fd, /* The file to send */
|
fd, /* The file to send */
|
||||||
NULL, /* header and trailer iovecs */
|
NULL, /* header and trailer iovecs */
|
||||||
0, /* Offset in file to begin sending from */
|
0, /* Offset in file to begin sending from */
|
||||||
&len,
|
&len,
|
||||||
0);
|
flags);
|
||||||
if (rv != APR_SUCCESS) {
|
if (rv != APR_SUCCESS) {
|
||||||
ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r,
|
ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r,
|
||||||
"ap_send_fd: iol_sendfile failed.");
|
"ap_send_fd: iol_sendfile failed.");
|
||||||
|
@@ -944,7 +944,6 @@ static ap_inline ap_status_t reset_acceptex_context(PCOMP_CONTEXT context)
|
|||||||
"reset_acceptex_context: AcceptEx failed for "
|
"reset_acceptex_context: AcceptEx failed for "
|
||||||
"listening socket: %d and accept socket: %d",
|
"listening socket: %d and accept socket: %d",
|
||||||
nsd, context->accept_socket);
|
nsd, context->accept_socket);
|
||||||
context->accept_socket = INVALID_SOCKET;
|
|
||||||
return lasterror;
|
return lasterror;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1071,6 +1070,7 @@ static void worker_main(int child_num)
|
|||||||
while (1) {
|
while (1) {
|
||||||
conn_rec *current_conn;
|
conn_rec *current_conn;
|
||||||
ap_iol *iol;
|
ap_iol *iol;
|
||||||
|
ap_int32_t disconnected;
|
||||||
|
|
||||||
/* Grab a connection off the network */
|
/* Grab a connection off the network */
|
||||||
if (osver.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) {
|
if (osver.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) {
|
||||||
@@ -1099,8 +1099,20 @@ static void worker_main(int child_num)
|
|||||||
child_num);
|
child_num);
|
||||||
|
|
||||||
ap_process_connection(current_conn);
|
ap_process_connection(current_conn);
|
||||||
ap_lingering_close(current_conn);
|
|
||||||
|
|
||||||
|
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;
|
context->accept_socket = INVALID_SOCKET;
|
||||||
|
ap_lingering_close(current_conn);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ap_log_error(APLOG_MARK, APLOG_INFO, APR_SUCCESS, server_conf,
|
ap_log_error(APLOG_MARK, APLOG_INFO, APR_SUCCESS, server_conf,
|
||||||
|
Reference in New Issue
Block a user