]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
[DEBUG] add an http_silent_debug function to debug HTTP states
authorWilly Tarreau <w@1wt.eu>
Mon, 4 Jan 2010 20:13:14 +0000 (21:13 +0100)
committerWilly Tarreau <w@1wt.eu>
Mon, 4 Jan 2010 20:13:14 +0000 (21:13 +0100)
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

index 3cb8bd0143e3e85222a32fd25fa933d2bb29cfbf..da0a8a83f79a96c50e59877899ee445e26d703b6 100644 (file)
@@ -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 <b>, just before the last
  * CRLF. Text length is measured first, so it cannot be NULL.