From 3798e1acd0576b52e300dbcbf905cdb9ee06a9f4 Mon Sep 17 00:00:00 2001 From: abraunegg Date: Sun, 29 Oct 2023 08:04:57 +1100 Subject: [PATCH] Fix memory leak on exit when using webhooks * Fix memory leak on exit when using webhooks --- src/main.d | 4 ---- src/onedrive.d | 6 ++++-- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/main.d b/src/main.d index f0fe6bc71..4a01e3b5a 100644 --- a/src/main.d +++ b/src/main.d @@ -899,10 +899,6 @@ void performStandardExitProcess(string scopeCaller) { // Who called this function log.vdebug("Running performStandardExitProcess due to: ", scopeCaller); - // Wait for all parallel jobs that depend on the database to complete - log.vdebug("Wait for all parallel jobs that depend on the database to complete"); - taskPool.finish(true); - // Shutdown the OneDrive API instance if (oneDriveApiInstance !is null) { log.vdebug("Shutdown OneDrive API instance"); diff --git a/src/onedrive.d b/src/onedrive.d index c81271c2f..828c54544 100644 --- a/src/onedrive.d +++ b/src/onedrive.d @@ -68,6 +68,7 @@ class OneDriveWebhook { // Cache instantiation flag in thread-local bool // Thread local private static bool instantiated_; + private RequestServer server; // Thread global private __gshared OneDriveWebhook instance_; @@ -107,10 +108,11 @@ class OneDriveWebhook { void stop() { if (this.started) { - RequestServer.stop(); + server.stop(); this.started = false; } log.log("Stopped webhook server"); + object.destroy(server); } // The static serve() is necessary because spawn() does not like instance methods @@ -128,7 +130,7 @@ class OneDriveWebhook { } private void serveImpl() { - auto server = new RequestServer(host, port); + server = RequestServer(host, port); server.serveEmbeddedHttp!handle(); }