You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by mi...@apache.org on 2022/02/09 18:23:23 UTC

svn commit: r1897912 - in /httpd/httpd/trunk: changes-entries/ab-keepalivefix.txt support/ab.c

Author: minfrin
Date: Wed Feb  9 18:23:23 2022
New Revision: 1897912

URL: http://svn.apache.org/viewvc?rev=1897912&view=rev
Log:
ab: Fix the detection for when the server performed a legitimate
connection close as per RFC7230 6.3.1. We must check whedther the
connection was previously kept alive, and not whether the current
closed request is keepalive.

Added:
    httpd/httpd/trunk/changes-entries/ab-keepalivefix.txt
Modified:
    httpd/httpd/trunk/support/ab.c

Added: httpd/httpd/trunk/changes-entries/ab-keepalivefix.txt
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/changes-entries/ab-keepalivefix.txt?rev=1897912&view=auto
==============================================================================
--- httpd/httpd/trunk/changes-entries/ab-keepalivefix.txt (added)
+++ httpd/httpd/trunk/changes-entries/ab-keepalivefix.txt Wed Feb  9 18:23:23 2022
@@ -0,0 +1,5 @@
+  *) ab: Fix the detection for when the server performed a legitimate
+     connection close as per RFC7230 6.3.1. We must check whedther the
+     connection was previously kept alive, and not whether the current
+     closed request is keepalive. [Graham Leggett]
+

Modified: httpd/httpd/trunk/support/ab.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/support/ab.c?rev=1897912&r1=1897911&r2=1897912&view=diff
==============================================================================
--- httpd/httpd/trunk/support/ab.c (original)
+++ httpd/httpd/trunk/support/ab.c Wed Feb  9 18:23:23 2022
@@ -273,6 +273,7 @@ struct connection {
                beginread,       /* First byte of input */
                done;            /* Connection closed */
 
+    apr_uint64_t keptalive;     /* subsequent keepalive requests */
     int socknum;
 #ifdef USE_SSL
     SSL *ssl;
@@ -738,6 +739,7 @@ static void ssl_proceed_handshake(struct
 
     while (do_next) {
         int ret, ecode;
+        apr_status_t status;
 
         ret = SSL_do_handshake(c->ssl);
         ecode = SSL_get_error(c->ssl, ret);
@@ -825,7 +827,9 @@ static void ssl_proceed_handshake(struct
         case SSL_ERROR_SSL:
         case SSL_ERROR_SYSCALL:
             /* Unexpected result */
-            BIO_printf(bio_err, "SSL handshake failed (%d).\n", ecode);
+            status = apr_get_netos_error();
+            BIO_printf(bio_err, "SSL handshake failed (%d): %s\n", ecode,
+                    apr_psprintf(c->ctx, "%pm", &status));
             ERR_print_errors(bio_err);
             close_connection(c);
             do_next = 0;
@@ -1406,6 +1410,7 @@ static void start_connect(struct connect
     c->cbx = 0;
     c->gotheader = 0;
     c->rwrite = 0;
+    c->keptalive = 0;
     if (c->ctx) {
         apr_pool_clear(c->ctx);
     }
@@ -1528,9 +1533,10 @@ static void start_connect(struct connect
 
 static void close_connection(struct connection * c)
 {
-    if (c->read == 0 && c->keepalive) {
+    if (c->read == 0 && c->keptalive) {
         /*
          * server has legitimately shut down an idle keep alive request
+         * as per RFC7230 6.3.1.
          */
         if (good)
             good--;     /* connection never happened */
@@ -1851,6 +1857,8 @@ read_more:
         /* zero connect time with keep-alive */
         c->start = c->connect = lasttime = apr_time_now();
 
+        c->keptalive++;
+
         write_request(c);
     }
 }