]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
lay a trap for situations where we connection_free something
authorRoger Dingledine <arma@torproject.org>
Mon, 31 Jan 2005 00:33:32 +0000 (00:33 +0000)
committerRoger Dingledine <arma@torproject.org>
Mon, 31 Jan 2005 00:33:32 +0000 (00:33 +0000)
that's still on one of the lists.

in particular, this will detect situations where we mark-for-close
and then free it ourselves.

svn:r3475

src/or/connection.c
src/or/main.c
src/or/or.h

index 7aa6fc5d9c3024a9585667a555b0e9bcf5df6cc8..59da957ccbbf8de576f889dee676820158b1faf9 100644 (file)
@@ -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);
index edcc0a8dc238c7f45f5744345815f480999bd1d5..cd3768c5ee52bbb9104b172e14b4b40e6e441e45 100644 (file)
@@ -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;
index bdc880df69aa0298502394987dee2c4a8594ac6a..443b57b2bb486c9e72ed82498643be7835373246 100644 (file)
@@ -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);