MEDIUM: connection: extract the send_proxy callback from proto_tcp
This handshake handler must be independant, so move it away from
proto_tcp. It has a dedicated connection flag. It is tested before
I/O handlers and automatically removes the CO_FL_WAIT_L4_CONN flag
upon success.
It also sets the BF_WRITE_NULL flag on the stream interface and
stops the SI timeout. However it does not perform the task_wakeup(),
and relies on the data handler to do so for now. The SI wakeup will
have to be moved elsewhere anyway.
diff --git a/src/connection.c b/src/connection.c
index 089ad89..c30e739 100644
--- a/src/connection.c
+++ b/src/connection.c
@@ -14,7 +14,8 @@
#include <common/config.h>
#include <types/connection.h>
-#include <types/stream_interface.h>
+
+#include <proto/stream_interface.h>
/* I/O callback for fd-based connections. It calls the read/write handlers
* provided by the connection's sock_ops, which must be valid. It returns
@@ -26,22 +27,26 @@
int ret = 0;
if (!conn)
- return ret;
+ goto leave;
if (conn->flags & CO_FL_ERROR)
- return ret;
+ goto leave;
+
+ if (conn->flags & CO_FL_SI_SEND_PROXY)
+ if ((ret = conn_si_send_proxy(conn, CO_FL_SI_SEND_PROXY)))
+ goto leave;
if (fdtab[fd].ev & (FD_POLL_IN | FD_POLL_HUP | FD_POLL_ERR))
if (!conn->data->read(fd))
ret |= FD_WAIT_READ;
if (conn->flags & CO_FL_ERROR)
- return ret;
+ goto leave;
if (fdtab[fd].ev & (FD_POLL_OUT | FD_POLL_ERR))
if (!conn->data->write(fd))
ret |= FD_WAIT_WRITE;
-
+ leave:
/* remove the events before leaving */
fdtab[fd].ev &= ~(FD_POLL_IN | FD_POLL_OUT | FD_POLL_HUP | FD_POLL_ERR);
return ret;