Skip to content

Commit

Permalink
a potential segfault
Browse files Browse the repository at this point in the history
  • Loading branch information
horta committed Dec 3, 2021
1 parent 9f9c528 commit 1d735dd
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
cmake_minimum_required(VERSION 3.10 FATAL_ERROR)
project(
athr
VERSION 4.0.0
VERSION 4.0.1
LANGUAGES C
)
set(PROJECT_DESCRIPTION "Progress indicator library written in C.")
Expand Down
6 changes: 4 additions & 2 deletions src/athr.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,20 +111,22 @@ void athr_stop(struct athr *at)
{
atomic_store(&at->stop, true);
update(at);
thr_join(&at->thr);

if (elapsed_stop(&at->total_elapsed)) error("failed to elapsed_stop");

double seconds = ((double)elapsed_milliseconds(&at->total_elapsed)) / 1000.;
at->main.super.vtable->finish(&at->main.super, seconds);
athr_canvas_close(&at->main.canvas);
thr_detach(&at->thr);
}

void athr_stop_wait(struct athr *at)
{
atomic_store(&at->stop, true);
update(at);
athr_canvas_close(&at->main.canvas);
thr_join(&at->thr);

athr_canvas_close(&at->main.canvas);
}

void athr_disable_threading(bool disable)
Expand Down
2 changes: 1 addition & 1 deletion src/athr/athr.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ extern "C" {
#define ATHR_TIMESTEP 250

/* Limit on how long to update, in milliseconds. */
#define ATHR_TIMESTEP_LIMIT 1000
#define ATHR_TIMESTEP_LIMIT 750

struct athr
{
Expand Down
2 changes: 1 addition & 1 deletion src/canvas.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,6 @@ void athr_canvas_close(struct athr_canvas *canvas)
else
{
fprintf(stdout, "\n");
fflush(stderr);
fflush(stdout);
}
}

0 comments on commit 1d735dd

Please sign in to comment.