Commit 3d7bf98d authored by Nick Mathewson's avatar Nick Mathewson 🦞
Browse files

Merge remote-tracking branch 'valentecaio/t-24714'

parents 3c8a4815 7884ce76
Loading
Loading
Loading
Loading

changes/ticket24714

0 → 100644
+6 −0
Original line number Diff line number Diff line
  o Code simplification and refactoring:
    - Rename two fields of connection_t struct.
      timestamp_lastwritten is renamed to timestamp_last_write_allowed and
      timestamp_lastread is renamed to timestamp_last_read_allowed.
      Closes ticket 24714, patch by "valentecaio".
+1 −1
Original line number Diff line number Diff line
@@ -2584,7 +2584,7 @@ link_apconn_to_circ(entry_connection_t *apconn, origin_circuit_t *circ,
  log_debug(LD_APP|LD_CIRC, "attaching new conn to circ. n_circ_id %u.",
            (unsigned)circ->base_.n_circ_id);
  /* reset it, so we can measure circ timeouts */
  ENTRY_TO_CONN(apconn)->timestamp_lastread = time(NULL);
  ENTRY_TO_CONN(apconn)->timestamp_last_read_allowed = time(NULL);
  ENTRY_TO_EDGE_CONN(apconn)->next_stream = circ->p_streams;
  ENTRY_TO_EDGE_CONN(apconn)->on_circuit = TO_CIRCUIT(circ);
  /* assert_connection_ok(conn, time(NULL)); */
+7 −7
Original line number Diff line number Diff line
@@ -462,8 +462,8 @@ connection_init(time_t now, connection_t *conn, int type, int socket_family)
  }

  conn->timestamp_created = now;
  conn->timestamp_lastread = now;
  conn->timestamp_lastwritten = now;
  conn->timestamp_last_read_allowed = now;
  conn->timestamp_last_write_allowed = now;
}

/** Create a link between <b>conn_a</b> and <b>conn_b</b>. */
@@ -861,7 +861,7 @@ connection_mark_for_close_internal_, (connection_t *conn,
  /* in case we're going to be held-open-til-flushed, reset
   * the number of seconds since last successful write, so
   * we get our whole 15 seconds */
  conn->timestamp_lastwritten = time(NULL);
  conn->timestamp_last_write_allowed = time(NULL);
}

/** Find each connection that has hold_open_until_flushed set to
@@ -883,7 +883,7 @@ connection_expire_held_open(void)
     */
    if (conn->hold_open_until_flushed) {
      tor_assert(conn->marked_for_close);
      if (now - conn->timestamp_lastwritten >= 15) {
      if (now - conn->timestamp_last_write_allowed >= 15) {
        int severity;
        if (conn->type == CONN_TYPE_EXIT ||
            (conn->type == CONN_TYPE_DIR &&
@@ -3417,7 +3417,7 @@ connection_handle_read_impl(connection_t *conn)
  if (conn->marked_for_close)
    return 0; /* do nothing */

  conn->timestamp_lastread = approx_time();
  conn->timestamp_last_read_allowed = approx_time();

  switch (conn->type) {
    case CONN_TYPE_OR_LISTENER:
@@ -3818,7 +3818,7 @@ update_send_buffer_size(tor_socket_t sock)
 * when libevent tells us that conn wants to write, or below
 * from connection_buf_add() when an entire TLS record is ready.
 *
 * Update <b>conn</b>-\>timestamp_lastwritten to now, and call flush_buf
 * Update <b>conn</b>-\>timestamp_last_write_allowed to now, and call flush_buf
 * or flush_buf_tls appropriately. If it succeeds and there are no more
 * more bytes on <b>conn</b>-\>outbuf, then call connection_finished_flushing
 * on it too.
@@ -3851,7 +3851,7 @@ connection_handle_write_impl(connection_t *conn, int force)
    return 0;
  }

  conn->timestamp_lastwritten = now;
  conn->timestamp_last_write_allowed = now;

  /* Sometimes, "writable" means "connected". */
  if (connection_state_is_connecting(conn)) {
+3 −3
Original line number Diff line number Diff line
@@ -739,7 +739,7 @@ connection_ap_expire_beginning(void)
    /* if it's an internal linked connection, don't yell its status. */
    severity = (tor_addr_is_null(&base_conn->addr) && !base_conn->port)
      ? LOG_INFO : LOG_NOTICE;
    seconds_idle = (int)( now - base_conn->timestamp_lastread );
    seconds_idle = (int)( now - base_conn->timestamp_last_read_allowed );
    seconds_since_born = (int)( now - base_conn->timestamp_created );

    if (base_conn->state == AP_CONN_STATE_OPEN)
@@ -825,7 +825,7 @@ connection_ap_expire_beginning(void)
    mark_circuit_unusable_for_new_conns(TO_ORIGIN_CIRCUIT(circ));

    /* give our stream another 'cutoff' seconds to try */
    conn->base_.timestamp_lastread += cutoff;
    conn->base_.timestamp_last_read_allowed += cutoff;
    if (entry_conn->num_socks_retries < 250) /* avoid overflow */
      entry_conn->num_socks_retries++;
    /* move it back into 'pending' state, and try to attach. */
@@ -1135,7 +1135,7 @@ connection_ap_detach_retriable(entry_connection_t *conn,
                               int reason)
{
  control_event_stream_status(conn, STREAM_EVENT_FAILED_RETRIABLE, reason);
  ENTRY_TO_CONN(conn)->timestamp_lastread = time(NULL);
  ENTRY_TO_CONN(conn)->timestamp_last_read_allowed = time(NULL);

  /* Roll back path bias use state so that we probe the circuit
   * if nothing else succeeds on it */
+1 −1
Original line number Diff line number Diff line
@@ -2437,7 +2437,7 @@ connection_dir_client_reached_eof(dir_connection_t *conn)
     * and the date header.  (We used to check now-date_header, but that's
     * inaccurate if we spend a lot of time downloading.)
     */
    apparent_skew = conn->base_.timestamp_lastwritten - date_header;
    apparent_skew = conn->base_.timestamp_last_write_allowed - date_header;
    if (labs(apparent_skew)>ALLOW_DIRECTORY_TIME_SKEW) {
      int trusted = router_digest_is_trusted_dir(conn->identity_digest);
      clock_skew_warning(TO_CONN(conn), apparent_skew, trusted, LD_HTTP,
Loading