From cc4ce9207277c82c4e645cfc2a528c18cd93d551 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Wed, 5 Sep 2018 07:14:39 +0200 Subject: [PATCH] Only allow 1800 loops in a thread, to prevent email IMAP fetch stops working if mailserver is once unreachable. Fixes issue#1861. --- app/models/scheduler.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/models/scheduler.rb b/app/models/scheduler.rb index 5aa54e7ca..d5c0f079b 100644 --- a/app/models/scheduler.rb +++ b/app/models/scheduler.rb @@ -233,7 +233,9 @@ class Scheduler < ApplicationModel # start loop for periods equal or under 5 minutes if job.period && job.period <= 5.minutes + loop_count = 0 loop do + loop_count += 1 _start_job(job) job = Scheduler.lookup(id: job.id) @@ -246,6 +248,9 @@ class Scheduler < ApplicationModel # exit if there is no loop period defined break if !job.period + # only do a certain amount of loops in this thread + break if loop_count == 1800 + # wait until next run sleep job.period end