MEDIUM: connection: get rid of data->init() which was not for data

The ->init() callback of the connection's data layer was only used to
complete the session's initialisation since sessions and streams were
split apart in 1.6. The problem is that it creates a big confusion in
the layers' roles as the session has to register a dummy data layer
when waiting for a handshake to complete, then hand it off to the
stream which will replace it.

The real need is to notify that the transport has finished initializing.
This should enable a better splitting between these layers.

This patch thus introduces a connection-specific callback called
xprt_done_cb() which informs about handshake successes or failures. With
this, data->init() can disappear, CO_FL_INIT_DATA as well, and we don't
need to register a dummy data->wake() callback to be notified of errors.
diff --git a/src/connection.c b/src/connection.c
index 564c976..54bbc07 100644
--- a/src/connection.c
+++ b/src/connection.c
@@ -86,12 +86,14 @@
 	if (!(conn->flags & CO_FL_POLL_SOCK))
 		__conn_sock_stop_both(conn);
 
-	/* The data layer might not be ready yet (eg: when using embryonic
-	 * sessions). If we're about to move data, we must initialize it first.
-	 * The function may fail and cause the connection to be destroyed, thus
-	 * we must not use it anymore and should immediately leave instead.
+	/* The connection owner might want to be notified about an end of
+	 * handshake indicating the connection is ready, before we proceed with
+	 * any data exchange. The callback may fail and cause the connection to
+	 * be destroyed, thus we must not use it anymore and should immediately
+	 * leave instead. The caller must immediately unregister itself once
+	 * called.
 	 */
-	if ((conn->flags & CO_FL_INIT_DATA) && conn->data->init(conn) < 0)
+	if (conn->xprt_done_cb && conn->xprt_done_cb(conn) < 0)
 		return;
 
 	if (conn->xprt && fd_send_ready(fd) &&
@@ -137,6 +139,16 @@
 	if (unlikely(!(conn->flags & (CO_FL_WAIT_L4_CONN | CO_FL_WAIT_L6_CONN | CO_FL_CONNECTED))))
 		conn->flags |= CO_FL_CONNECTED;
 
+	/* The connection owner might want to be notified about failures to
+	 * complete the handshake. The callback may fail and cause the
+	 * connection to be destroyed, thus we must not use it anymore and
+	 * should immediately leave instead. The caller must immediately
+	 * unregister itself once called.
+	 */
+	if (((conn->flags ^ flags) & CO_FL_NOTIFY_DONE) &&
+	    conn->xprt_done_cb && conn->xprt_done_cb(conn) < 0)
+		return;
+
 	/* The wake callback is normally used to notify the data layer about
 	 * data layer activity (successful send/recv), connection establishment,
 	 * shutdown and fatal errors. We need to consider the following