dovecot-2.0: anvil: Fixed checking what the master connection is.

dovecot at dovecot.org dovecot at dovecot.org
Thu Jun 4 19:45:47 EEST 2009


details:   http://hg.dovecot.org/dovecot-2.0/rev/cab8f8009456
changeset: 9440:cab8f8009456
user:      Timo Sirainen <tss at iki.fi>
date:      Thu Jun 04 12:44:37 2009 -0400
description:
anvil: Fixed checking what the master connection is.

diffstat:

3 files changed, 9 insertions(+), 4 deletions(-)
src/anvil/anvil-connection.c |    6 ++++--
src/anvil/anvil-connection.h |    2 +-
src/anvil/main.c             |    5 ++++-

diffs (71 lines):

diff -r 03ef1dd538fe -r cab8f8009456 src/anvil/anvil-connection.c
--- a/src/anvil/anvil-connection.c	Wed Jun 03 17:23:24 2009 -0400
+++ b/src/anvil/anvil-connection.c	Thu Jun 04 12:44:37 2009 -0400
@@ -27,6 +27,7 @@ struct anvil_connection {
 
 	unsigned int version_received:1;
 	unsigned int handshaked:1;
+	unsigned int master:1;
 };
 
 struct anvil_connection *anvil_connections = NULL;
@@ -73,7 +74,7 @@ anvil_connection_request(struct anvil_co
 			*error_r = "KILL: Not enough parameters";
 			return -1;
 		}
-		if (conn->fd != MASTER_LISTEN_FD_FIRST) {
+		if (!conn->master) {
 			*error_r = "KILL sent by a non-master connection";
 			return -1;
 		}
@@ -134,7 +135,7 @@ static void anvil_connection_input(void 
 	}
 }
 
-struct anvil_connection *anvil_connection_create(int fd)
+struct anvil_connection *anvil_connection_create(int fd, bool master)
 {
 	struct anvil_connection *conn;
 
@@ -143,6 +144,7 @@ struct anvil_connection *anvil_connectio
 	conn->input = i_stream_create_fd(fd, MAX_INBUF_SIZE, FALSE);
 	conn->output = o_stream_create_fd(fd, (size_t)-1, FALSE);
 	conn->io = io_add(fd, IO_READ, anvil_connection_input, conn);
+	conn->master = master;
 	DLLIST_PREPEND(&anvil_connections, conn);
 	return conn;
 }
diff -r 03ef1dd538fe -r cab8f8009456 src/anvil/anvil-connection.h
--- a/src/anvil/anvil-connection.h	Wed Jun 03 17:23:24 2009 -0400
+++ b/src/anvil/anvil-connection.h	Thu Jun 04 12:44:37 2009 -0400
@@ -1,7 +1,7 @@
 #ifndef ANVIL_CONNECTION_H
 #define ANVIL_CONNECTION_H
 
-struct anvil_connection *anvil_connection_create(int fd);
+struct anvil_connection *anvil_connection_create(int fd, bool master);
 void anvil_connection_destroy(struct anvil_connection *conn);
 
 void anvil_connections_destroy_all(void);
diff -r 03ef1dd538fe -r cab8f8009456 src/anvil/main.c
--- a/src/anvil/main.c	Wed Jun 03 17:23:24 2009 -0400
+++ b/src/anvil/main.c	Thu Jun 04 12:44:37 2009 -0400
@@ -4,6 +4,7 @@
 #include "array.h"
 #include "env-util.h"
 #include "master-service.h"
+#include "master-interface.h"
 #include "connect-limit.h"
 #include "anvil-connection.h"
 
@@ -14,7 +15,9 @@ struct connect_limit *connect_limit;
 
 static void client_connected(const struct master_service_connection *conn)
 {
-	anvil_connection_create(conn->fd);
+	bool master = conn->listen_fd == MASTER_LISTEN_FD_FIRST;
+
+	anvil_connection_create(conn->fd, master);
 }
 
 int main(int argc, char *argv[])


More information about the dovecot-cvs mailing list