Skip to content

Commit

Permalink
Update PR
Browse files Browse the repository at this point in the history
* Update PR
  • Loading branch information
abraunegg committed Jul 3, 2024
1 parent af46efd commit d2b370c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
15 changes: 12 additions & 3 deletions src/log.d
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,16 @@ import std.file;
import std.datetime;
import std.concurrency;
import std.typecons;
import core.sync.mutex;
import core.sync.condition;
import core.thread;
import std.format;
import std.string;
import std.conv;

// What other modules that we have created do we need to import?
import util;

version(Notifications) {
import dnotify;
}
Expand Down Expand Up @@ -54,8 +58,10 @@ class LogBuffer {
}

~this() {
if (!isRunning) {
bufferLock.unlock();
if (!isRunning) {
if (exitHandlerTriggered) {
bufferLock.unlock();
}
}
}

Expand All @@ -80,7 +86,10 @@ class LogBuffer {
}

// Flush any remaining logs
flushBuffer();
flushBuffer();

// Sleep for a while to avoid busy-waiting
Thread.sleep(dur!"msecs"(100)); // Adjust the sleep duration as needed

// Exit scopes
scope(exit) {
Expand Down
8 changes: 5 additions & 3 deletions src/util.d
Original file line number Diff line number Diff line change
Expand Up @@ -1287,9 +1287,11 @@ void setupExitScopeSignalHandler() {
// Catch any SIGSEV generated by the exit scopes
extern(C) nothrow @nogc @system void exitScopeSignalHandler(int signo) {
if (signo == SIGSEGV) {
// Caught a SIGSEG but everything was shutdown cleanly .....
//printf("Caught a SIGSEG but everything was shutdown cleanly .....\n");
exit(0);
assumeNoGC ( () {
// Caught a SIGSEGV but everything was shutdown cleanly .....
//printf("Caught a SIGSEGV but everything was shutdown cleanly .....\n");
exit(0);
})();
}
}

Expand Down

0 comments on commit d2b370c

Please sign in to comment.