From ce832e9fe8e98e972adbc0ca55fc614dd7234192 Mon Sep 17 00:00:00 2001 From: Mihails Strasuns Date: Thu, 12 Jul 2018 13:12:18 +0300 Subject: [PATCH 1/2] Ignore tasks scheduled during shutdown Because of missing return statement, trying to schedule a new task after shutdown would succeed but result in application infinitely stuck during shutdown sequence. With this fix, any such tasks will be ignored allowing for clean exit. There is a concern of losing app data but it will have to be addressed in a separate changest, targetting minor or maybe even major branch. --- src/ocean/task/Scheduler.d | 1 + 1 file changed, 1 insertion(+) diff --git a/src/ocean/task/Scheduler.d b/src/ocean/task/Scheduler.d index 3093f0102..ec21dab4e 100644 --- a/src/ocean/task/Scheduler.d +++ b/src/ocean/task/Scheduler.d @@ -334,6 +334,7 @@ final class Scheduler : IScheduler auto caller_task = Task.getThis(); if (caller_task !is null) caller_task.kill(); + return; } try From 75b4da23bc8bee9117121a97d59ea9e7a613289a Mon Sep 17 00:00:00 2001 From: Mihails Strasuns Date: Thu, 12 Jul 2018 13:32:34 +0300 Subject: [PATCH 2/2] Add comment explaining shutdown logic --- src/ocean/task/Scheduler.d | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/ocean/task/Scheduler.d b/src/ocean/task/Scheduler.d index ec21dab4e..0d8cdec14 100644 --- a/src/ocean/task/Scheduler.d +++ b/src/ocean/task/Scheduler.d @@ -331,6 +331,11 @@ final class Scheduler : IScheduler { if (this.state == State.Shutdown) { + // Simply returning here would be generally sufficient to make sure + // no new tasks get added after shutdown. However, it is of some + // merit to try to kill everything as soon as possible thus + // scheduler kills the caller tasks on any attempt to schedule a new + // one. auto caller_task = Task.getThis(); if (caller_task !is null) caller_task.kill();