Skip to content

Commit

Permalink
minor safety improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
Absolucy committed Nov 23, 2024
1 parent 614ffd3 commit 3e72fff
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion prof.c
Original file line number Diff line number Diff line change
Expand Up @@ -993,6 +993,7 @@ int utracy_server_thread_start(void* arg) {

utracy_flush();
close_event_pipe(utracy.quit);
utracy.quit = NULL;
return 0;
}

Expand Down Expand Up @@ -1637,7 +1638,11 @@ char *UTRACY_WINDOWS_CDECL UTRACY_LINUX_CDECL destroy(int argc, char **argv) {

if (!initialized) {
return "not initialized";
}
} else if (utracy.fstream == NULL) {
return "file stream closed";
} else if (utracy.quit == NULL) {
return "already shutting down";
}

set_event_pipe(utracy.quit);

Expand All @@ -1648,8 +1653,10 @@ char *UTRACY_WINDOWS_CDECL UTRACY_LINUX_CDECL destroy(int argc, char **argv) {
}

close_event_pipe(utracy.quit);
utracy.quit = NULL;
utracy_flush();
fclose(utracy.fstream);
utracy.fstream = NULL;
initialized = false;

return "0";
Expand All @@ -1664,6 +1671,8 @@ char *UTRACY_WINDOWS_CDECL UTRACY_LINUX_CDECL flush(int argc, char **argv) {
return "not initialized";
} else if(utracy.fstream == NULL) {
return "file stream closed";
} else if (utracy.quit == NULL) {
return "already shutting down";
}

// Then ensure it's written to disk
Expand Down

0 comments on commit 3e72fff

Please sign in to comment.