dovecot-2.0: Idle-disconnecting auth master connections is now o...

dovecot at dovecot.org dovecot at dovecot.org
Wed Dec 16 03:27:14 EET 2009


details:   http://hg.dovecot.org/dovecot-2.0/rev/3907cc4ecc4b
changeset: 10497:3907cc4ecc4b
user:      Timo Sirainen <tss at iki.fi>
date:      Tue Dec 15 20:27:07 2009 -0500
description:
Idle-disconnecting auth master connections is now optional. LMTP no longer does it.

diffstat:

6 files changed, 28 insertions(+), 12 deletions(-)
src/doveadm/doveadm-auth.c             |    2 +-
src/lib-auth/auth-master.c             |   14 ++++++++------
src/lib-auth/auth-master.h             |    9 ++++++++-
src/lib-storage/mail-storage-service.c |    8 ++++++--
src/lib-storage/mail-storage-service.h |    4 +++-
src/lmtp/main.c                        |    3 ++-

diffs (148 lines):

diff -r eb5795c49550 -r 3907cc4ecc4b src/doveadm/doveadm-auth.c
--- a/src/doveadm/doveadm-auth.c	Tue Dec 15 20:19:53 2009 -0500
+++ b/src/doveadm/doveadm-auth.c	Tue Dec 15 20:27:07 2009 -0500
@@ -34,7 +34,7 @@ cmd_user_input(const char *auth_socket_p
 
 	pool = pool_alloconly_create("auth master lookup", 1024);
 
-	conn = auth_master_init(auth_socket_path, FALSE);
+	conn = auth_master_init(auth_socket_path, 0);
 	ret = auth_master_user_lookup(conn, input->username, &input->info,
 				      pool, &username, &fields);
 	if (ret < 0)
diff -r eb5795c49550 -r 3907cc4ecc4b src/lib-auth/auth-master.c
--- a/src/lib-auth/auth-master.c	Tue Dec 15 20:19:53 2009 -0500
+++ b/src/lib-auth/auth-master.c	Tue Dec 15 20:27:07 2009 -0500
@@ -27,6 +27,7 @@
 
 struct auth_master_connection {
 	char *auth_socket_path;
+	enum auth_master_flags flags;
 
 	int fd;
 	struct ioloop *ioloop;
@@ -42,7 +43,6 @@ struct auth_master_connection {
 			       void *context);
 	void *reply_context;
 
-	unsigned int debug:1;
 	unsigned int sent_handshake:1;
 	unsigned int handshaked:1;
 	unsigned int aborted:1;
@@ -69,14 +69,14 @@ static void auth_input(struct auth_maste
 static void auth_input(struct auth_master_connection *conn);
 
 struct auth_master_connection *
-auth_master_init(const char *auth_socket_path, bool debug)
+auth_master_init(const char *auth_socket_path, enum auth_master_flags flags)
 {
 	struct auth_master_connection *conn;
 
 	conn = i_new(struct auth_master_connection, 1);
 	conn->auth_socket_path = i_strdup(auth_socket_path);
 	conn->fd = -1;
-	conn->debug = debug;
+	conn->flags = flags;
 	conn->prefix = DEFAULT_USERDB_LOOKUP_PREFIX;
 	return conn;
 }
@@ -167,7 +167,7 @@ static bool auth_lookup_reply_callback(c
 		ctx->fields = p_new(ctx->pool, const char *, len + 1);
 		for (i = 0; i < len; i++)
 			ctx->fields[i] = p_strdup(ctx->pool, args[i]);
-		if (ctx->conn->debug)
+		if ((ctx->conn->flags & AUTH_MASTER_FLAG_DEBUG) != 0)
 			i_debug("auth input: %s", t_strarray_join(args, " "));
 	}
 	return TRUE;
@@ -302,8 +302,10 @@ static void auth_master_unset_io(struct 
 	o_stream_unref(&conn->output);
 	io_loop_destroy(&conn->ioloop);
 
-	conn->to = timeout_add(1000*AUTH_MASTER_IDLE_SECS,
-			       auth_idle_timeout, conn);
+	if ((conn->flags & AUTH_MASTER_FLAG_NO_IDLE_TIMEOUT) == 0) {
+		conn->to = timeout_add(1000*AUTH_MASTER_IDLE_SECS,
+				       auth_idle_timeout, conn);
+	}
 }
 
 static bool is_valid_string(const char *str)
diff -r eb5795c49550 -r 3907cc4ecc4b src/lib-auth/auth-master.h
--- a/src/lib-auth/auth-master.h	Tue Dec 15 20:19:53 2009 -0500
+++ b/src/lib-auth/auth-master.h	Tue Dec 15 20:27:07 2009 -0500
@@ -2,6 +2,13 @@
 #define AUTH_MASTER_H
 
 #include "network.h"
+
+enum auth_master_flags {
+	/* Enable logging debug information */
+	AUTH_MASTER_FLAG_DEBUG			= 0x01,
+	/* Don't disconnect from auth socket when idling */
+	AUTH_MASTER_FLAG_NO_IDLE_TIMEOUT	= 0x02
+};
 
 struct auth_user_info {
 	const char *service;
@@ -17,7 +24,7 @@ struct auth_user_reply {
 };
 
 struct auth_master_connection *
-auth_master_init(const char *auth_socket_path, bool debug);
+auth_master_init(const char *auth_socket_path, enum auth_master_flags flags);
 void auth_master_deinit(struct auth_master_connection **conn);
 
 /* Do a USER lookup. Returns -1 = error, 0 = user not found, 1 = ok */
diff -r eb5795c49550 -r 3907cc4ecc4b src/lib-storage/mail-storage-service.c
--- a/src/lib-storage/mail-storage-service.c	Tue Dec 15 20:19:53 2009 -0500
+++ b/src/lib-storage/mail-storage-service.c	Tue Dec 15 20:27:07 2009 -0500
@@ -630,6 +630,7 @@ mail_storage_service_first_init(struct m
 				const struct mail_user_settings *user_set)
 {
 	const struct mail_storage_settings *mail_set;
+	enum auth_master_flags flags = 0;
 
 	i_assert(ctx->conn == NULL);
 
@@ -637,8 +638,11 @@ mail_storage_service_first_init(struct m
 						MAIL_STORAGE_SET_DRIVER_NAME);
 	ctx->debug = mail_set->mail_debug;
 
-	ctx->conn = auth_master_init(user_set->auth_socket_path,
-				     ctx->debug);
+	if (ctx->debug)
+		flags |= AUTH_MASTER_FLAG_DEBUG;
+	if ((ctx->flags & MAIL_STORAGE_SERVICE_FLAG_NO_IDLE_TIMEOUT) != 0)
+		flags |= AUTH_MASTER_FLAG_NO_IDLE_TIMEOUT;
+	ctx->conn = auth_master_init(user_set->auth_socket_path, flags);
 
 	i_assert(mail_user_auth_master_conn == NULL);
 	mail_user_auth_master_conn = ctx->conn;
diff -r eb5795c49550 -r 3907cc4ecc4b src/lib-storage/mail-storage-service.h
--- a/src/lib-storage/mail-storage-service.h	Tue Dec 15 20:19:53 2009 -0500
+++ b/src/lib-storage/mail-storage-service.h	Tue Dec 15 20:27:07 2009 -0500
@@ -24,7 +24,9 @@ enum mail_storage_service_flags {
 	/* Don't initialize logging or change log prefixes */
 	MAIL_STORAGE_SERVICE_NO_LOG_INIT		= 0x80,
 	/* Don't load plugins in _service_lookup() */
-	MAIL_STORAGE_SERVICE_NO_PLUGINS			= 0x100
+	MAIL_STORAGE_SERVICE_NO_PLUGINS			= 0x100,
+	/* Don't close auth connections because of idling. */
+	MAIL_STORAGE_SERVICE_FLAG_NO_IDLE_TIMEOUT	= 0x200
 };
 
 struct mail_storage_service_input {
diff -r eb5795c49550 -r 3907cc4ecc4b src/lmtp/main.c
--- a/src/lmtp/main.c	Tue Dec 15 20:19:53 2009 -0500
+++ b/src/lmtp/main.c	Tue Dec 15 20:27:07 2009 -0500
@@ -57,7 +57,8 @@ int main(int argc, char *argv[])
 		MAIL_STORAGE_SERVICE_FLAG_DISALLOW_ROOT |
 		MAIL_STORAGE_SERVICE_FLAG_USERDB_LOOKUP |
 		MAIL_STORAGE_SERVICE_FLAG_TEMP_PRIV_DROP |
-		MAIL_STORAGE_SERVICE_NO_LOG_INIT;
+		MAIL_STORAGE_SERVICE_NO_LOG_INIT |
+		MAIL_STORAGE_SERVICE_FLAG_NO_IDLE_TIMEOUT;
 	int c;
 
 	if (IS_STANDALONE()) {


More information about the dovecot-cvs mailing list