]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: http: remove the pointer to the error snapshot in http_capture_bad_message()
authorWilly Tarreau <w@1wt.eu>
Fri, 7 Sep 2018 16:01:03 +0000 (18:01 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 7 Sep 2018 16:36:04 +0000 (18:36 +0200)
It's not needed anymore as we know the side thanks to the channel. This
will allow the proxy generic code to better manage the error snapshots.

include/proto/proto_http.h
src/proto_http.c

index 49cb501e416c59b0577776db34ed893971ba1e02..7849e154887adde35431e79b71e01f5c34124025 100644 (file)
@@ -99,7 +99,7 @@ int http_transform_header_str(struct stream* s, struct http_msg *msg, const char
 void inet_set_tos(int fd, const struct sockaddr_storage *from, int tos);
 void http_perform_server_redirect(struct stream *s, struct stream_interface *si);
 void http_return_srv_error(struct stream *s, struct stream_interface *si);
-void http_capture_bad_message(struct proxy *proxy, struct error_snapshot *es, struct stream *s,
+void http_capture_bad_message(struct proxy *proxy, struct stream *s,
                               struct http_msg *msg,
                              enum h1_state state, struct proxy *other_end);
 unsigned int http_get_hdr(const struct http_msg *msg, const char *hname, int hlen,
index a94fb699c8716b007f50246f43bdebb8417eef32..e848a34344c9de71f2c0075750bd072b2c59ea96 100644 (file)
@@ -1738,7 +1738,7 @@ int http_wait_for_request(struct stream *s, struct channel *req, int an_bit)
 
                        /* we cannot return any message on error */
                        if (msg->err_pos >= 0) {
-                               http_capture_bad_message(sess->fe, &sess->fe->invalid_req, s, msg, msg->err_state, sess->fe);
+                               http_capture_bad_message(sess->fe, s, msg, msg->err_state, sess->fe);
                                stream_inc_http_err_ctr(s);
                        }
 
@@ -1771,7 +1771,7 @@ int http_wait_for_request(struct stream *s, struct channel *req, int an_bit)
 
                        /* read timeout : give up with an error message. */
                        if (msg->err_pos >= 0) {
-                               http_capture_bad_message(sess->fe, &sess->fe->invalid_req, s, msg, msg->err_state, sess->fe);
+                               http_capture_bad_message(sess->fe, s, msg, msg->err_state, sess->fe);
                                stream_inc_http_err_ctr(s);
                        }
                        txn->status = 408;
@@ -1803,7 +1803,7 @@ int http_wait_for_request(struct stream *s, struct channel *req, int an_bit)
                                goto failed_keep_alive;
 
                        if (msg->err_pos >= 0)
-                               http_capture_bad_message(sess->fe, &sess->fe->invalid_req, s, msg, msg->err_state, sess->fe);
+                               http_capture_bad_message(sess->fe, s, msg, msg->err_state, sess->fe);
                        txn->status = 400;
                        msg->err_state = msg->msg_state;
                        msg->msg_state = HTTP_MSG_ERROR;
@@ -1896,7 +1896,7 @@ int http_wait_for_request(struct stream *s, struct channel *req, int an_bit)
         * to block on that, so we have to capture it now.
         */
        if (unlikely(msg->err_pos >= 0))
-               http_capture_bad_message(sess->fe, &sess->fe->invalid_req, s, msg, msg->err_state, sess->fe);
+               http_capture_bad_message(sess->fe, s, msg, msg->err_state, sess->fe);
 
        /*
         * 1: identify the method
@@ -2200,7 +2200,7 @@ int http_wait_for_request(struct stream *s, struct channel *req, int an_bit)
                /* we detected a parsing error. We want to archive this request
                 * in the dedicated proxy area for later troubleshooting.
                 */
-               http_capture_bad_message(sess->fe, &sess->fe->invalid_req, s, msg, msg->err_state, sess->fe);
+               http_capture_bad_message(sess->fe, s, msg, msg->err_state, sess->fe);
        }
 
        txn->req.err_state = txn->req.msg_state;
@@ -3703,7 +3703,7 @@ int http_process_req_common(struct stream *s, struct channel *req, int an_bit, s
                /* we detected a parsing error. We want to archive this request
                 * in the dedicated proxy area for later troubleshooting.
                 */
-               http_capture_bad_message(sess->fe, &sess->fe->invalid_req, s, msg, msg->err_state, sess->fe);
+               http_capture_bad_message(sess->fe, s, msg, msg->err_state, sess->fe);
        }
 
        txn->req.err_state = txn->req.msg_state;
@@ -4054,7 +4054,7 @@ int http_process_request(struct stream *s, struct channel *req, int an_bit)
                /* we detected a parsing error. We want to archive this request
                 * in the dedicated proxy area for later troubleshooting.
                 */
-               http_capture_bad_message(sess->fe, &sess->fe->invalid_req, s, msg, msg->err_state, sess->fe);
+               http_capture_bad_message(sess->fe, s, msg, msg->err_state, sess->fe);
        }
 
        txn->req.err_state = txn->req.msg_state;
@@ -4997,7 +4997,7 @@ int http_request_forward_body(struct stream *s, struct channel *req, int an_bit)
                                goto aborted_xfer;
                        }
                        if (msg->err_pos >= 0)
-                               http_capture_bad_message(sess->fe, &sess->fe->invalid_req, s, msg, msg->err_state, s->be);
+                               http_capture_bad_message(sess->fe, s, msg, msg->err_state, s->be);
                        goto return_bad_req;
                }
                return 1;
@@ -5238,7 +5238,7 @@ int http_wait_for_response(struct stream *s, struct channel *rep, int an_bit)
                         */
                hdr_response_bad:
                        if (msg->msg_state == HTTP_MSG_ERROR || msg->err_pos >= 0)
