]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
sched: Rate limit scheduler_bug_occurred()
authorDavid Goulet <dgoulet@torproject.org>
Thu, 26 Oct 2017 18:44:44 +0000 (14:44 -0400)
committerNick Mathewson <nickm@torproject.org>
Thu, 2 Nov 2017 14:30:33 +0000 (10:30 -0400)
Just in case we end up hitting a SCHED_BUG() multiple times, rate limit the
log warning.

Signed-off-by: David Goulet <dgoulet@torproject.org>
src/or/scheduler.c

index 67911ff81ebf2b70fdd37588d9b74562035e2024..97b6d40b1e64bde6d15057c997a0bcbdecbe0eae 100644 (file)
@@ -690,10 +690,21 @@ scheduler_bug_occurred(const channel_t *chan)
                  outbuf_len);
   }
 
-  log_warn(LD_BUG, "%s Num pending channels: %d. Channel in pending list: %s",
-           (chan != NULL) ? buf : "No channel in bug context.",
-           smartlist_len(channels_pending),
-           (smartlist_pos(channels_pending, chan) == -1) ? "no" : "yes");
+  {
+    char *msg;
+    /* Rate limit every 60 seconds. If we start seeing this every 60 sec, we
+     * know something is stuck/wrong. It *should* be loud but not too much. */
+    static ratelim_t rlimit = RATELIM_INIT(60);
+    if ((msg = rate_limit_log(&rlimit, approx_time()))) {
+      log_warn(LD_BUG, "%s Num pending channels: %d. "
+                       "Channel in pending list: %s.%s",
+               (chan != NULL) ? buf : "No channel in bug context.",
+               smartlist_len(channels_pending),
+               (smartlist_pos(channels_pending, chan) == -1) ? "no" : "yes",
+               msg);
+      tor_free(msg);
+    }
+  }
 }
 
 #ifdef TOR_UNIT_TESTS