Skip to content

Commit

Permalink
lib: Fix a deadlock in exit condition
Browse files Browse the repository at this point in the history
The driver was calling cr_renderer_stop() from within the on_status
callback, which should be fine, but we weren't checking for. Now we
check for it.
  • Loading branch information
vkoskiv committed Jan 4, 2024
1 parent 7ede985 commit 7d65d54
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/lib/api/c-ray.c
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ void cr_renderer_stop(struct cr_renderer *ext) {
if (!ext) return;
struct renderer *r = (struct renderer *)ext;
r->state.render_aborted = true;
while (!r->state.interactive_exit_done) {
while (r->prefs.iterative && !r->state.exit_done) {
timer_sleep_ms(10);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/lib/renderer/renderer.c
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ void renderer_render(struct renderer *r) {
if (info_tiles) free(info_tiles);
tile_set_free(&set);
logr(info, "Renderer exiting\n");
r->state.interactive_exit_done = true;
r->state.exit_done = true;
}

// An interactive render thread that progressively
Expand Down
2 changes: 1 addition & 1 deletion src/lib/renderer/renderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ struct state {
bool rendering;
// TODO: Rename to request_abort, and use an enum for actual state
bool render_aborted; //SDL listens for X key pressed, which sets this
bool interactive_exit_done;
bool exit_done;
struct worker_arr workers;
struct render_client_arr clients;
struct callback callbacks[5];
Expand Down

0 comments on commit 7d65d54

Please sign in to comment.