]> granicus.if.org Git - apache/commitdiff
Optimize reading keep-alive requests with APR_INCOMPLETE_READ. In the
authorBill Stoddard <stoddard@apache.org>
Sun, 7 Jul 2002 16:35:20 +0000 (16:35 +0000)
committerBill Stoddard <stoddard@apache.org>
Sun, 7 Jul 2002 16:35:20 +0000 (16:35 +0000)
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

index 8bd0fb7e8d3c28d2133face362feb1fe0a80f5ac..9bbcdfcfd5feada789b5e7143e0285d0901d42d1 100644 (file)
@@ -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;