From e988a79c740146ea0bc9acf9b67918533e632f1e Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Mon, 4 Jan 2010 21:13:14 +0100 Subject: [PATCH] [DEBUG] add an http_silent_debug function to debug HTTP states This function outputs to fd #-1 the status of request and response buffers, the transaction states, the stream interface states, etc... That way, it's easy to find that output in an strace report, correctly placed WRT the other syscalls. --- src/proto_http.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/proto_http.c b/src/proto_http.c index 3cb8bd014..da0a8a83f 100644 --- a/src/proto_http.c +++ b/src/proto_http.c @@ -360,6 +360,32 @@ const char http_is_ver_token[256] = { }; +/* + * Silent debug that outputs only in strace, using fd #-1. Trash is modified. + */ +#if defined(DEBUG_FSM) +static void http_silent_debug(int line, struct session *s) +{ + int size = 0; + size += snprintf(trash + size, sizeof(trash) - size, + "[%04d] req: p=%d(%d) s=%d bf=%08x an=%08x data=%p size=%d l=%d w=%p r=%p lr=%p sm=%d fw=%ld tf=%08x\n", + line, + s->si[0].state, s->si[0].fd, s->txn.req.msg_state, s->req->flags, s->req->analysers, + s->req->data, s->req->size, s->req->l, s->req->w, s->req->r, s->req->lr, s->req->send_max, s->req->to_forward, s->txn.flags); + write(-1, trash, size); + size = 0; + size += snprintf(trash + size, sizeof(trash) - size, + " %04d rep: p=%d(%d) s=%d bf=%08x an=%08x data=%p size=%d l=%d w=%p r=%p lr=%p sm=%d fw=%ld\n", + line, + s->si[1].state, s->si[1].fd, s->txn.rsp.msg_state, s->rep->flags, s->rep->analysers, + s->rep->data, s->rep->size, s->rep->l, s->rep->w, s->rep->r, s->rep->lr, s->rep->send_max, s->rep->to_forward); + + write(-1, trash, size); +} +#else +#define http_silent_debug(l,s) do { } while (0) +#endif + /* * Adds a header and its CRLF at the tail of buffer , just before the last * CRLF. Text length is measured first, so it cannot be NULL.