dovecot-2.2: connection API: Track the number of connections.

dovecot at dovecot.org dovecot at dovecot.org
Tue Oct 23 12:59:46 EEST 2012


details:   http://hg.dovecot.org/dovecot-2.2/rev/acd76b5272e9
changeset: 15234:acd76b5272e9
user:      Timo Sirainen <tss at iki.fi>
date:      Tue Oct 23 12:59:41 2012 +0300
description:
connection API: Track the number of connections.

diffstat:

 src/lib/connection.c |  6 ++++++
 src/lib/connection.h |  1 +
 2 files changed, 7 insertions(+), 0 deletions(-)

diffs (48 lines):

diff -r f417cab3a21f -r acd76b5272e9 src/lib/connection.c
--- a/src/lib/connection.c	Tue Oct 23 12:34:42 2012 +0300
+++ b/src/lib/connection.c	Tue Oct 23 12:59:41 2012 +0300
@@ -163,6 +163,7 @@
 	connection_init_streams(conn);
 
 	DLLIST_PREPEND(&list->connections, conn);
+	list->connections_count++;
 }
 
 void connection_init_client_ip(struct connection_list *list,
@@ -179,6 +180,7 @@
 	conn->port = port;
 
 	DLLIST_PREPEND(&list->connections, conn);
+	list->connections_count++;
 }
 
 void connection_init_client_unix(struct connection_list *list,
@@ -191,6 +193,7 @@
 	conn->name = i_strdup(path);
 
 	DLLIST_PREPEND(&list->connections, conn);
+	list->connections_count++;
 }
 
 static void connection_ip_connected(struct connection *conn)
@@ -253,6 +256,9 @@
 
 void connection_deinit(struct connection *conn)
 {
+	i_assert(conn->list->connections_count > 0);
+
+	conn->list->connections_count--;
 	DLLIST_REMOVE(&conn->list->connections, conn);
 
 	connection_disconnect(conn);
diff -r f417cab3a21f -r acd76b5272e9 src/lib/connection.h
--- a/src/lib/connection.h	Tue Oct 23 12:34:42 2012 +0300
+++ b/src/lib/connection.h	Tue Oct 23 12:59:41 2012 +0300
@@ -85,6 +85,7 @@
 
 struct connection_list {
 	struct connection *connections;
+	unsigned int connections_count;
 
 	struct connection_settings set;
 	struct connection_vfuncs v;


More information about the dovecot-cvs mailing list