Commit 10ae9b9b authored by Nick Mathewson's avatar Nick Mathewson 🤹
Browse files

Usually downgrade middle heartbeat messages when stuff is in-range

parent 251f6cfc
Loading
Loading
Loading
Loading
+18 −9
Original line number Diff line number Diff line
@@ -117,15 +117,24 @@ log_heartbeat(time_t now)
    log_accounting(now, options);
  }

  if (stats_n_data_cells_packaged && !hibernating)
    log_notice(LD_HEARTBEAT, "Average packaged cell fullness: %2.3f%%",
  double fullness_pct = 100;
  if (stats_n_data_cells_packaged && !hibernating) {
    fullness_pct =
      100*(U64_TO_DBL(stats_n_data_bytes_packaged) /
             U64_TO_DBL(stats_n_data_cells_packaged*RELAY_PAYLOAD_SIZE)) );

  if (r > 1.0) {
    double overhead = ( r - 1.0 ) * 100.0;
    log_notice(LD_HEARTBEAT, "TLS write overhead: %.f%%", overhead);
           U64_TO_DBL(stats_n_data_cells_packaged*RELAY_PAYLOAD_SIZE));
  }
  const double overhead_pct = ( r - 1.0 ) * 100.0;

#define FULLNESS_PCT_THRESHOLD 80
#define TLS_OVERHEAD_THRESHOLD 15

  const int severity = (fullness_pct < FULLNESS_PCT_THRESHOLD ||
                        overhead_pct > TLS_OVERHEAD_THRESHOLD)
    ? LOG_NOTICE : LOG_INFO;

  log_fn(severity, LD_HEARTBEAT,
         "Average packaged cell fullness: %2.3f%%"
         "TLS write overhead: %.f%%", fullness_pct, overhead_pct);

  if (public_server_mode(options))
    rep_hist_log_circuit_handshake_stats(now);