Skip to content

Commit

Permalink
Fix memory leak on exit when using webhooks
Browse files Browse the repository at this point in the history
* Fix memory leak on exit when using webhooks
  • Loading branch information
abraunegg committed Oct 28, 2023
1 parent 4df36ff commit 3798e1a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
4 changes: 0 additions & 4 deletions src/main.d
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
6 changes: 4 additions & 2 deletions src/onedrive.d
Original file line number Diff line number Diff line change
Expand Up @@ -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_;
Expand Down Expand Up @@ -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
Expand All @@ -128,7 +130,7 @@ class OneDriveWebhook {
}

private void serveImpl() {
auto server = new RequestServer(host, port);
server = RequestServer(host, port);
server.serveEmbeddedHttp!handle();
}

Expand Down

0 comments on commit 3798e1a

Please sign in to comment.