From e3ddc90edc8938c6a0e39524f03011b9c5b50fd1 Mon Sep 17 00:00:00 2001 From: Bill Stoddard Date: Sun, 7 Jul 2002 16:35:20 +0000 Subject: [PATCH] Optimize reading keep-alive requests with APR_INCOMPLETE_READ. In the profiling I've done, the read() in apr_read() would always fail with EAGAIN. This will send the thread directly to select to wait for the next request. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@95968 13f79535-47bb-0310-9956-ffa450edef68 --- modules/http/http_core.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/modules/http/http_core.c b/modules/http/http_core.c index 8bd0fb7e8d..9bbcdfcfd5 100644 --- a/modules/http/http_core.c +++ b/modules/http/http_core.c @@ -274,7 +274,9 @@ static apr_port_t http_port(const request_rec *r) static int ap_process_http_connection(conn_rec *c) { request_rec *r; - + int csd_set = 0; + apr_socket_t *csd = NULL; + /* * Read and process each request found on our connection * until no requests are left or we decide to close. @@ -282,7 +284,7 @@ static int ap_process_http_connection(conn_rec *c) ap_update_child_status(c->sbh, SERVER_BUSY_READ, NULL); while ((r = ap_read_request(c)) != NULL) { - + c->keepalive = AP_CONN_UNKNOWN; /* process the request if it was read without error */ @@ -301,6 +303,12 @@ static int ap_process_http_connection(conn_rec *c) if (ap_graceful_stop_signalled()) break; + /* Go straight to select() to wait for the next request */ + if (!csd_set) { + csd = ap_get_module_config(c->conn_config, &core_module); + csd_set = 1; + } + apr_setsocketopt(csd, APR_INCOMPLETE_READ, 1); } return OK; -- 2.40.0