[tor-commits] [obfsproxy/master] Don't poke connections or circuits after connect_hostname().

asn at torproject.org asn at torproject.org
Wed Mar 28 21:17:24 UTC 2012


commit 70e6947c81e7c0f42c94e837fdabec271b876567
Author: George Kadianakis <desnacked at riseup.net>
Date:   Mon Mar 19 17:10:06 2012 -0700

    Don't poke connections or circuits after connect_hostname().
    
    bufferevent_socket_connect_hostname() might fail immediately, and take
    the whole circuit with it (since pending_socks_cb() and error_or_eof()
    will be called). This means that we should not play with conn_t or
    circuit_t after calling bufferevent_socket_connect_hostname().
---
 src/network.c |   11 ++++++-----
 1 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/src/network.c b/src/network.c
index 219593f..1d73249 100644
--- a/src/network.c
+++ b/src/network.c
@@ -648,6 +648,12 @@ socks_read_cb(struct bufferevent *bev, void *arg)
       }
 
       bufferevent_setcb(newconn->buffer, downstream_read_cb, NULL, pending_socks_cb, newconn);
+      bufferevent_enable(newconn->buffer, EV_READ|EV_WRITE);
+
+      /* further upstream data will be processed once the downstream
+         side is established */
+      bufferevent_disable(conn->buffer, EV_READ|EV_WRITE);
+
       if (bufferevent_socket_connect_hostname(newconn->buffer, get_evdns_base(),
                                               af, addr, port) < 0) {
         log_warn("%s: outbound connection to %s:%u failed: %s",
@@ -656,11 +662,6 @@ socks_read_cb(struct bufferevent *bev, void *arg)
         conn_free(conn);
         return;
       }
-      bufferevent_enable(newconn->buffer, EV_READ|EV_WRITE);
-
-      /* further upstream data will be processed once the downstream
-         side is established */
-      bufferevent_disable(conn->buffer, EV_READ|EV_WRITE);
       return;
     }
 





More information about the tor-commits mailing list