From 2c961ee3441c350f5f4ade8ba5cffb82022dd6cf Mon Sep 17 00:00:00 2001 From: michaeloffner Date: Mon, 18 Dec 2023 11:32:06 +0100 Subject: [PATCH] LDEV-4406 - improve mail watcher itself --- core/src/main/cfml/context/gateway/MailWatcher.cfc | 14 +++++++++++--- loader/build.xml | 2 +- loader/pom.xml | 2 +- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/core/src/main/cfml/context/gateway/MailWatcher.cfc b/core/src/main/cfml/context/gateway/MailWatcher.cfc index 7c4fd64a86..89650da6a1 100755 --- a/core/src/main/cfml/context/gateway/MailWatcher.cfc +++ b/core/src/main/cfml/context/gateway/MailWatcher.cfc @@ -29,7 +29,7 @@ public void function start() output=false localmode=true { - while ( getState() EQ "stopping" ) { + if ( getState() EQ "stopping" ) { sleep(10); } variables.state="running"; @@ -37,7 +37,7 @@ var last =now(); var mail = ""; - while ( variables.state EQ "running" ){ + while ( variables.state EQ "running" ) { try { mails = getMailsNewerThan( config.server, config.port, config.username, config.password, config.attachmentpath, last); for ( el in mails ) { @@ -52,8 +52,10 @@ if ( getState() != "running" ) { break; } - sleep( variables.config.interval ); + sleep( variables.config.interval?:10 ); } + // set to stopped when we leave + variables.setState( "stopped" ); } public array function getMailsNewerThan( required string server, required numeric port, required string user, required string pass, @@ -86,6 +88,12 @@ public void function stop() output=false { writeLog ( text="stop", file="MailWatcher", type="information" ); variables.state="stopping"; + + sleep( (variables.config.interval?:10)+10 ); + // should be stopped, so we guess it is blockes somehow, because it will not run again, we can ignore it + if (getState() EQ "stopping" ) { + variables.state="stopping"; + } } public void function restart() output=false { diff --git a/loader/build.xml b/loader/build.xml index 7b8ca658b8..10cd76f668 100644 --- a/loader/build.xml +++ b/loader/build.xml @@ -2,7 +2,7 @@ - + diff --git a/loader/pom.xml b/loader/pom.xml index 34339ce3fa..f0c9264d4e 100644 --- a/loader/pom.xml +++ b/loader/pom.xml @@ -3,7 +3,7 @@ org.lucee lucee - 6.0.1.43-SNAPSHOT + 6.0.1.44-SNAPSHOT jar Lucee Loader Build