[MAJOR] implement autonomous inter-socket forwarding

If an analyser sets buf->to_forward to a given value, that many
data will be forwarded between the two stream interfaces attached
to a buffer without waking the task up. The same applies once all
analysers have been released. This saves a large amount of calls
to process_session() and a number of task_dequeue/queue.
diff --git a/include/common/defaults.h b/include/common/defaults.h
index 05628e1..acba5c6 100644
--- a/include/common/defaults.h
+++ b/include/common/defaults.h
@@ -2,8 +2,8 @@
   include/common/defaults.h
   Miscellaneous default values.
 
-  Copyright (C) 2000-2007 Willy Tarreau - w@1wt.eu
-  
+  Copyright (C) 2000-2008 Willy Tarreau - w@1wt.eu
+
   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Lesser General Public
   License as published by the Free Software Foundation, version 2.1
@@ -40,6 +40,16 @@
 #define MAXREWRITE      (BUFSIZE / 2)
 #endif
 
+/* FORWARD_DEFAULT_SIZE
+ * Indicates how many bytes may be forwarded at once in low-level stream-socks
+ * without waking the owner task up. This should be much larger than the buffer
+ * size. A few megabytes seem appropriate.
+ */
+#ifndef FORWARD_DEFAULT_SIZE
+#define FORWARD_DEFAULT_SIZE (16*1024*1024)
+#endif
+
+
 #define REQURI_LEN      1024
 #define CAPTURE_LEN     64
 
diff --git a/include/proto/buffers.h b/include/proto/buffers.h
index 6442796..ab0de11 100644
--- a/include/proto/buffers.h
+++ b/include/proto/buffers.h
@@ -46,6 +46,7 @@
 static inline void buffer_init(struct buffer *buf)
 {
 	buf->send_max = 0;
+	buf->to_forward = 0;
 	buf->l = buf->total = 0;
 	buf->analysers = 0;
 	buf->cons = NULL;
@@ -92,6 +93,7 @@
 static inline void buffer_flush(struct buffer *buf)
 {
 	buf->send_max = 0;
+	buf->to_forward = 0;
 	buf->r = buf->lr = buf->w = buf->data;
 	buf->l = 0;
 	buf->flags |= BF_EMPTY | BF_FULL;
diff --git a/include/types/buffers.h b/include/types/buffers.h
index d8f7118..f15d33d 100644
--- a/include/types/buffers.h
+++ b/include/types/buffers.h
@@ -130,6 +130,7 @@
 	char *r, *w, *lr;               /* read ptr, write ptr, last read */
 	char *rlim;                     /* read limit, used for header rewriting */
 	unsigned int send_max;          /* number of bytes the sender can consume */
+	unsigned int to_forward;        /* number of bytes that can send without a wake-up, >= send_max */
 	unsigned int analysers;         /* bit field indicating what to do on the buffer */
 	int analyse_exp;                /* expiration date for current analysers (if set) */
 	void (*hijacker)(struct session *, struct buffer *); /* alternative content producer */