[tor-commits] [tor/maint-0.2.3] Fix (Open?)BSD fast-connect bug with optimistic data.
nickm at torproject.org
nickm at torproject.org
Mon Jun 10 16:26:06 UTC 2013
commit 77a193533966c5c2f81e6a85b3c2a7446076508f
Author: Nick Mathewson <nickm at torproject.org>
Date: Mon Jun 10 12:14:49 2013 -0400
Fix (Open?)BSD fast-connect bug with optimistic data.
There's an assertion failure that can occur if a connection has
optimistic data waiting, and then the connect() call returns 0 on the
first attempt (rather than -1 and EINPROGRESS). That latter behavior
from connect() appears to be an (Open?)BSDism when dealing with remote
addresses in some cases. (At least, I've only seen it reported with
the BSDs under libevent, even when the address was 127.0.0.1. And
we've only seen this problem in Tor with OpenBSD.)
Fixes bug 9017; bugfix on 0.2.3.1-alpha, which first introduced
optimistic data. (Although you could also argue that the commented-out
connection_start_writing in 155c9b80 back in 2002 is the real source
of the issue.)
---
changes/bug9017 | 6 ++++++
src/or/connection_edge.c | 11 ++++++-----
2 files changed, 12 insertions(+), 5 deletions(-)
diff --git a/changes/bug9017 b/changes/bug9017
new file mode 100644
index 0000000..359c526
--- /dev/null
+++ b/changes/bug9017
@@ -0,0 +1,6 @@
+ o Major bugfixes:
+ - Avoid an assertion failure on OpenBSD (and perhaps other BSDs)
+ when an exit connection with optimistic data succeeds immediately
+ rather than returning EINPROGRESS. Fixes bug 9017; bugfix on
+ 0.2.3.1-alpha.
+
diff --git a/src/or/connection_edge.c b/src/or/connection_edge.c
index 9563ca6..362ad9a 100644
--- a/src/or/connection_edge.c
+++ b/src/or/connection_edge.c
@@ -3302,12 +3302,13 @@ connection_exit_connect(edge_connection_t *edge_conn)
conn->state = EXIT_CONN_STATE_OPEN;
if (connection_get_outbuf_len(conn)) {
- /* in case there are any queued data cells */
- log_warn(LD_BUG,"newly connected conn had data waiting!");
-// connection_start_writing(conn);
+ /* in case there are any queued data cells, from e.g. optimistic data */
+ IF_HAS_NO_BUFFEREVENT(conn)
+ connection_watch_events(conn, READ_EVENT|WRITE_EVENT);
+ } else {
+ IF_HAS_NO_BUFFEREVENT(conn)
+ connection_watch_events(conn, READ_EVENT);
}
- IF_HAS_NO_BUFFEREVENT(conn)
- connection_watch_events(conn, READ_EVENT);
/* also, deliver a 'connected' cell back through the circuit. */
if (connection_edge_is_rendezvous_stream(edge_conn)) {
More information about the tor-commits
mailing list