On Mon, Mar 28, 2011 at 01:50:58PM -0400, Roy Smith wrote:
> OK, this looks like it works. I still need to do something smarter
> about generating the unique ids (some combination of hostid, pid, and
> time, and counter should do it), and adding a way to control this from
> the config file. Before I get too deep into this, does the following
> patch (against haproxy-1.4.11) look reasonable for the basics?
almost, see below :
> --- a/src/proto_http.c Sat Mar 26 12:38:10 2011 -0400
> +++ b/src/proto_http.c Mon Mar 28 13:41:04 2011 -0400
> @@ -2713,6 +2713,19 @@
> /* transfer length unknown*/
> txn->flags &= ~TX_REQ_XFER_LEN;
>
> + /* 4b: Insert header for tracing, if needed */
> + ctx.idx = 0;
> + {
> + const char hdr[] = "X-Unique-Id";
> + const size_t hdr_len = sizeof(hdr);
> + if (! http_find_header(hdr, msg->sol, &txn->hdr_idx, &ctx)) {
> + static int id_counter = 0;
> + char hdr_val[hdr_len + sizeof(": 1234567890") + 1];
Here, either you use sizeof("") or you use strlen("") + 1, but your
array is larger than you need as is (it's harmless).
...
> + snprintf(hdr_val, sizeof(hdr_val), "%s: %d", hdr,
> id_counter++);
> + http_header_add_tail(req, &txn->req, &txn->hdr_idx,
> hdr_val);
> + }
> + }
> +
> /* 5: we may need to capture headers */
> if (unlikely((s->logs.logwait & LW_REQHDR) && s->fe->req_cap))
> capture_headers(msg->sol, &txn->hdr_idx,
> @@ -2757,7 +2770,6 @@
> */
>
> use_close_only = 0;
> - ctx.idx = 0;
You must not remove this line otherwise the lookup for next headers below
will only start from the first header found above.
> /* set TE_CHNK and XFER_LEN only if "chunked" is seen last */
> while ((txn->flags & TX_REQ_VER_11) &&
> http_find_header2("Transfer-Encoding", 17, msg->sol,
> &txn->hdr_idx, &ctx)) {
Regards,
Willy