changeset 17489:f6e2fa1afa45

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.
author Timo Sirainen <tss@iki.fi>
date Fri, 13 Jun 2014 15:14:44 +0300
parents 1fcaa7d0b35e
children d2ecee775c1f
files src/lib-auth/auth-server-connection.c src/lib-master/master-auth.c src/lib-master/master-login-auth.c src/lib-settings/settings-parser.c src/login-common/ssl-proxy-openssl.c
diffstat 5 files changed, 7 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- 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;
 }
--- 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;
 }
--- 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);
 
--- 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;
 }
--- 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;
 }