From 9b390baea003a95a92b36ec0bcd9afab81045f56 Mon Sep 17 00:00:00 2001 From: codedust Date: Wed, 27 Jan 2016 20:35:04 +0100 Subject: [PATCH] Fix a bug that causes 100% CPU load in timestamp_view.js When `millis_since` becomes larger than one week, `delay` becomes negative and is set to Zero. This causes an infinite loop and therefore 100% CPU usage (single thread). // FREEBIE --- js/views/timestamp_view.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/js/views/timestamp_view.js b/js/views/timestamp_view.js index 73d15693272c..7f475de2e676 100644 --- a/js/views/timestamp_view.js +++ b/js/views/timestamp_view.js @@ -34,10 +34,17 @@ } else { // more than a week ago // Day of week + time delay = 7 * 24 * 60 * 60 * 1000 - millis_since; + + if (delay < -(60 * 1000)) { + // more than one week and one minute ago + // don't do any further updates as the displayed timestamp + // won't change any more + return; + } } if (delay) { - if (delay < 0) { delay = 0; } + if (delay < 0) { delay = 1000; } this.timeout = setTimeout(this.update.bind(this), delay); } },