diff options
-rw-r--r-- | src/or/connection.c | 2 | ||||
-rw-r--r-- | src/or/main.c | 5 | ||||
-rw-r--r-- | src/or/or.h | 1 |
3 files changed, 8 insertions, 0 deletions
diff --git a/src/or/connection.c b/src/or/connection.c index 7aa6fc5d9c..59da957ccb 100644 --- a/src/or/connection.c +++ b/src/or/connection.c @@ -143,6 +143,8 @@ connection_t *connection_new(int type) { void connection_free(connection_t *conn) { tor_assert(conn); tor_assert(conn->magic == CONNECTION_MAGIC); + tor_assert(!connection_in_array(conn)); + tor_assert(!connection_is_on_closeable_list(conn)); if (!connection_is_listener(conn)) { buf_free(conn->inbuf); diff --git a/src/or/main.c b/src/or/main.c index edcc0a8dc2..cd3768c5ee 100644 --- a/src/or/main.c +++ b/src/or/main.c @@ -206,6 +206,11 @@ add_connection_to_closeable_list(connection_t *conn) smartlist_add(closeable_connection_lst, conn); } +/** Return 1 if conn is on the closeable list, else return 0. */ +int connection_is_on_closeable_list(connection_t *conn) { + return smartlist_isin(closeable_connection_lst, conn); +} + /** Return true iff conn is in the current poll array. */ int connection_in_array(connection_t *conn) { int i; diff --git a/src/or/or.h b/src/or/or.h index bdc880df69..443b57b2bb 100644 --- a/src/or/or.h +++ b/src/or/or.h @@ -1393,6 +1393,7 @@ int connection_add(connection_t *conn); int connection_remove(connection_t *conn); int connection_in_array(connection_t *conn); void add_connection_to_closeable_list(connection_t *conn); +int connection_is_on_closeable_list(connection_t *conn); void get_connection_array(connection_t ***array, int *n); |