From c735220a0b4c2c7852145fe8e9bf2584d4901d1f Mon Sep 17 00:00:00 2001 From: U+039b <*@0x39b.fr> Date: Thu, 14 Jul 2016 18:46:37 +0200 Subject: Remove bufferevents dead code Signed-off-by: U+039b <*@0x39b.fr> --- src/or/connection_or.c | 131 ------------------------------------------------- 1 file changed, 131 deletions(-) (limited to 'src/or/connection_or.c') diff --git a/src/or/connection_or.c b/src/or/connection_or.c index c69a2ad377..c22e92cd55 100644 --- a/src/or/connection_or.c +++ b/src/or/connection_or.c @@ -42,10 +42,6 @@ #include "ext_orport.h" #include "scheduler.h" -#ifdef USE_BUFFEREVENTS -#include -#endif - static int connection_tls_finish_handshake(or_connection_t *conn); static int connection_or_launch_v3_or_handshake(or_connection_t *conn); static int connection_or_process_cells_from_inbuf(or_connection_t *conn); @@ -66,12 +62,6 @@ static void connection_or_mark_bad_for_new_circs(or_connection_t *or_conn); static void connection_or_change_state(or_connection_t *conn, uint8_t state); -#ifdef USE_BUFFEREVENTS -static void connection_or_handle_event_cb(struct bufferevent *bufev, - short event, void *arg); -#include /*XXXX REMOVE */ -#endif - /**************************************************************/ /** Map from identity digest of connected OR or desired OR to a connection_t @@ -565,13 +555,6 @@ connection_or_process_inbuf(or_connection_t *conn) return ret; case OR_CONN_STATE_TLS_SERVER_RENEGOTIATING: -#ifdef USE_BUFFEREVENTS - if (tor_tls_server_got_renegotiate(conn->tls)) - connection_or_tls_renegotiated_cb(conn->tls, conn); - if (conn->base_.marked_for_close) - return 0; - /* fall through. */ -#endif case OR_CONN_STATE_OPEN: case OR_CONN_STATE_OR_HANDSHAKING_V2: case OR_CONN_STATE_OR_HANDSHAKING_V3: @@ -807,27 +790,6 @@ connection_or_update_token_buckets_helper(or_connection_t *conn, int reset, conn->bandwidthrate = rate; conn->bandwidthburst = burst; -#ifdef USE_BUFFEREVENTS - { - const struct timeval *tick = tor_libevent_get_one_tick_timeout(); - struct ev_token_bucket_cfg *cfg, *old_cfg; - int64_t rate64 = (((int64_t)rate) * options->TokenBucketRefillInterval) - / 1000; - /* This can't overflow, since TokenBucketRefillInterval <= 1000, - * and rate started out less than INT_MAX. */ - int rate_per_tick = (int) rate64; - - cfg = ev_token_bucket_cfg_new(rate_per_tick, burst, rate_per_tick, - burst, tick); - old_cfg = conn->bucket_cfg; - if (conn->base_.bufev) - tor_set_bufferevent_rate_limit(conn->base_.bufev, cfg); - if (old_cfg) - ev_token_bucket_cfg_free(old_cfg); - conn->bucket_cfg = cfg; - (void) reset; /* No way to do this with libevent yet. */ - } -#else if (reset) { /* set up the token buckets to be full */ conn->read_bucket = conn->write_bucket = burst; return; @@ -838,7 +800,6 @@ connection_or_update_token_buckets_helper(or_connection_t *conn, int reset, conn->read_bucket = burst; if (conn->write_bucket > burst) conn->write_bucket = burst; -#endif } /** Either our set of relays or our per-conn rate limits have changed. @@ -1395,29 +1356,6 @@ connection_tls_start_handshake,(or_connection_t *conn, int receiving)) tor_tls_set_logged_address(conn->tls, // XXX client and relay? escaped_safe_str(conn->base_.address)); -#ifdef USE_BUFFEREVENTS - if (connection_type_uses_bufferevent(TO_CONN(conn))) { - const int filtering = get_options()->UseFilteringSSLBufferevents; - struct bufferevent *b = - tor_tls_init_bufferevent(conn->tls, conn->base_.bufev, conn->base_.s, - receiving, filtering); - if (!b) { - log_warn(LD_BUG,"tor_tls_init_bufferevent failed. Closing."); - return -1; - } - conn->base_.bufev = b; - if (conn->bucket_cfg) - tor_set_bufferevent_rate_limit(conn->base_.bufev, conn->bucket_cfg); - connection_enable_rate_limiting(TO_CONN(conn)); - - connection_configure_bufferevent_callbacks(TO_CONN(conn)); - bufferevent_setcb(b, - connection_handle_read_cb, - connection_handle_write_cb, - connection_or_handle_event_cb,/* overriding this one*/ - TO_CONN(conn)); - } -#endif connection_start_reading(TO_CONN(conn)); log_debug(LD_HANDSHAKE,"starting TLS handshake on fd "TOR_SOCKET_T_FORMAT, conn->base_.s); @@ -1517,75 +1455,6 @@ connection_tls_continue_handshake(or_connection_t *conn) return 0; } -#ifdef USE_BUFFEREVENTS -static void -connection_or_handle_event_cb(struct bufferevent *bufev, short event, - void *arg) -{ - struct or_connection_t *conn = TO_OR_CONN(arg); - - /* XXXX cut-and-paste code; should become a function. */ - if (event & BEV_EVENT_CONNECTED) { - if (conn->base_.state == OR_CONN_STATE_TLS_HANDSHAKING) { - if (tor_tls_finish_handshake(conn->tls) < 0) { - log_warn(LD_OR, "Problem finishing handshake"); - connection_or_close_for_error(conn, 0); - return; - } - } - - if (! tor_tls_used_v1_handshake(conn->tls)) { - if (!tor_tls_is_server(conn->tls)) { - if (conn->base_.state == OR_CONN_STATE_TLS_HANDSHAKING) { - if (connection_or_launch_v3_or_handshake(conn) < 0) - connection_or_close_for_error(conn, 0); - } - } else { - const int handshakes = tor_tls_get_num_server_handshakes(conn->tls); - - if (handshakes == 1) { - /* v2 or v3 handshake, as a server. Only got one handshake, so - * wait for the next one. */ - tor_tls_set_renegotiate_callback(conn->tls, - connection_or_tls_renegotiated_cb, - conn); - connection_or_change_state(conn, - OR_CONN_STATE_TLS_SERVER_RENEGOTIATING); - } else if (handshakes == 2) { - /* v2 handshake, as a server. Two handshakes happened already, - * so we treat renegotiation as done. - */ - connection_or_tls_renegotiated_cb(conn->tls, conn); - } else if (handshakes > 2) { - log_warn(LD_OR, "More than two handshakes done on connection. " - "Closing."); - connection_or_close_for_error(conn, 0); - } else { - log_warn(LD_BUG, "We were unexpectedly told that a connection " - "got %d handshakes. Closing.", handshakes); - connection_or_close_for_error(conn, 0); - } - return; - } - } - connection_watch_events(TO_CONN(conn), READ_EVENT|WRITE_EVENT); - if (connection_tls_finish_handshake(conn) < 0) - connection_or_close_for_error(conn, 0); /* ???? */ - return; - } - - if (event & BEV_EVENT_ERROR) { - unsigned long err; - while ((err = bufferevent_get_openssl_error(bufev))) { - tor_tls_log_one_error(conn->tls, err, LOG_WARN, LD_OR, - "handshaking (with bufferevent)"); - } - } - - connection_handle_event_cb(bufev, event, arg); -} -#endif - /** Return 1 if we initiated this connection, or 0 if it started * out as an incoming connection. */ -- cgit v1.2.3-54-g00ecf From c68a23a135369380dad5cb1ff393edee74e6d6ac Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Tue, 2 Aug 2016 13:15:10 -0400 Subject: Bufferevent removal: remove HAS_BUFFEREVENT macros and usage This is another way that we had bufferevents-only code marked. --- src/or/connection.c | 76 ++++-------------------------------------------- src/or/connection.h | 12 +------- src/or/connection_edge.c | 19 ++++-------- src/or/connection_or.c | 22 ++++---------- src/or/control.c | 7 +---- src/or/directory.c | 6 +--- src/or/ext_orport.c | 7 +---- src/or/main.c | 41 +------------------------- src/or/or.h | 34 ---------------------- src/or/relay.c | 2 +- 10 files changed, 22 insertions(+), 204 deletions(-) (limited to 'src/or/connection_or.c') diff --git a/src/or/connection.c b/src/or/connection.c index 9b82e0924f..ac00a1b786 100644 --- a/src/or/connection.c +++ b/src/or/connection.c @@ -575,15 +575,6 @@ connection_free_(connection_t *conn) tor_event_free(conn->read_event); tor_event_free(conn->write_event); conn->read_event = conn->write_event = NULL; - IF_HAS_BUFFEREVENT(conn, { - /* This was a workaround to handle bugs in some old versions of libevent - * where callbacks can occur after calling bufferevent_free(). Setting - * the callbacks to NULL prevented this. It shouldn't be necessary any - * more, but let's not tempt fate for now. */ - bufferevent_setcb(conn->bufev, NULL, NULL, NULL, NULL); - bufferevent_free(conn->bufev); - conn->bufev = NULL; - }); if (conn->type == CONN_TYPE_DIR) { dir_connection_t *dir_conn = TO_DIR_CONN(conn); @@ -2220,12 +2211,7 @@ static int connection_fetch_from_buf_socks_client(connection_t *conn, int state, char **reason) { - IF_HAS_BUFFEREVENT(conn, { - struct evbuffer *input = bufferevent_get_input(conn->bufev); - return fetch_from_evbuffer_socks_client(input, state, reason); - }) ELSE_IF_NO_BUFFEREVENT { - return fetch_from_buf_socks_client(conn->inbuf, state, reason); - } + return fetch_from_buf_socks_client(conn->inbuf, state, reason); } /** Call this from connection_*_process_inbuf() to advance the proxy @@ -3570,12 +3556,7 @@ connection_read_to_buf(connection_t *conn, ssize_t *max_to_read, int connection_fetch_from_buf(char *string, size_t len, connection_t *conn) { - IF_HAS_BUFFEREVENT(conn, { - /* XXX overflow -seb */ - return (int)bufferevent_read(conn->bufev, string, len); - }) ELSE_IF_NO_BUFFEREVENT { - return fetch_from_buf(string, len, conn->inbuf); - } + return fetch_from_buf(string, len, conn->inbuf); } /** As fetch_from_buf_line(), but read from a connection's input buffer. */ @@ -3583,25 +3564,7 @@ int connection_fetch_from_buf_line(connection_t *conn, char *data, size_t *data_len) { - IF_HAS_BUFFEREVENT(conn, { - int r; - size_t eol_len=0; - struct evbuffer *input = bufferevent_get_input(conn->bufev); - struct evbuffer_ptr ptr = - evbuffer_search_eol(input, NULL, &eol_len, EVBUFFER_EOL_LF); - if (ptr.pos == -1) - return 0; /* No EOL found. */ - if ((size_t)ptr.pos+eol_len >= *data_len) { - return -1; /* Too long */ - } - *data_len = ptr.pos+eol_len; - r = evbuffer_remove(input, data, ptr.pos+eol_len); - tor_assert(r >= 0); - data[ptr.pos+eol_len] = '\0'; - return 1; - }) ELSE_IF_NO_BUFFEREVENT { - return fetch_from_buf_line(conn->inbuf, data, data_len); - } + return fetch_from_buf_line(conn->inbuf, data, data_len); } /** As fetch_from_buf_http, but fetches from a connection's input buffer_t or @@ -3612,14 +3575,8 @@ connection_fetch_from_buf_http(connection_t *conn, char **body_out, size_t *body_used, size_t max_bodylen, int force_complete) { - IF_HAS_BUFFEREVENT(conn, { - struct evbuffer *input = bufferevent_get_input(conn->bufev); - return fetch_from_evbuffer_http(input, headers_out, max_headerlen, - body_out, body_used, max_bodylen, force_complete); - }) ELSE_IF_NO_BUFFEREVENT { - return fetch_from_buf_http(conn->inbuf, headers_out, max_headerlen, - body_out, body_used, max_bodylen, force_complete); - } + return fetch_from_buf_http(conn->inbuf, headers_out, max_headerlen, + body_out, body_used, max_bodylen, force_complete); } /** Return conn-\>outbuf_flushlen: how many bytes conn wants to flush @@ -3931,10 +3888,6 @@ connection_handle_write(connection_t *conn, int force) int connection_flush(connection_t *conn) { - IF_HAS_BUFFEREVENT(conn, { - int r = bufferevent_flush(conn->bufev, EV_WRITE, BEV_FLUSH); - return (r < 0) ? -1 : 0; - }); return connection_handle_write(conn, 1); } @@ -3963,22 +3916,6 @@ connection_write_to_buf_impl_,(const char *string, size_t len, if (conn->marked_for_close && !conn->hold_open_until_flushed) return; - IF_HAS_BUFFEREVENT(conn, { - if (zlib) { - int done = zlib < 0; - r = write_to_evbuffer_zlib(bufferevent_get_output(conn->bufev), - TO_DIR_CONN(conn)->zlib_state, - string, len, done); - } else { - r = bufferevent_write(conn->bufev, string, len); - } - if (r < 0) { - /* XXXX mark for close? */ - log_warn(LD_NET, "bufferevent_write failed! That shouldn't happen."); - } - return; - }); - old_datalen = buf_datalen(conn->outbuf); if (zlib) { dir_connection_t *dir_conn = TO_DIR_CONN(conn); @@ -4441,8 +4378,7 @@ connection_finished_flushing(connection_t *conn) // log_fn(LOG_DEBUG,"entered. Socket %u.", conn->s); - IF_HAS_NO_BUFFEREVENT(conn) - connection_stop_writing(conn); + connection_stop_writing(conn); switch (conn->type) { case CONN_TYPE_OR: diff --git a/src/or/connection.h b/src/or/connection.h index 7f659dce70..6c531c0a6e 100644 --- a/src/or/connection.h +++ b/src/or/connection.h @@ -57,8 +57,6 @@ void connection_mark_for_close_internal_(connection_t *conn, connection_t *tmp_conn_ = (c); \ connection_mark_for_close_internal_(tmp_conn_, (line), (file)); \ tmp_conn_->hold_open_until_flushed = 1; \ - IF_HAS_BUFFEREVENT(tmp_conn_, \ - connection_start_writing(tmp_conn_)); \ } while (0) #define connection_mark_and_flush_internal(c) \ @@ -166,21 +164,13 @@ static size_t connection_get_outbuf_len(connection_t *conn); static inline size_t connection_get_inbuf_len(connection_t *conn) { - IF_HAS_BUFFEREVENT(conn, { - return evbuffer_get_length(bufferevent_get_input(conn->bufev)); - }) ELSE_IF_NO_BUFFEREVENT { - return conn->inbuf ? buf_datalen(conn->inbuf) : 0; - } + return conn->inbuf ? buf_datalen(conn->inbuf) : 0; } static inline size_t connection_get_outbuf_len(connection_t *conn) { - IF_HAS_BUFFEREVENT(conn, { - return evbuffer_get_length(bufferevent_get_output(conn->bufev)); - }) ELSE_IF_NO_BUFFEREVENT { return conn->outbuf ? buf_datalen(conn->outbuf) : 0; - } } connection_t *connection_get_by_global_id(uint64_t id); diff --git a/src/or/connection_edge.c b/src/or/connection_edge.c index 799baa2acc..d5eada61d8 100644 --- a/src/or/connection_edge.c +++ b/src/or/connection_edge.c @@ -478,8 +478,7 @@ connection_edge_finished_connecting(edge_connection_t *edge_conn) rep_hist_note_exit_stream_opened(conn->port); conn->state = EXIT_CONN_STATE_OPEN; - IF_HAS_NO_BUFFEREVENT(conn) - connection_watch_events(conn, READ_EVENT); /* stop writing, keep reading */ + connection_watch_events(conn, READ_EVENT); /* stop writing, keep reading */ if (connection_get_outbuf_len(conn)) /* in case there are any queued relay * cells */ connection_start_writing(conn); @@ -2008,14 +2007,8 @@ connection_ap_handshake_process_socks(entry_connection_t *conn) log_debug(LD_APP,"entered."); - IF_HAS_BUFFEREVENT(base_conn, { - struct evbuffer *input = bufferevent_get_input(base_conn->bufev); - sockshere = fetch_from_evbuffer_socks(input, socks, - options->TestSocks, options->SafeSocks); - }) ELSE_IF_NO_BUFFEREVENT { - sockshere = fetch_from_buf_socks(base_conn->inbuf, socks, - options->TestSocks, options->SafeSocks); - }; + sockshere = fetch_from_buf_socks(base_conn->inbuf, socks, + options->TestSocks, options->SafeSocks); if (socks->replylen) { had_reply = 1; @@ -3225,11 +3218,9 @@ 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, from e.g. optimistic data */ - IF_HAS_NO_BUFFEREVENT(conn) - connection_watch_events(conn, READ_EVENT|WRITE_EVENT); + connection_watch_events(conn, READ_EVENT|WRITE_EVENT); } else { - IF_HAS_NO_BUFFEREVENT(conn) - connection_watch_events(conn, READ_EVENT); + connection_watch_events(conn, READ_EVENT); } /* also, deliver a 'connected' cell back through the circuit. */ diff --git a/src/or/connection_or.c b/src/or/connection_or.c index c22e92cd55..4de64b2347 100644 --- a/src/or/connection_or.c +++ b/src/or/connection_or.c @@ -1361,12 +1361,9 @@ connection_tls_start_handshake,(or_connection_t *conn, int receiving)) conn->base_.s); note_crypto_pk_op(receiving ? TLS_HANDSHAKE_S : TLS_HANDSHAKE_C); - IF_HAS_BUFFEREVENT(TO_CONN(conn), { - /* ???? */; - }) ELSE_IF_NO_BUFFEREVENT { - if (connection_tls_continue_handshake(conn) < 0) - return -1; - } + if (connection_tls_continue_handshake(conn) < 0) + return -1; + return 0; } @@ -1872,11 +1869,7 @@ connection_or_set_state_open(or_connection_t *conn) or_handshake_state_free(conn->handshake_state); conn->handshake_state = NULL; - IF_HAS_BUFFEREVENT(TO_CONN(conn), { - connection_watch_events(TO_CONN(conn), READ_EVENT|WRITE_EVENT); - }) ELSE_IF_NO_BUFFEREVENT { - connection_start_reading(TO_CONN(conn)); - } + connection_start_reading(TO_CONN(conn)); return 0; } @@ -1936,12 +1929,7 @@ static int connection_fetch_var_cell_from_buf(or_connection_t *or_conn, var_cell_t **out) { connection_t *conn = TO_CONN(or_conn); - IF_HAS_BUFFEREVENT(conn, { - struct evbuffer *input = bufferevent_get_input(conn->bufev); - return fetch_var_cell_from_evbuffer(input, out, or_conn->link_proto); - }) ELSE_IF_NO_BUFFEREVENT { - return fetch_var_cell_from_buf(conn->inbuf, out, or_conn->link_proto); - } + return fetch_var_cell_from_buf(conn->inbuf, out, or_conn->link_proto); } /** Process cells from conn's inbuf. diff --git a/src/or/control.c b/src/or/control.c index 21f48aff12..b4fead43d4 100644 --- a/src/or/control.c +++ b/src/or/control.c @@ -4798,12 +4798,7 @@ is_valid_initial_command(control_connection_t *conn, const char *cmd) static int peek_connection_has_control0_command(connection_t *conn) { - IF_HAS_BUFFEREVENT(conn, { - struct evbuffer *input = bufferevent_get_input(conn->bufev); - return peek_evbuffer_has_control0_command(input); - }) ELSE_IF_NO_BUFFEREVENT { - return peek_buf_has_control0_command(conn->inbuf); - } + return peek_buf_has_control0_command(conn->inbuf); } /** Called when data has arrived on a v1 control connection: Try to fetch diff --git a/src/or/directory.c b/src/or/directory.c index 11594ff476..d37b5c2e0f 100644 --- a/src/or/directory.c +++ b/src/or/directory.c @@ -1272,11 +1272,7 @@ directory_initiate_command_rend(const tor_addr_port_t *or_addr_port, if_modified_since); connection_watch_events(TO_CONN(conn), READ_EVENT|WRITE_EVENT); - IF_HAS_BUFFEREVENT(ENTRY_TO_CONN(linked_conn), { - connection_watch_events(ENTRY_TO_CONN(linked_conn), - READ_EVENT|WRITE_EVENT); - }) ELSE_IF_NO_BUFFEREVENT - connection_start_reading(ENTRY_TO_CONN(linked_conn)); + connection_start_reading(ENTRY_TO_CONN(linked_conn)); } } diff --git a/src/or/ext_orport.c b/src/or/ext_orport.c index 8ba3c6afa3..fb7add17d8 100644 --- a/src/or/ext_orport.c +++ b/src/or/ext_orport.c @@ -41,12 +41,7 @@ ext_or_cmd_free(ext_or_cmd_t *cmd) static int connection_fetch_ext_or_cmd_from_buf(connection_t *conn, ext_or_cmd_t **out) { - IF_HAS_BUFFEREVENT(conn, { - struct evbuffer *input = bufferevent_get_input(conn->bufev); - return fetch_ext_or_command_from_evbuffer(input, out); - }) ELSE_IF_NO_BUFFEREVENT { - return fetch_ext_or_command_from_buf(conn->inbuf, out); - } + return fetch_ext_or_command_from_buf(conn->inbuf, out); } /** Write an Extended ORPort message to conn. Use diff --git a/src/or/main.c b/src/or/main.c index 3f9b40bd13..0a689ba77c 100644 --- a/src/or/main.c +++ b/src/or/main.c @@ -225,7 +225,7 @@ connection_add_impl(connection_t *conn, int is_connecting) (void) is_connecting; - if (!HAS_BUFFEREVENT(conn) && (SOCKET_OK(conn->s) || conn->linked)) { + if (SOCKET_OK(conn->s) || conn->linked) { conn->read_event = tor_event_new(tor_libevent_get_base(), conn->s, EV_READ|EV_PERSIST, conn_read_callback, conn); conn->write_event = tor_event_new(tor_libevent_get_base(), @@ -413,17 +413,6 @@ get_bytes_written,(void)) void connection_watch_events(connection_t *conn, watchable_events_t events) { - IF_HAS_BUFFEREVENT(conn, { - short ev = ((short)events) & (EV_READ|EV_WRITE); - short old_ev = bufferevent_get_enabled(conn->bufev); - if ((ev & ~old_ev) != 0) { - bufferevent_enable(conn->bufev, ev); - } - if ((old_ev & ~ev) != 0) { - bufferevent_disable(conn->bufev, old_ev & ~ev); - } - return; - }); if (events & READ_EVENT) connection_start_reading(conn); else @@ -441,9 +430,6 @@ connection_is_reading(connection_t *conn) { tor_assert(conn); - IF_HAS_BUFFEREVENT(conn, - return (bufferevent_get_enabled(conn->bufev) & EV_READ) != 0; - ); return conn->reading_from_linked_conn || (conn->read_event && event_pending(conn->read_event, EV_READ, NULL)); } @@ -494,11 +480,6 @@ connection_stop_reading,(connection_t *conn)) { tor_assert(conn); - IF_HAS_BUFFEREVENT(conn, { - bufferevent_disable(conn->bufev, EV_READ); - return; - }); - if (connection_check_event(conn, conn->read_event) < 0) { return; } @@ -521,11 +502,6 @@ connection_start_reading,(connection_t *conn)) { tor_assert(conn); - IF_HAS_BUFFEREVENT(conn, { - bufferevent_enable(conn->bufev, EV_READ); - return; - }); - if (connection_check_event(conn, conn->read_event) < 0) { return; } @@ -549,10 +525,6 @@ connection_is_writing(connection_t *conn) { tor_assert(conn); - IF_HAS_BUFFEREVENT(conn, - return (bufferevent_get_enabled(conn->bufev) & EV_WRITE) != 0; - ); - return conn->writing_to_linked_conn || (conn->write_event && event_pending(conn->write_event, EV_WRITE, NULL)); } @@ -563,11 +535,6 @@ connection_stop_writing,(connection_t *conn)) { tor_assert(conn); - IF_HAS_BUFFEREVENT(conn, { - bufferevent_disable(conn->bufev, EV_WRITE); - return; - }); - if (connection_check_event(conn, conn->write_event) < 0) { return; } @@ -591,11 +558,6 @@ connection_start_writing,(connection_t *conn)) { tor_assert(conn); - IF_HAS_BUFFEREVENT(conn, { - bufferevent_enable(conn->bufev, EV_WRITE); - return; - }); - if (connection_check_event(conn, conn->write_event) < 0) { return; } @@ -793,7 +755,6 @@ conn_close_if_marked(int i) if (conn->proxy_state == PROXY_INFANT) log_failed_proxy_connection(conn); - IF_HAS_BUFFEREVENT(conn, goto unlink); if ((SOCKET_OK(conn->s) || conn->linked_conn) && connection_wants_to_flush(conn)) { /* s == -1 means it's an incomplete edge connection, or that the socket diff --git a/src/or/or.h b/src/or/or.h index d04fc28564..e091d5cfd3 100644 --- a/src/or/or.h +++ b/src/or/or.h @@ -1826,40 +1826,6 @@ static inline listener_connection_t *TO_LISTENER_CONN(connection_t *c) return DOWNCAST(listener_connection_t, c); } -/* Conditional macros to help write code that works whether bufferevents are - disabled or not. - - We can't just write: - if (conn->bufev) { - do bufferevent stuff; - } else { - do other stuff; - } - because the bufferevent stuff won't even compile unless we have a fairly - new version of Libevent. Instead, we say: - IF_HAS_BUFFEREVENT(conn, { do_bufferevent_stuff } ); - or: - IF_HAS_BUFFEREVENT(conn, { - do bufferevent stuff; - }) ELSE_IF_NO_BUFFEREVENT { - do non-bufferevent stuff; - } - If we're compiling with bufferevent support, then the macros expand more or - less to: - if (conn->bufev) { - do_bufferevent_stuff; - } else { - do non-bufferevent stuff; - } - and if we aren't using bufferevents, they expand more or less to: - { do non-bufferevent stuff; } -*/ -#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) - /** What action type does an address policy indicate: accept or reject? */ typedef enum { ADDR_POLICY_ACCEPT=1, diff --git a/src/or/relay.c b/src/or/relay.c index fb8c8e74d6..cfb0016913 100644 --- a/src/or/relay.c +++ b/src/or/relay.c @@ -2525,7 +2525,7 @@ set_streams_blocked_on_circ(circuit_t *circ, channel_t *chan, edge->edge_blocked_on_circ = block; } - if (!conn->read_event && !HAS_BUFFEREVENT(conn)) { + if (!conn->read_event) { /* This connection is a placeholder for something; probably a DNS * request. It can't actually stop or start reading.*/ continue; -- cgit v1.2.3-54-g00ecf