MEDIUM: connection: merge the send_proxy and local_send_proxy calls

We used to have two very similar functions for sending a PROXY protocol
line header. The reason is that the default one relies on the stream
interface to retrieve the other end's address, while the "local" one
performs a local address lookup and sends that instead (used by health
checks).

Now that the send_proxy_ofs is stored in the connection and not the
stream interface, we can make the local_send_proxy rely on it and
support partial sends. This also simplifies the code by removing the
local_send_proxy function, making health checks use send_proxy_ofs,
resulting in the removal of the CO_FL_LOCAL_SPROXY flag, and the
associated test in the connection handler. The other flag,
CO_FL_SI_SEND_PROXY was renamed without the "SI" part so that it
is clear that it is not dedicated anymore to a usage with a stream
interface.
diff --git a/src/connection.c b/src/connection.c
index 05cad01..75f876f 100644
--- a/src/connection.c
+++ b/src/connection.c
@@ -66,12 +66,8 @@
 			if (!conn_recv_proxy(conn, CO_FL_ACCEPT_PROXY))
 				goto leave;
 
-		if (conn->flags & CO_FL_SI_SEND_PROXY)
-			if (!conn_si_send_proxy(conn, CO_FL_SI_SEND_PROXY))
-				goto leave;
-
-		if (conn->flags & CO_FL_LOCAL_SPROXY)
-			if (!conn_local_send_proxy(conn, CO_FL_LOCAL_SPROXY))
+		if (conn->flags & CO_FL_SEND_PROXY)
+			if (!conn_si_send_proxy(conn, CO_FL_SEND_PROXY))
 				goto leave;
 #ifdef USE_OPENSSL
 		if (conn->flags & CO_FL_SSL_WAIT_HS)
@@ -535,82 +531,3 @@
 	}
 	return ret;
 }
-
-/* This callback is used to send a valid PROXY protocol line to a socket being
- * established from the local machine. It sets the protocol addresses to the
- * local and remote address. This is typically used with health checks or when
- * it is not possible to determine the other end's address. It returns 0 if it
- * fails in a fatal way or needs to poll to go further, otherwise it returns
- * non-zero and removes itself from the connection's flags (the bit is provided
- * in <flag> by the caller). It is designed to be called by the connection
- * handler and relies on it to commit polling changes. Note that this function
- * expects to be able to send the whole line at once, which should always be
- * possible since it is supposed to start at the first byte of the outgoing
- * data segment.
- */
-int conn_local_send_proxy(struct connection *conn, unsigned int flag)
-{
-	int ret;
-
-	/* we might have been called just after an asynchronous shutw */
-	if (conn->flags & CO_FL_SOCK_WR_SH)
-		goto out_error;
-
-	if (!(conn->flags & CO_FL_CTRL_READY))
-		goto out_error;
-
-	/* The target server expects a PROXY line to be sent first. Retrieving
-	 * local or remote addresses may fail until the connection is established.
-	 */
-	conn_get_from_addr(conn);
-	if (!(conn->flags & CO_FL_ADDR_FROM_SET))
-		goto out_wait;
-
-	conn_get_to_addr(conn);
-	if (!(conn->flags & CO_FL_ADDR_TO_SET))
-		goto out_wait;
-
-	trash.len = make_proxy_line(trash.str, trash.size, &conn->addr.from, &conn->addr.to);
-	if (!trash.len)
-		goto out_error;
-
-	/* we have to send the whole trash. If the data layer has a
-	 * pending write, we'll also set MSG_MORE.
-	 */
-	do {
-		ret = send(conn->t.sock.fd, trash.str, trash.len, (conn->flags & CO_FL_DATA_WR_ENA) ? MSG_MORE : 0);
-
-		if (ret == 0)
-			goto out_wait;
-
-		if (ret < 0) {
-			if (errno == EAGAIN || errno == ENOTCONN)
-				goto out_wait;
-			if (errno == EINTR)
-				continue;
-			conn->flags |= CO_FL_SOCK_RD_SH | CO_FL_SOCK_WR_SH;
-			goto out_error;
-		}
-	} while (0);
-
-	if (ret != trash.len)
-		goto out_error;
-
-	/* The connection is ready now, simply return and let the connection
-	 * handler notify upper layers if needed.
-	 */
-	if (conn->flags & CO_FL_WAIT_L4_CONN)
-		conn->flags &= ~CO_FL_WAIT_L4_CONN;
-	conn->flags &= ~flag;
-	return 1;
-
- out_error:
-	/* Write error on the file descriptor */
-	conn->flags |= CO_FL_ERROR;
-	return 0;
-
- out_wait:
-	__conn_sock_stop_recv(conn);
-	__conn_sock_poll_send(conn);
-	return 0;
-}