dovecot-2.2: connection: Added support for creating a stream fro...

dovecot at dovecot.org dovecot at dovecot.org
Sat Apr 19 09:28:40 UTC 2014


details:   http://hg.dovecot.org/dovecot-2.2/rev/54178ae78835
changeset: 17246:54178ae78835
user:      Stephan Bosch <stephan at rename-it.nl>
date:      Sat Apr 19 11:23:18 2014 +0200
description:
connection: Added support for creating a stream from input/output stream pair.

diffstat:

 src/lib/connection.c |  36 ++++++++++++++++++++++++++++++++++++
 src/lib/connection.h |   3 +++
 2 files changed, 39 insertions(+), 0 deletions(-)

diffs (59 lines):

diff -r 6c3bd941e153 -r 54178ae78835 src/lib/connection.c
--- a/src/lib/connection.c	Sat Apr 19 11:21:47 2014 +0200
+++ b/src/lib/connection.c	Sat Apr 19 11:23:18 2014 +0200
@@ -198,6 +198,42 @@
 	list->connections_count++;
 }
 
+void connection_init_from_streams(struct connection_list *list,
+			    struct connection *conn, const char *name,
+			    struct istream *input, struct ostream *output)
+{
+	i_assert(name != NULL);
+
+	conn->list = list;
+	conn->name = i_strdup(name);
+	conn->fd_in = i_stream_get_fd(input);
+	conn->fd_out = o_stream_get_fd(output);
+
+	i_assert(conn->fd_in >= 0);
+	i_assert(conn->fd_out >= 0);
+	i_assert(conn->io == NULL);
+	i_assert(conn->input == NULL);
+	i_assert(conn->output == NULL);
+	i_assert(conn->to == NULL);
+
+	conn->input = input;
+	i_stream_ref(conn->input);
+	i_stream_set_name(conn->input, conn->name);
+
+	conn->output = output;
+	o_stream_ref(conn->output);
+	o_stream_set_no_error_handling(conn->output, TRUE);
+	o_stream_set_name(conn->output, conn->name);
+
+	conn->io = io_add(conn->fd_in, IO_READ, *list->v.input, conn);
+	
+	DLLIST_PREPEND(&list->connections, conn);
+	list->connections_count++;
+
+	if (list->v.client_connected != NULL)
+		list->v.client_connected(conn, TRUE);
+}
+
 static void connection_ip_connected(struct connection *conn)
 {
 	io_remove(&conn->io);
diff -r 6c3bd941e153 -r 54178ae78835 src/lib/connection.h
--- a/src/lib/connection.h	Sat Apr 19 11:21:47 2014 +0200
+++ b/src/lib/connection.h	Sat Apr 19 11:23:18 2014 +0200
@@ -100,6 +100,9 @@
 			       const struct ip_addr *ip, unsigned int port);
 void connection_init_client_unix(struct connection_list *list,
 				 struct connection *conn, const char *path);
+void connection_init_from_streams(struct connection_list *list,
+			    struct connection *conn, const char *name,
+			    struct istream *input, struct ostream *output);
 
 int connection_client_connect(struct connection *conn);
 


More information about the dovecot-cvs mailing list