-                               http_capture_bad_message(s->be, &s->be->invalid_rep, s, msg, msg->err_state, sess->fe);
+                               http_capture_bad_message(s->be, s, msg, msg->err_state, sess->fe);
 
                        HA_ATOMIC_ADD(&s->be->be_counters.failed_resp, 1);
                        if (objt_server(s->target)) {
@@ -5271,7 +5271,7 @@ int http_wait_for_response(struct stream *s, struct channel *rep, int an_bit)
                /* read error */
                else if (rep->flags & CF_READ_ERROR) {
                        if (msg->err_pos >= 0)
-                               http_capture_bad_message(s->be, &s->be->invalid_rep, s, msg, msg->err_state, sess->fe);
+                               http_capture_bad_message(s->be, s, msg, msg->err_state, sess->fe);
                        else if (txn->flags & TX_NOT_FIRST)
                                goto abort_keep_alive;
 
@@ -5309,7 +5309,7 @@ int http_wait_for_response(struct stream *s, struct channel *rep, int an_bit)
                /* read timeout : return a 504 to the client. */
                else if (rep->flags & CF_READ_TIMEOUT) {
                        if (msg->err_pos >= 0)
-                               http_capture_bad_message(s->be, &s->be->invalid_rep, s, msg, msg->err_state, sess->fe);
+                               http_capture_bad_message(s->be, s, msg, msg->err_state, sess->fe);
 
                        HA_ATOMIC_ADD(&s->be->be_counters.failed_resp, 1);
                        if (objt_server(s->target)) {
@@ -5357,7 +5357,7 @@ int http_wait_for_response(struct stream *s, struct channel *rep, int an_bit)
                /* close from server, capture the response if the server has started to respond */
                else if (rep->flags & CF_SHUTR) {
                        if (msg->msg_state >= HTTP_MSG_RPVER || msg->err_pos >= 0)
-                               http_capture_bad_message(s->be, &s->be->invalid_rep, s, msg, msg->err_state, sess->fe);
+                               http_capture_bad_message(s->be, s, msg, msg->err_state, sess->fe);
                        else if (txn->flags & TX_NOT_FIRST)
                                goto abort_keep_alive;
 
@@ -5384,7 +5384,7 @@ int http_wait_for_response(struct stream *s, struct channel *rep, int an_bit)
                /* write error to client (we don't send any message then) */
                else if (rep->flags & CF_WRITE_ERROR) {
                        if (msg->err_pos >= 0)
-                               http_capture_bad_message(s->be, &s->be->invalid_rep, s, msg, msg->err_state, sess->fe);
+                               http_capture_bad_message(s->be, s, msg, msg->err_state, sess->fe);
                        else if (txn->flags & TX_NOT_FIRST)
                                goto abort_keep_alive;
 
@@ -5412,7 +5412,7 @@ int http_wait_for_response(struct stream *s, struct channel *rep, int an_bit)
         */
 
        if (unlikely(msg->err_pos >= 0))
-               http_capture_bad_message(s->be, &s->be->invalid_rep, s, msg, msg->err_state, sess->fe);
+               http_capture_bad_message(s->be, s, msg, msg->err_state, sess->fe);
 
        /*
         * 1: get the status code
@@ -6191,7 +6191,7 @@ int http_response_forward_body(struct stream *s, struct channel *res, int an_bit
                                goto aborted_xfer;
                        }
                        if (msg->err_pos >= 0)
-                               http_capture_bad_message(s->be, &s->be->invalid_rep, s, msg, msg->err_state, strm_fe(s));
+                               http_capture_bad_message(s->be, s, msg, msg->err_state, strm_fe(s));
                        goto return_bad_res;
                }
                return 1;
@@ -6504,10 +6504,10 @@ http_msg_forward_chunked_body(struct stream *s, struct http_msg *msg)
   chunk_parsing_error:
        if (msg->err_pos >= 0) {
                if (chn->flags & CF_ISRESP)
-                       http_capture_bad_message(s->be, &s->be->invalid_rep, s, msg,
+                       http_capture_bad_message(s->be, s, msg,
                                                 msg->msg_state, strm_fe(s));
                else
-                       http_capture_bad_message(strm_fe(s), &strm_fe(s)->invalid_req, s,
+                       http_capture_bad_message(strm_fe(s), s,
                                                 msg, msg->msg_state, s->be);
        }
   error:
@@ -8029,9 +8029,10 @@ void http_show_error_snapshot(struct buffer *out, const struct error_snapshot *e
  * By default it tries to report the error position as msg->err_pos. However if
  * this one is not set, it will then report msg->next, which is the last known
  * parsing point. The function is able to deal with wrapping buffers. It always
- * displays buffers as a contiguous area starting at buf->p.
+ * displays buffers as a contiguous area starting at buf->p. The direction is
+ * determined thanks to the channel's flags.
  */
-void http_capture_bad_message(struct proxy *proxy, struct error_snapshot *es, struct stream *s,
+void http_capture_bad_message(struct proxy *proxy, struct stream *s,
                               struct http_msg *msg,
                              enum h1_state state, struct proxy *other_end)
 {
@@ -8052,7 +8053,7 @@ void http_capture_bad_message(struct proxy *proxy, struct error_snapshot *es, st
        if (ofs < 0)
                ofs = 0;
 
-       proxy_capture_error(proxy, es == &proxy->invalid_rep,
+       proxy_capture_error(proxy, !!(msg->chn->flags & CF_ISRESP),
                            other_end, s->target,
                            strm_sess(s), &msg->chn->buf,
                            ofs, co_data(msg->chn),