mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-05-20 19:50:24 +02:00
Do not assume `pthread_t' is an integer type.
Fixes <http://bugs.gnu.org/14469>. Reported by Panicz Maciej Godek <godek.maciek@gmail.com>. * libguile/finalizers.c (finalization_thread_is_running): New variable. (start_finalization_thread): Use it to determine whether FINALIZATION_THREAD is up and running. (stop_finalization_thread): Likewise.
This commit is contained in:
parent
b782ed0137
commit
1701a68920
1 changed files with 15 additions and 10 deletions
|
@ -185,6 +185,7 @@ static int finalization_pipe[2];
|
||||||
static scm_i_pthread_mutex_t finalization_thread_lock =
|
static scm_i_pthread_mutex_t finalization_thread_lock =
|
||||||
SCM_I_PTHREAD_MUTEX_INITIALIZER;
|
SCM_I_PTHREAD_MUTEX_INITIALIZER;
|
||||||
static pthread_t finalization_thread;
|
static pthread_t finalization_thread;
|
||||||
|
static int finalization_thread_is_running = 0;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
notify_finalizers_to_run (void)
|
notify_finalizers_to_run (void)
|
||||||
|
@ -256,7 +257,8 @@ static void
|
||||||
start_finalization_thread (void)
|
start_finalization_thread (void)
|
||||||
{
|
{
|
||||||
scm_i_pthread_mutex_lock (&finalization_thread_lock);
|
scm_i_pthread_mutex_lock (&finalization_thread_lock);
|
||||||
if (!finalization_thread)
|
if (!finalization_thread_is_running)
|
||||||
|
{
|
||||||
/* Use the raw pthread API and scm_with_guile, because we don't want
|
/* Use the raw pthread API and scm_with_guile, because we don't want
|
||||||
to block on any lock that scm_spawn_thread might want to take,
|
to block on any lock that scm_spawn_thread might want to take,
|
||||||
and we don't want to inherit the dynamic state (fluids) of the
|
and we don't want to inherit the dynamic state (fluids) of the
|
||||||
|
@ -264,6 +266,9 @@ start_finalization_thread (void)
|
||||||
if (pthread_create (&finalization_thread, NULL,
|
if (pthread_create (&finalization_thread, NULL,
|
||||||
run_finalization_thread, NULL))
|
run_finalization_thread, NULL))
|
||||||
perror ("error creating finalization thread");
|
perror ("error creating finalization thread");
|
||||||
|
else
|
||||||
|
finalization_thread_is_running = 1;
|
||||||
|
}
|
||||||
scm_i_pthread_mutex_unlock (&finalization_thread_lock);
|
scm_i_pthread_mutex_unlock (&finalization_thread_lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -271,12 +276,12 @@ static void
|
||||||
stop_finalization_thread (void)
|
stop_finalization_thread (void)
|
||||||
{
|
{
|
||||||
scm_i_pthread_mutex_lock (&finalization_thread_lock);
|
scm_i_pthread_mutex_lock (&finalization_thread_lock);
|
||||||
if (finalization_thread)
|
if (finalization_thread_is_running)
|
||||||
{
|
{
|
||||||
notify_about_to_fork ();
|
notify_about_to_fork ();
|
||||||
if (pthread_join (finalization_thread, NULL))
|
if (pthread_join (finalization_thread, NULL))
|
||||||
perror ("joining finalization thread");
|
perror ("joining finalization thread");
|
||||||
finalization_thread = 0;
|
finalization_thread_is_running = 0;
|
||||||
}
|
}
|
||||||
scm_i_pthread_mutex_unlock (&finalization_thread_lock);
|
scm_i_pthread_mutex_unlock (&finalization_thread_lock);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue