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

[tor-commits] [obfsproxy/master] Actual solution to bug5072



commit c52bf0c5c047bdfddf01c1d3e2772c5b0687f69a
Author: Nick Mathewson <nickm@xxxxxxxxxxxxxx>
Date:   Sat Feb 11 11:24:03 2012 -0500

    Actual solution to bug5072
    
    When we were setting the flush callback on bev_flush, we were passing
    the wrong conn_t as the argument.
---
 src/network.c |   15 ++++++++-------
 1 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/src/network.c b/src/network.c
index b9bcbb0..27eb2ee 100644
--- a/src/network.c
+++ b/src/network.c
@@ -768,6 +768,7 @@ static void
 error_or_eof(conn_t *conn)
 {
   circuit_t *circ = conn->circuit;
+  conn_t *conn_flush;
   struct bufferevent *bev_err = conn->buffer;
   struct bufferevent *bev_flush;
 
@@ -778,8 +779,9 @@ error_or_eof(conn_t *conn)
     return;
   }
 
-  bev_flush = (conn == circ->upstream) ? circ->downstream->buffer
-                                       : circ->upstream->buffer;
+  conn_flush = (conn == circ->upstream) ? circ->downstream
+                                        : circ->upstream;
+  bev_flush = conn_flush->buffer;
   if (evbuffer_get_length(bufferevent_get_output(bev_flush)) == 0) {
     conn_free(conn);
     return;
@@ -792,11 +794,10 @@ error_or_eof(conn_t *conn)
   bufferevent_disable(bev_err, EV_READ|EV_WRITE);
   bufferevent_setcb(bev_err, NULL, NULL, flush_error_cb, conn);
 
-  /* XXX Dirty access to bufferevent guts.  There appears to be no
-     official API to retrieve the callback functions and/or change
-     just one callback while leaving the others intact. */
-  bufferevent_setcb(bev_flush, bev_flush->readcb,
-                    conn_free_on_flush, flush_error_cb, conn);
+  /* We can ignore any data that arrives; we should free the connection
+   * when we're done flushing */
+  bufferevent_setcb(bev_flush, NULL,
+                    conn_free_on_flush, flush_error_cb, conn_flush);
 }
 
 /**

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