[or-cvs] [tor/master 12/38] Move the "stop writing when the buffer is empty" logic to cnnection_finished_flushing
nickm at torproject.org
nickm at torproject.org
Mon Sep 27 20:50:59 UTC 2010
Author: Nick Mathewson <nickm at torproject.org>
Date: Wed, 5 Aug 2009 09:59:11 -0700
Subject: Move the "stop writing when the buffer is empty" logic to cnnection_finished_flushing
Commit: ec10c044fb3e7b4865a7e9082c5353876e40915f
---
src/or/connection.c | 3 +++
src/or/connection_edge.c | 2 --
src/or/connection_or.c | 1 -
src/or/control.c | 2 --
src/or/cpuworker.c | 1 -
src/or/directory.c | 1 -
src/or/or.h | 4 ++++
7 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/src/or/connection.c b/src/or/connection.c
index a68ba77..ff5c4c0 100644
--- a/src/or/connection.c
+++ b/src/or/connection.c
@@ -3430,6 +3430,9 @@ connection_finished_flushing(connection_t *conn)
// log_fn(LOG_DEBUG,"entered. Socket %u.", conn->s);
+ IF_HAS_NO_BUFFEREVENT(conn)
+ connection_stop_writing(conn);
+
switch (conn->type) {
case CONN_TYPE_OR:
return connection_or_finished_flushing(TO_OR_CONN(conn));
diff --git a/src/or/connection_edge.c b/src/or/connection_edge.c
index 1488f5a..edc58a0 100644
--- a/src/or/connection_edge.c
+++ b/src/or/connection_edge.c
@@ -319,7 +319,6 @@ connection_edge_finished_flushing(edge_connection_t *conn)
switch (conn->_base.state) {
case AP_CONN_STATE_OPEN:
case EXIT_CONN_STATE_OPEN:
- connection_stop_writing(TO_CONN(conn));
connection_edge_consider_sending_sendme(conn);
return 0;
case AP_CONN_STATE_SOCKS_WAIT:
@@ -328,7 +327,6 @@ connection_edge_finished_flushing(edge_connection_t *conn)
case AP_CONN_STATE_CIRCUIT_WAIT:
case AP_CONN_STATE_CONNECT_WAIT:
case AP_CONN_STATE_CONTROLLER_WAIT:
- connection_stop_writing(TO_CONN(conn));
return 0;
default:
log_warn(LD_BUG, "Called in unexpected state %d.",conn->_base.state);
diff --git a/src/or/connection_or.c b/src/or/connection_or.c
index cb2c429..169f141 100644
--- a/src/or/connection_or.c
+++ b/src/or/connection_or.c
@@ -281,7 +281,6 @@ connection_or_finished_flushing(or_connection_t *conn)
case OR_CONN_STATE_PROXY_HANDSHAKING:
case OR_CONN_STATE_OPEN:
case OR_CONN_STATE_OR_HANDSHAKING:
- connection_stop_writing(TO_CONN(conn));
break;
default:
log_err(LD_BUG,"Called in unexpected state %d.", conn->_base.state);
diff --git a/src/or/control.c b/src/or/control.c
index 436ee2b..ac004b5 100644
--- a/src/or/control.c
+++ b/src/or/control.c
@@ -2719,8 +2719,6 @@ int
connection_control_finished_flushing(control_connection_t *conn)
{
tor_assert(conn);
-
- connection_stop_writing(TO_CONN(conn));
return 0;
}
diff --git a/src/or/cpuworker.c b/src/or/cpuworker.c
index 07a1c2f..a9c29d2 100644
--- a/src/or/cpuworker.c
+++ b/src/or/cpuworker.c
@@ -62,7 +62,6 @@ connection_cpu_finished_flushing(connection_t *conn)
{
tor_assert(conn);
tor_assert(conn->type == CONN_TYPE_CPUWORKER);
- connection_stop_writing(conn);
return 0;
}
diff --git a/src/or/directory.c b/src/or/directory.c
index 7f8d116..2e9770e 100644
--- a/src/or/directory.c
+++ b/src/or/directory.c
@@ -3355,7 +3355,6 @@ connection_dir_finished_flushing(dir_connection_t *conn)
case DIR_CONN_STATE_CLIENT_SENDING:
log_debug(LD_DIR,"client finished sending command.");
conn->_base.state = DIR_CONN_STATE_CLIENT_READING;
- connection_stop_writing(TO_CONN(conn));
return 0;
case DIR_CONN_STATE_SERVER_WRITING:
log_debug(LD_DIRSERV,"Finished writing server response. Closing.");
diff --git a/src/or/or.h b/src/or/or.h
index e82cd4e..8f87573 100644
--- a/src/or/or.h
+++ b/src/or/or.h
@@ -1312,10 +1312,14 @@ static INLINE control_connection_t *TO_CONTROL_CONN(connection_t *c)
stmt ; \
} while (0)
#define ELSE_IF_NO_BUFFEREVENT ; else
+#define IF_HAS_NO_BUFFEREVENT(c) \
+ if (NULL == (c)->bufev)
#else
#define HAS_BUFFEREVENT(c) (0)
#define IF_HAS_BUFFEREVENT(c, stmt) (void)0
#define ELSE_IF_NO_BUFFEREVENT ;
+#define IF_HAS_NO_BUFFEREVENT(c) \
+ if (1)
#endif
/** What action type does an address policy indicate: accept or reject? */
--
1.7.1
More information about the tor-commits
mailing list