[MAJOR] rework of the server FSM
srv_state has been removed from HTTP state machines, and states
have been split in either TCP states or analyzers. For instance,
the TARPIT state has just become a simple analyzer.
New flags have been added to the struct buffer to compensate this.
The high-level stream processors sometimes need to force a disconnection
without touching a file-descriptor (eg: report an error). But if
they touched BF_SHUTW or BF_SHUTR, the file descriptor would not
be closed. Thus, the two SHUT?_NOW flags have been added so that
an application can request a forced close which the stream interface
will be forced to obey.
During this change, a new BF_HIJACK flag was added. It will
be used for data generation, eg during a stats dump. It
prevents the producer on a buffer from sending data into it.
BF_SHUTR_NOW /* the producer must shut down for reads ASAP */
BF_SHUTW_NOW /* the consumer must shut down for writes ASAP */
BF_HIJACK /* the producer is temporarily replaced */
BF_SHUTW_NOW has precedence over BF_HIJACK. BF_HIJACK has
precedence over BF_MAY_FORWARD (so that it does not need it).
New functions buffer_shutr_now(), buffer_shutw_now(), buffer_abort()
are provided to manipulate BF_SHUT* flags.
A new type "stream_interface" has been added to describe both
sides of a buffer. A stream interface has states and error
reporting. The session now has two stream interfaces (one per
side). Each buffer has stream_interface pointers to both
consumer and producer sides.
The server-side file descriptor has moved to its stream interface,
so that even the buffer has access to it.
process_srv() has been split into three parts :
- tcp_get_connection() obtains a connection to the server
- tcp_connection_failed() tests if a previously attempted
connection has succeeded or not.
- process_srv_data() only manages the data phase, and in
this sense should be roughly equivalent to process_cli.
Little code has been removed, and a lot of old code has been
left in comments for now.
diff --git a/include/types/buffers.h b/include/types/buffers.h
index f516ffe..6374271 100644
--- a/include/types/buffers.h
+++ b/include/types/buffers.h
@@ -57,6 +57,15 @@
#define BF_READ_TIMEOUT 32768 /* timeout while waiting for producer */
#define BF_WRITE_TIMEOUT 65536 /* timeout while waiting for consumer */
+/* When either BF_SHUTR_NOW or BF_HIJACK is set, it is strictly forbidden for
+ * the stream interface to alter the buffer contents. When BF_SHUTW_NOW is set,
+ * it is strictly forbidden for the stream interface to send anything from the
+ * buffer.
+ */
+#define BF_SHUTR_NOW 131072 /* the producer must shut down for reads ASAP */
+#define BF_SHUTW_NOW 262144 /* the consumer must shut down for writes ASAP */
+#define BF_HIJACK 524288 /* the producer is temporarily replaced */
+
/* Analysers (buffer->analysers).
* Those bits indicate that there are some processing to do on the buffer
@@ -68,7 +77,8 @@
#define AN_REQ_INSPECT 0x00000001 /* inspect request contents */
#define AN_REQ_HTTP_HDR 0x00000002 /* inspect HTTP request headers */
#define AN_REQ_HTTP_BODY 0x00000004 /* inspect HTTP request body */
-#define AN_RTR_HTTP_HDR 0x00000008 /* inspect HTTP response headers */
+#define AN_REQ_HTTP_TARPIT 0x00000008 /* wait for end of HTTP tarpit */
+#define AN_RTR_HTTP_HDR 0x00000010 /* inspect HTTP response headers */
/* describes a chunk of string */
struct chunk {
@@ -91,6 +101,8 @@
unsigned char xfer_large; /* number of consecutive large xfers */
unsigned char xfer_small; /* number of consecutive small xfers */
unsigned long long total; /* total data read */
+ struct stream_interface *prod; /* producer attached to this buffer */
+ struct stream_interface *cons; /* consumer attached to this buffer */
char data[BUFSIZE];
};