MEDIUM: stream-interface: provide a generic si_conn_send_cb callback

The connection send() callback is supposed to be generic for a
stream-interface, and consists in calling the lower layer snd_buf
function. Move this function to the stream interface and remove
the sock-raw and sock-ssl clones.
diff --git a/include/proto/stream_interface.h b/include/proto/stream_interface.h
index 844d925..8a4cf3a 100644
--- a/include/proto/stream_interface.h
+++ b/include/proto/stream_interface.h
@@ -41,6 +41,7 @@
 int stream_int_shutw(struct stream_interface *si);
 void stream_int_chk_rcv_conn(struct stream_interface *si);
 void stream_int_chk_snd_conn(struct stream_interface *si);
+void si_conn_send_cb(struct connection *conn);
 
 extern struct sock_ops stream_int_embedded;
 extern struct sock_ops stream_int_task;
diff --git a/src/sock_raw.c b/src/sock_raw.c
index e21177c..5b20f2f 100644
--- a/src/sock_raw.c
+++ b/src/sock_raw.c
@@ -44,7 +44,6 @@
 
 /* main event functions used to move data between sockets and buffers */
 static void sock_raw_read(struct connection *conn);
-static void sock_raw_write(struct connection *conn);
 static void sock_raw_read0(struct stream_interface *si);
 
 
@@ -593,38 +592,6 @@
 
 
 /*
- * This function is called on a write event from a stream socket.
- */
-static void sock_raw_write(struct connection *conn)
-{
-	struct stream_interface *si = container_of(conn, struct stream_interface, conn);
-	struct buffer *b = si->ob;
-
-#ifdef DEBUG_FULL
-	fprintf(stderr,"sock_raw_write : fd=%d, owner=%p\n", fd, fdtab[fd].owner);
-#endif
-
-	if (conn->flags & CO_FL_ERROR)
-		goto out_error;
-
-	/* we might have been called just after an asynchronous shutw */
-	if (b->flags & BF_SHUTW)
-		return;
-
-	if (conn_data_snd_buf(conn) < 0)
-		goto out_error;
-
-	/* OK all done */
-	return;
-
- out_error:
-	/* Write error on the connection, report the error and stop I/O */
-
-	conn->flags |= CO_FL_ERROR;
-	conn_data_stop_both(conn);
-}
-
-/*
  * This function propagates a null read received on a connection. It updates
  * the stream interface. If the stream interface has SI_FL_NOHALF, we also
  * forward the close to the write side.
@@ -681,7 +648,7 @@
 	.chk_rcv = stream_int_chk_rcv_conn,
 	.chk_snd = stream_int_chk_snd_conn,
 	.read    = sock_raw_read,
-	.write   = sock_raw_write,
+	.write   = si_conn_send_cb,
 	.snd_buf = sock_raw_write_loop,
 	.close   = NULL,
 };
diff --git a/src/stream_interface.c b/src/stream_interface.c
index 06a5d4e..6be0354 100644
--- a/src/stream_interface.c
+++ b/src/stream_interface.c
@@ -864,6 +864,40 @@
 	}
 }
 
+/*
+ * This is the callback which is called by the connection layer to send data
+ * from the buffer to the connection. It iterates over the data layer's snd_buf
+ * function.
+ */
+void si_conn_send_cb(struct connection *conn)
+{
+	struct stream_interface *si = container_of(conn, struct stream_interface, conn);
+	struct buffer *b = si->ob;
+
+	if (conn->flags & CO_FL_ERROR)
+		goto out_error;
+
+	if (si->conn.flags & CO_FL_HANDSHAKE)
+		/* a handshake was requested */
+		return;
+
+	/* we might have been called just after an asynchronous shutw */
+	if (b->flags & BF_SHUTW)
+		return;
+
+	/* OK there are data waiting to be sent */
+	if (conn_data_snd_buf(conn) < 0)
+		goto out_error;
+
+	/* OK all done */
+	return;
+
+ out_error:
+	/* Write error on the connection, report the error and stop I/O */
+	conn->flags |= CO_FL_ERROR;
+	conn_data_stop_both(conn);
+}
+
 
 /*
  * Local variables: