diff --git a/src/or/connection.c b/src/or/connection.c index a68ba7748c..ff5c4c04ae 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 1488f5a894..edc58a0cf1 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 cb2c429e9a..169f14153a 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 436ee2ba8b..ac004b5582 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 07a1c2fb06..a9c29d288d 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 7f8d1167b3..2e9770eebf 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 e82cd4e1b5..8f875731f6 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? */