Changes between Version 14 and Version 15 of Ticket #16248, comment 20


Ignore:
Timestamp:
Mar 11, 2016, 2:17:22 PM (3 years ago)
Author:
cypherpunks
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #16248, comment 20

    v14 v15  
    1 ~~wrong~~
     1{{{
     2 /** Tell the main loop to stop notifying <b>conn</b> of any read events. */
     3 MOCK_IMPL(void,
     4 connection_stop_reading,(connection_t *conn))
     5 {
     6   tor_assert(conn);
     7 
     8   IF_HAS_BUFFEREVENT(conn, {
     9       bufferevent_disable(conn->bufev, EV_READ);
     10       return;
     11   });
     12 
     13+  /* if dummy conn then no socket and no event, nothing to do here */
     14+  if (conn->type == CONN_TYPE_AP && TO_EDGE_CONN(conn)->is_dns_request) {
     15+    tor_assert(!conn->read_event);
     16+    return;
     17+  }
     18+
     19   tor_assert(conn->read_event);
     20 
     21   if (conn->linked) {
     22     conn->reading_from_linked_conn = 0;
     23     connection_stop_reading_from_linked_conn(conn);
     24   } else {
     25     if (event_del(conn->read_event))
     26       log_warn(LD_NET, "Error from libevent setting read event state for %d "
     27                "to unwatched: %s",
     28                (int)conn->s,
     29                tor_socket_strerror(tor_socket_errno(conn->s)));
     30   }
     31 }
     32 
     33 /** Tell the main loop to start notifying <b>conn</b> of any read events. */
     34 MOCK_IMPL(void,
     35 connection_start_reading,(connection_t *conn))
     36 {
     37   tor_assert(conn);
     38 
     39   IF_HAS_BUFFEREVENT(conn, {
     40       bufferevent_enable(conn->bufev, EV_READ);
     41       return;
     42   });
     43 
     44+  /* if dummy conn then no socket and no event, nothing to do here */
     45+  if (conn->type == CONN_TYPE_AP && TO_EDGE_CONN(conn)->is_dns_request) {
     46+    tor_assert(!conn->read_event);
     47+    return;
     48+  }
     49+
     50   tor_assert(conn->read_event);
     51 
     52   if (conn->linked) {
     53     conn->reading_from_linked_conn = 1;
     54     if (connection_should_read_from_linked_conn(conn))
     55       connection_start_reading_from_linked_conn(conn);
     56   } else {
     57     if (event_add(conn->read_event, NULL))
     58       log_warn(LD_NET, "Error from libevent setting read event state for %d "
     59                "to watched: %s",
     60                (int)conn->s,
     61                tor_socket_strerror(tor_socket_errno(conn->s)));
     62   }
     63 }
     64}}}