[tor-commits] [stegotorus/master] Don't allow connection count to grow without limit in HTTP steg.
zwol at torproject.org
zwol at torproject.org
Fri Jul 20 23:17:08 UTC 2012
commit 83648b9054337c6276077a342c7d7653a9daafca
Author: Zack Weinberg <zackw at cmu.edu>
Date: Mon Jul 16 15:04:12 2012 -0700
Don't allow connection count to grow without limit in HTTP steg.
The fix involves two complementary changes: (1) restore the upper
limit of 64 outstanding downstream connections per circuit; (2) HTTP
steg needs to call ->cease_transmission() and ->expect_close() on its
connections at the right times (for now, unconditionally; in the
future, paying attention to the HTTP "Connection:" header).
---
src/protocol/chop.cc | 3 ++-
src/steg/http.cc | 13 ++++++++++++-
src/steg/jsSteg.cc | 2 --
src/steg/pdfSteg.cc | 2 --
src/steg/swfSteg.cc | 3 ---
5 files changed, 14 insertions(+), 9 deletions(-)
diff --git a/src/protocol/chop.cc b/src/protocol/chop.cc
index bb4a95c..3059c1b 100644
--- a/src/protocol/chop.cc
+++ b/src/protocol/chop.cc
@@ -479,7 +479,8 @@ chop_circuit_t::send()
// reopening new connections. If we're the server, we have to
// just twiddle our thumbs and hope the client does that.
if (no_target_connection) {
- if (config->mode != LSN_SIMPLE_SERVER)
+ if (config->mode != LSN_SIMPLE_SERVER &&
+ downstreams.size() < 64)
circuit_reopen_downstreams(this);
else
circuit_arm_axe_timer(this, axe_interval());
diff --git a/src/steg/http.cc b/src/steg/http.cc
index 7caf2e7..381258c 100644
--- a/src/steg/http.cc
+++ b/src/steg/http.cc
@@ -588,7 +588,13 @@ http_steg_t::transmit(struct evbuffer *source)
break;
}
- if (rval == 0) have_transmitted = 1;
+ if (rval == 0) {
+ have_transmitted = 1;
+ // FIXME: should decide whether or not to do this based on the
+ // Connection: header. (Needs additional changes elsewhere, esp.
+ // in transmit_room.)
+ conn->cease_transmission();
+ }
return rval;
}
}
@@ -671,6 +677,11 @@ http_server_receive(http_steg_t *s, conn_t *conn, struct evbuffer *dest, struct
s->have_received = 1;
s->type = type;
+ // FIXME: should decide whether or not to do this based on the
+ // Connection: header. (Needs additional changes elsewhere, esp.
+ // in transmit_room.)
+ conn->expect_close();
+
conn->transmit_soon(100);
return RECV_GOOD;
}
diff --git a/src/steg/jsSteg.cc b/src/steg/jsSteg.cc
index dbe4431..3954829 100644
--- a/src/steg/jsSteg.cc
+++ b/src/steg/jsSteg.cc
@@ -893,8 +893,6 @@ http_server_JS_transmit (payloads& pl, struct evbuffer *source, conn_t *conn,
evbuffer_drain(source, sbuflen);
free(outbuf2);
- conn->cease_transmission();
- // downcast_steg(s)->have_transmitted = 1;
return 0;
}
diff --git a/src/steg/pdfSteg.cc b/src/steg/pdfSteg.cc
index f76da99..8bff423 100644
--- a/src/steg/pdfSteg.cc
+++ b/src/steg/pdfSteg.cc
@@ -464,8 +464,6 @@ http_server_PDF_transmit(payloads &pl, struct evbuffer *source,
}
evbuffer_drain(source, sbuflen);
-
- conn->cease_transmission();
return 0;
}
diff --git a/src/steg/swfSteg.cc b/src/steg/swfSteg.cc
index 8fb29ee..8e12d21 100644
--- a/src/steg/swfSteg.cc
+++ b/src/steg/swfSteg.cc
@@ -152,9 +152,6 @@ http_server_SWF_transmit(payloads& pl, struct evbuffer *source, conn_t *conn)
return -1;
}
-
- conn->cease_transmission();
-
free(inbuf);
free(outbuf);
return 0;
More information about the tor-commits
mailing list