Only allow 1800 loops in a thread, to prevent email IMAP fetch stops working if mailserver is once unreachable. Fixes issue#1861.

This commit is contained in:
Martin Edenhofer 2018-09-05 07:14:39 +02:00
parent 15d8cb213d
commit cc4ce92072

View file

@ -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