* stdlib/cxa_finalize.c (__cxa_finalize): Don't call
	UNREGISTER_ATFORK if d == NULL.
This commit is contained in:
Ulrich Drepper 2003-04-19 18:26:10 +00:00
parent 2c008571c3
commit 4e648ea3ad
5 changed files with 57 additions and 20 deletions

View File

@ -1,5 +1,8 @@
2003-04-19 Ulrich Drepper <drepper@redhat.com>
* stdlib/cxa_finalize.c (__cxa_finalize): Don't call
UNREGISTER_ATFORK if d == NULL.
* catgets/nl_types.h: Remove __THROW marker from cancellation points.
* dirent/dirent.h: Likewise.
* dlfcn/dlfcn.h: Likewise.

View File

@ -1,4 +1,4 @@
/* Copyright (C) 2002 Free Software Foundation, Inc.
/* Copyright (C) 2002, 2003 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@ -48,14 +48,19 @@ extern int sem_close (sem_t *__sem) __THROW;
/* Remove named semaphore NAME. */
extern int sem_unlink (__const char *__name) __THROW;
/* Wait for SEM being posted. */
extern int sem_wait (sem_t *__sem) __THROW;
/* Wait for SEM being posted.
This function is a cancellation point and therefore not marked with
__THROW. */
extern int sem_wait (sem_t *__sem);
#ifdef __USE_XOPEN2K
/* Similar to `sem_wait' but wait only until ABSTIME. */
/* Similar to `sem_wait' but wait only until ABSTIME.
This function is a cancellation point and therefore not marked with
__THROW. */
extern int sem_timedwait (sem_t *__restrict __sem,
__const struct timespec *__restrict __abstime)
__THROW;
__const struct timespec *__restrict __abstime);
#endif
/* Test whether SEM is posted. */

View File

@ -182,8 +182,11 @@ extern void pthread_exit (void *__retval)
/* Make calling thread wait for termination of the thread TH. The
exit status of the thread is stored in *THREAD_RETURN, if THREAD_RETURN
is not NULL. */
extern int pthread_join (pthread_t __th, void **__thread_return) __THROW;
is not NULL.
This function is a cancellation point and therefore not marked with
__THROW. */
extern int pthread_join (pthread_t __th, void **__thread_return);
#ifdef __USE_GNU
/* Check whether thread TH has terminated. If yes return the status of
@ -192,9 +195,12 @@ extern int pthread_tryjoin_np (pthread_t __th, void **__thread_return) __THROW;
/* Make calling thread wait for termination of the thread TH, but only
until TIMEOUT. The exit status of the thread is stored in
*THREAD_RETURN, if THREAD_RETURN is not NULL. */
*THREAD_RETURN, if THREAD_RETURN is not NULL.
This function is a cancellation point and therefore not marked with
__THROW. */
extern int pthread_timedjoin_np (pthread_t __th, void **__thread_return,
__const struct timespec *__abstime) __THROW;
__const struct timespec *__abstime);
#endif
/* Indicate that the thread TH is never to be joined with PTHREAD_JOIN.
@ -635,18 +641,24 @@ extern int pthread_cond_signal (pthread_cond_t *__cond) __THROW;
extern int pthread_cond_broadcast (pthread_cond_t *__cond) __THROW;
/* Wait for condition variable COND to be signaled or broadcast.
MUTEX is assumed to be locked before. */
MUTEX is assumed to be locked before.
This function is a cancellation point and therefore not marked with
__THROW. */
extern int pthread_cond_wait (pthread_cond_t *__restrict __cond,
pthread_mutex_t *__restrict __mutex) __THROW;
pthread_mutex_t *__restrict __mutex);
/* Wait for condition variable COND to be signaled or broadcast until
ABSTIME. MUTEX is assumed to be locked before. ABSTIME is an
absolute time specification; zero is the beginning of the epoch
(00:00:00 GMT, January 1, 1970). */
(00:00:00 GMT, January 1, 1970).
This function is a cancellation point and therefore not marked with
__THROW. */
extern int pthread_cond_timedwait (pthread_cond_t *__restrict __cond,
pthread_mutex_t *__restrict __mutex,
__const struct timespec *__restrict
__abstime) __THROW;
__abstime);
/* Functions for handling condition variable attributes. */

View File

@ -22,6 +22,14 @@
#include "fork.h"
/* Defined in libc_pthread_init.c. */
extern struct fork_handler __pthread_child_handler attribute_hidden;
/* Three static memory blocks used when registering malloc. */
static struct fork_handler malloc_prepare;
static struct fork_handler malloc_parent;
static struct fork_handler malloc_child;
void
__unregister_atfork (dso_handle)
void *dso_handle;
@ -37,7 +45,9 @@ __unregister_atfork (dso_handle)
{
list_del (runp);
free (list_entry (runp, struct fork_handler, list));
struct fork_handler *p = list_entry (runp, struct fork_handler, list);
if (p != &malloc_prepare)
free (p);
}
list_for_each_prev_safe (runp, prevp, &__fork_parent_list)
@ -45,7 +55,9 @@ __unregister_atfork (dso_handle)
{
list_del (runp);
free (list_entry (runp, struct fork_handler, list));
struct fork_handler *p = list_entry (runp, struct fork_handler, list);
if (p != &malloc_parent)
free (p);
}
list_for_each_prev_safe (runp, prevp, &__fork_child_list)
@ -53,7 +65,9 @@ __unregister_atfork (dso_handle)
{
list_del (runp);
free (list_entry (runp, struct fork_handler, list));
struct fork_handler *p = list_entry (runp, struct fork_handler, list);
if (p != &__pthread_child_handler && p != &malloc_child)
free (p);
}
/* Release the lock. */

View File

@ -23,7 +23,8 @@
#include <fork.h>
/* If D is non-NULL, call all functions registered with `__cxa_atexit'
with the same dso handle. Otherwise, if D is NULL, do nothing. */
with the same dso handle. Otherwise, if D is NULL, call all of the
registered handlers. */
void
__cxa_finalize (void *d)
{
@ -41,8 +42,10 @@ __cxa_finalize (void *d)
(*f->func.cxa.fn) (f->func.cxa.arg, 0);
}
/* Remove the registered fork handlers. */
/* Remove the registered fork handlers. We do not have to
unregister anything if the program is going to terminate anyway. */
#ifdef UNREGISTER_ATFORK
UNREGISTER_ATFORK (d);
if (d != NULL)
UNREGISTER_ATFORK (d);
#endif
}