[MAJOR] migrate the connection logic to stream interface

The connection setup code has been refactored in order to
make it run only on low level (stream interface). Several
complicated functions have been removed from backend.c,
and we now have sess_update_stream_int() to manage
an assigned connection, sess_prepare_conn_req() to assign a
server to a connection request, perform_http_redirect() to
redirect instead of connecting to server, and return_srv_error()
to return connection error status messages.

The stream_interface status changes are checked before adjusting
buffer flags, so that the buffers can be informed about this lower
level update.

A new connection is initiated by changing si->state from SI_ST_INI
to SI_ST_REQ.

The code seems to work but is awfully dirty. Some functions need
to be moved, and the layering is not yet quite clear.

A lot of dead old code has simply been removed.
diff --git a/include/proto/backend.h b/include/proto/backend.h
index aa27654..4d37c71 100644
--- a/include/proto/backend.h
+++ b/include/proto/backend.h
@@ -2,7 +2,7 @@
   include/proto/backend.h
   Functions prototypes for the backend.
 
-  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
@@ -33,8 +33,6 @@
 int assign_server_address(struct session *s);
 int assign_server_and_queue(struct session *s);
 int connect_server(struct session *s);
-int srv_count_retry_down(struct session *t, int conn_err);
-int srv_retryable_connect(struct session *t);
 int srv_redispatch_connect(struct session *t);
 int backend_parse_balance(const char **args, char *err,
 			  int errlen, struct proxy *curproxy);
diff --git a/include/proto/buffers.h b/include/proto/buffers.h
index 73999ce..36a82d8 100644
--- a/include/proto/buffers.h
+++ b/include/proto/buffers.h
@@ -111,7 +111,7 @@
 /* marks the buffer as "shutdown" ASAP for reads */
 static inline void buffer_shutr_now(struct buffer *buf)
 {
-	buf->flags |= BF_SHUTR_NOW;
+	buf->flags |= BF_SHUTR_NOW | BF_SHUTR;
 }
 
 /* marks the buffer as "shutdown" ASAP for writes */
@@ -123,7 +123,7 @@
 /* marks the buffer as "shutdown" ASAP in both directions */
 static inline void buffer_abort(struct buffer *buf)
 {
-	buf->flags |= BF_SHUTR_NOW | BF_SHUTW_NOW;
+	buf->flags |= BF_SHUTR_NOW | BF_SHUTR | BF_SHUTW_NOW;
 }
 
 /* set the buffer to hijacking mode */
diff --git a/include/types/stream_interface.h b/include/types/stream_interface.h
index ba1a36d..9e5e4d9 100644
--- a/include/types/stream_interface.h
+++ b/include/types/stream_interface.h
@@ -32,7 +32,8 @@
  * interface is performing some retries (eg: connection error).
  */
 enum {
-	SI_ST_INI = 0,           /* interface not initialized yet and might not exist */
+	SI_ST_INI = 0,           /* interface not sollicitated yet */
+	SI_ST_REQ,               /* connection initiation desired and not started yet */
 	SI_ST_QUE,               /* interface waiting in queue */
 	SI_ST_TAR,               /* interface in turn-around state after failed connect attempt */
 	SI_ST_ASS,               /* server just assigned to this interface */