dovecot-2.2: lib-auth: auth_master_cache_flush() always waited f...

dovecot at dovecot.org dovecot at dovecot.org
Wed Oct 23 11:47:15 EEST 2013


details:   http://hg.dovecot.org/dovecot-2.2/rev/100a2c0ce5e8
changeset: 16866:100a2c0ce5e8
user:      Timo Sirainen <tss at iki.fi>
date:      Wed Oct 23 11:47:10 2013 +0300
description:
lib-auth: auth_master_cache_flush() always waited for timeout before finishing.

diffstat:

 src/lib-auth/auth-master.c |  25 +++++++++++++++++--------
 1 files changed, 17 insertions(+), 8 deletions(-)

diffs (59 lines):

diff -r 9c347c7faaf2 -r 100a2c0ce5e8 src/lib-auth/auth-master.c
--- a/src/lib-auth/auth-master.c	Wed Oct 23 11:40:26 2013 +0300
+++ b/src/lib-auth/auth-master.c	Wed Oct 23 11:47:10 2013 +0300
@@ -588,30 +588,38 @@
 	return ctx.return_value;
 }
 
+struct auth_master_cache_ctx {
+	struct auth_master_connection *conn;
+	unsigned int count;
+	bool failed;
+};
+
 static bool
 auth_cache_flush_reply_callback(const char *cmd, const char *const *args,
 				void *context)
 {
-	unsigned int *countp = context;
+	struct auth_master_cache_ctx *ctx = context;
 
 	if (strcmp(cmd, "OK") != 0)
-		*countp = UINT_MAX;
-	else if (args[0] == NULL || str_to_uint(args[0], countp) < 0)
-		*countp = UINT_MAX;
+		ctx->failed = TRUE;
+	else if (args[0] == NULL || str_to_uint(args[0], &ctx->count) < 0)
+		ctx->failed = TRUE;
 
-	io_loop_stop(current_ioloop);
+	io_loop_stop(ctx->conn->ioloop);
 	return TRUE;
 }
 
 int auth_master_cache_flush(struct auth_master_connection *conn,
 			    const char *const *users, unsigned int *count_r)
 {
+	struct auth_master_cache_ctx ctx;
 	string_t *str;
 
-	*count_r = UINT_MAX;
+	memset(&ctx, 0, sizeof(ctx));
+	ctx.conn = conn;
 
 	conn->reply_callback = auth_cache_flush_reply_callback;
-	conn->reply_context = count_r;
+	conn->reply_context = &ctx;
 
 	str = t_str_new(128);
 	str_printfa(str, "CACHE-FLUSH\t%u", auth_master_next_request_id(conn));
@@ -628,7 +636,8 @@
 	conn->prefix = DEFAULT_USERDB_LOOKUP_PREFIX;
 
 	conn->reply_context = NULL;
-	return *count_r == UINT_MAX ? -1 : 0;
+	*count_r = ctx.count;
+	return ctx.failed ? -1 : 0;
 }
 
 static bool


More information about the dovecot-cvs mailing list