|
@@ -2987,6 +2987,47 @@ rep_hist_conn_stats_write(time_t now)
|
|
return start_of_conn_stats_interval + WRITE_STATS_INTERVAL;
|
|
return start_of_conn_stats_interval + WRITE_STATS_INTERVAL;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+/** Internal statistics to track how many requests of each type of
|
|
|
|
+ * handshake we've received, and how many we've completed. Useful for
|
|
|
|
+ * seeing trends in cpu load.
|
|
|
|
+ * @{ */
|
|
|
|
+static int onion_handshakes_requested[MAX_ONION_HANDSHAKE_TYPE+1] = {0};
|
|
|
|
+static int onion_handshakes_completed[MAX_ONION_HANDSHAKE_TYPE+1] = {0};
|
|
|
|
+/**@}*/
|
|
|
|
+
|
|
|
|
+/** A new onionskin (using the <b>type</b> handshake) has arrived. */
|
|
|
|
+void
|
|
|
|
+rep_hist_note_circuit_handshake_requested(uint16_t type)
|
|
|
|
+{
|
|
|
|
+ if (type <= MAX_ONION_HANDSHAKE_TYPE)
|
|
|
|
+ onion_handshakes_requested[type]++;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+/** We've sent an onionskin (using the <b>type</b> handshake) to a
|
|
|
|
+ * cpuworker. */
|
|
|
|
+void
|
|
|
|
+rep_hist_note_circuit_handshake_completed(uint16_t type)
|
|
|
|
+{
|
|
|
|
+ if (type <= MAX_ONION_HANDSHAKE_TYPE)
|
|
|
|
+ onion_handshakes_completed[type]++;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+/** Log our onionskin statistics since the last time we were called. */
|
|
|
|
+void
|
|
|
|
+rep_hist_log_circuit_handshake_stats(time_t now)
|
|
|
|
+{
|
|
|
|
+ (void)now;
|
|
|
|
+ /* XXX024 maybe quiet this log message before 0.2.4 goes stable for real */
|
|
|
|
+ log_notice(LD_HIST, "Circuit handshake stats since last time: "
|
|
|
|
+ "%d/%d TAP, %d/%d NTor.",
|
|
|
|
+ onion_handshakes_completed[ONION_HANDSHAKE_TYPE_TAP],
|
|
|
|
+ onion_handshakes_requested[ONION_HANDSHAKE_TYPE_TAP],
|
|
|
|
+ onion_handshakes_completed[ONION_HANDSHAKE_TYPE_NTOR],
|
|
|
|
+ onion_handshakes_requested[ONION_HANDSHAKE_TYPE_NTOR]);
|
|
|
|
+ memset(onion_handshakes_completed, 0, sizeof(onion_handshakes_completed));
|
|
|
|
+ memset(onion_handshakes_requested, 0, sizeof(onion_handshakes_requested));
|
|
|
|
+}
|
|
|
|
+
|
|
/** Free all storage held by the OR/link history caches, by the
|
|
/** Free all storage held by the OR/link history caches, by the
|
|
* bandwidth history arrays, by the port history, or by statistics . */
|
|
* bandwidth history arrays, by the port history, or by statistics . */
|
|
void
|
|
void
|