소스 검색

Limit the number of different handshake reasons to report

If connections failed in more than 10 different states, let's just
report the top ten states.
Nick Mathewson 14 년 전
부모
커밋
b25ca8af06
1개의 변경된 파일7개의 추가작업 그리고 1개의 파일을 삭제
  1. 7 1
      src/or/connection_or.c

+ 7 - 1
src/or/connection_or.c

@@ -221,6 +221,9 @@ broken_state_count_compare(const void **a_ptr, const void **b_ptr)
   return a->count - b->count;
 }
 
+/** DOCDOC */
+#define MAX_REASONS_TO_REPORT 10
+
 /** DOCDOC */
 void
 connection_or_report_broken_states(int severity, int domain)
@@ -242,9 +245,12 @@ connection_or_report_broken_states(int severity, int domain)
 
   smartlist_sort(items, broken_state_count_compare);
 
-  log(severity, domain, "%d connections have failed:", total);
+  log(severity, domain, "%d connections have failed%s", total,
+      smartlist_len(items) > MAX_REASONS_TO_REPORT ? ". Top reasons:" : ":");
 
   SMARTLIST_FOREACH_BEGIN(items, const broken_state_count_t *, c) {
+    if (c_sl_idx > MAX_REASONS_TO_REPORT)
+      break;
     log(severity, domain,
         " %d connections died in state %s", (int)c->count, c->state);
   } SMARTLIST_FOREACH_END(c);