]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: http-ana: Use -1 status for client aborts during queuing and connect
authorChristopher Faulet <cfaulet@haproxy.com>
Wed, 2 Jun 2021 12:07:24 +0000 (14:07 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Wed, 2 Jun 2021 15:17:34 +0000 (17:17 +0200)
When a client aborts while the session is in the queue or during the connect
stage, instead of reporting a 503-Service-Unavailable error in logs, -1
status is used. It means -1 status is now reported with 'CC' and 'CQ'
termination state.

Indeed, when a client aborts before the server connection is established,
there is no reason to report a 503 because nothing is sent to the
server. And in this case, because it is a client abort, it is useless to
send any response to the client. Thus -1 status is approriate. This status
is used in log messages when the connection is closed and no response is
sent.

This patch should fix the issue #1266.

src/http_ana.c

index 0a1af6d887a9d7aa31a7abbc7d3be7098086fc6a..be0f7471198c9517a3cf620d18b5be03be347dad 100644 (file)
@@ -4799,33 +4799,42 @@ void http_return_srv_error(struct stream *s, struct stream_interface *si)
        int err_type = si->err_type;
 
        /* set s->txn->status for http_error_message(s) */
-       s->txn->status = 503;
-
-       if (err_type & SI_ET_QUEUE_ABRT)
-               http_server_error(s, si, SF_ERR_CLICL, SF_FINST_Q,
-                                 http_error_message(s));
-       else if (err_type & SI_ET_CONN_ABRT)
-               http_server_error(s, si, SF_ERR_CLICL, SF_FINST_C,
-                                 (s->txn->flags & TX_NOT_FIRST) ? NULL :
-                                 http_error_message(s));
-       else if (err_type & SI_ET_QUEUE_TO)
+       if (err_type & SI_ET_QUEUE_ABRT) {
+               s->txn->status = -1;
+               http_server_error(s, si, SF_ERR_CLICL, SF_FINST_Q, NULL);
+       }
+       else if (err_type & SI_ET_CONN_ABRT) {
+               s->txn->status = -1;
+               http_server_error(s, si, SF_ERR_CLICL, SF_FINST_C, NULL);
+       }
+       else if (err_type & SI_ET_QUEUE_TO) {
+               s->txn->status = 503;
                http_server_error(s, si, SF_ERR_SRVTO, SF_FINST_Q,
                                  http_error_message(s));
-       else if (err_type & SI_ET_QUEUE_ERR)
+       }
+       else if (err_type & SI_ET_QUEUE_ERR) {
+               s->txn->status = 503;
                http_server_error(s, si, SF_ERR_SRVCL, SF_FINST_Q,
                                  http_error_message(s));
-       else if (err_type & SI_ET_CONN_TO)
+       }
+       else if (err_type & SI_ET_CONN_TO) {
+               s->txn->status = 503;
                http_server_error(s, si, SF_ERR_SRVTO, SF_FINST_C,
                                  (s->txn->flags & TX_NOT_FIRST) ? NULL :
                                  http_error_message(s));
-       else if (err_type & SI_ET_CONN_ERR)
+       }
+       else if (err_type & SI_ET_CONN_ERR) {
+               s->txn->status = 503;
                http_server_error(s, si, SF_ERR_SRVCL, SF_FINST_C,
                                  (s->flags & SF_SRV_REUSED) ? NULL :
                                  http_error_message(s));
-       else if (err_type & SI_ET_CONN_RES)
+       }
+       else if (err_type & SI_ET_CONN_RES) {
+               s->txn->status = 503;
                http_server_error(s, si, SF_ERR_RESOURCE, SF_FINST_C,
                                  (s->txn->flags & TX_NOT_FIRST) ? NULL :
                                  http_error_message(s));
+       }
        else { /* SI_ET_CONN_OTHER and others */
                s->txn->status = 500;
                http_server_error(s, si, SF_ERR_INTERNAL, SF_FINST_C,