[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [obfsproxy/master] Fix a bug in counting n_conns



commit e536ae192ef9c9d75a5bcdd170067b7466ede93e
Author: Nick Mathewson <nickm@xxxxxxxxxxxxxx>
Date:   Thu Jul 14 11:39:33 2011 -0400

    Fix a bug in counting n_conns
---
 src/network.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/src/network.c b/src/network.c
index 605e13d..8b19418 100644
--- a/src/network.c
+++ b/src/network.c
@@ -181,6 +181,11 @@ simple_listener_cb(struct evconnlistener *evcl,
   listener_t *lsn = arg;
   struct event_base *base;
   conn_t *conn = calloc(1, sizeof(conn_t));
+
+  n_connections++; /* If we call conn_free() later on error, it will decrement
+                    * n_connections.  Therefore, we had better increment it at
+                    * the start. */
+
   if (!conn)
     goto err;
 
@@ -260,7 +265,6 @@ simple_listener_cb(struct evconnlistener *evcl,
   /* add conn to the linked list of connections */
   if (dll_append(&conn_list, &conn->dll_node)<0)
     goto err;
-  n_connections++;
 
   log_debug("Connection setup completed. "
             "We currently have %d connections!", n_connections);

_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits