changeset 9864:5b36fa967538 HEAD

lib-master: Fixes to handling FIFO connections. Also expose the FIFOness to caller.
author Timo Sirainen <tss@iki.fi>
date Fri, 04 Sep 2009 13:45:33 -0400
parents 3e20e23154e0
children c90ba3f3fa51
files src/lib-master/master-service.c src/lib-master/master-service.h
diffstat 2 files changed, 8 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-master/master-service.c	Fri Sep 04 12:38:00 2009 -0400
+++ b/src/lib-master/master-service.c	Fri Sep 04 13:45:33 2009 -0400
@@ -499,13 +499,12 @@
 		}
 		/* it's not a socket. probably a fifo. use the "listener"
 		   as the connection fd and stop the listener. */
-		io_remove(&l->io);
-		conn.fd = dup(l->fd);
+		conn.fd = l->fd;
 		conn.listen_fd = l->fd;
-		if (conn.fd == -1) {
-			i_error("dup() failed: %m");
-			return;
-		}
+		conn.fifo = TRUE;
+
+		io_remove(&l->io);
+		l->fd = -1;
 	}
 	conn.ssl = l->ssl;
 	net_set_nonblock(conn.fd, TRUE);
@@ -547,7 +546,7 @@
 	for (i = 0; i < service->socket_count; i++) {
 		struct master_service_listener *l = &service->listeners[i];
 
-		if (l->io == NULL) {
+		if (l->io == NULL && l->fd != -1) {
 			l->io = io_add(MASTER_LISTEN_FD_FIRST + i, IO_READ,
 				       master_service_listen, l);
 		}
--- a/src/lib-master/master-service.h	Fri Sep 04 12:38:00 2009 -0400
+++ b/src/lib-master/master-service.h	Fri Sep 04 13:45:33 2009 -0400
@@ -23,7 +23,8 @@
 	struct ip_addr remote_ip;
 	unsigned int remote_port;
 
-	bool ssl;
+	unsigned int fifo:1;
+	unsigned int ssl:1;
 };
 
 typedef void