dovecot-2.2: Added several asserts to make sure duplicates aren'...

dovecot at dovecot.org dovecot at dovecot.org
Fri Jun 13 12:16:02 UTC 2014


details:   http://hg.dovecot.org/dovecot-2.2/rev/f6e2fa1afa45
changeset: 17489:f6e2fa1afa45
user:      Timo Sirainen <tss at iki.fi>
date:      Fri Jun 13 15:14:44 2014 +0300
description:
Added several asserts to make sure duplicates aren't inserted into hash table.
The previous commit hopefully fixed the problem causing auth and login
processes to sometimes die with "key not found from hash" error, but if not
maybe one of these will catch it.

diffstat:

 src/lib-auth/auth-server-connection.c |  1 +
 src/lib-master/master-auth.c          |  1 +
 src/lib-master/master-login-auth.c    |  1 +
 src/lib-settings/settings-parser.c    |  3 +++
 src/login-common/ssl-proxy-openssl.c  |  1 +
 5 files changed, 7 insertions(+), 0 deletions(-)

diffs (71 lines):

diff -r 1fcaa7d0b35e -r f6e2fa1afa45 src/lib-auth/auth-server-connection.c
--- a/src/lib-auth/auth-server-connection.c	Fri Jun 13 15:13:26 2014 +0300
+++ b/src/lib-auth/auth-server-connection.c	Fri Jun 13 15:14:44 2014 +0300
@@ -476,6 +476,7 @@
 		/* wrapped - ID 0 not allowed */
 		id = ++conn->client->request_id_counter;
 	}
+	i_assert(hash_table_lookup(conn->requests, POINTER_CAST(id)) == NULL);
 	hash_table_insert(conn->requests, POINTER_CAST(id), request);
 	return id;
 }
diff -r 1fcaa7d0b35e -r f6e2fa1afa45 src/lib-master/master-auth.c
--- a/src/lib-master/master-auth.c	Fri Jun 13 15:13:26 2014 +0300
+++ b/src/lib-master/master-auth.c	Fri Jun 13 15:14:44 2014 +0300
@@ -211,6 +211,7 @@
 			       master_auth_connection_timeout, conn);
 	conn->io = io_add(conn->fd, IO_READ,
 			  master_auth_connection_input, conn);
+	i_assert(hash_table_lookup(auth->connections, POINTER_CAST(req.tag)) == NULL);
 	hash_table_insert(auth->connections, POINTER_CAST(req.tag), conn);
 	*tag_r = req.tag;
 }
diff -r 1fcaa7d0b35e -r f6e2fa1afa45 src/lib-master/master-login-auth.c
--- a/src/lib-master/master-login-auth.c	Fri Jun 13 15:13:26 2014 +0300
+++ b/src/lib-master/master-login-auth.c	Fri Jun 13 15:14:44 2014 +0300
@@ -483,6 +483,7 @@
 	memcpy(login_req->cookie, req->cookie, sizeof(login_req->cookie));
 	login_req->callback = callback;
 	login_req->context = context;
+	i_assert(hash_table_lookup(auth->requests, POINTER_CAST(id)) == NULL);
 	hash_table_insert(auth->requests, POINTER_CAST(id), login_req);
 	DLLIST2_APPEND(&auth->request_head, &auth->request_tail, login_req);
 
diff -r 1fcaa7d0b35e -r f6e2fa1afa45 src/lib-settings/settings-parser.c
--- a/src/lib-settings/settings-parser.c	Fri Jun 13 15:13:26 2014 +0300
+++ b/src/lib-settings/settings-parser.c	Fri Jun 13 15:14:44 2014 +0300
@@ -143,6 +143,7 @@
 		new_link->change_array = carr;
 		new_link->set_struct = new_set;
 		new_link->change_struct = new_changes;
+		i_assert(hash_table_lookup(ctx->links, full_key) == NULL);
 		hash_table_insert(ctx->links, full_key, new_link);
 
 		info.defaults = children[i];
@@ -524,6 +525,7 @@
 	link = p_new(ctx->parser_pool, struct setting_link, 1);
 	*link = *link_copy;
 	link->full_key = key;
+	i_assert(hash_table_lookup(ctx->links, key) == NULL);
 	hash_table_insert(ctx->links, key, link);
 
 	if (link->info->struct_size != 0)
@@ -1744,6 +1746,7 @@
 		}
 		i_assert(i < count);
 	}
+	i_assert(hash_table_lookup(links, old_link) == NULL);
 	hash_table_insert(links, old_link, new_link);
 	return new_link;
 }
diff -r 1fcaa7d0b35e -r f6e2fa1afa45 src/login-common/ssl-proxy-openssl.c
--- a/src/login-common/ssl-proxy-openssl.c	Fri Jun 13 15:13:26 2014 +0300
+++ b/src/login-common/ssl-proxy-openssl.c	Fri Jun 13 15:14:44 2014 +0300
@@ -1318,6 +1318,7 @@
 	if (ctx->verify_client_cert)
 		ssl_proxy_ctx_verify_client(ctx->ctx, xnames);
 
+	i_assert(hash_table_lookup(ssl_servers, ctx) == NULL);
 	hash_table_insert(ssl_servers, ctx, ctx);
 	return ctx;
 }


More information about the dovecot-cvs mailing list