From 38c19f11583e5f7575f82b258bc76c21b39cd4a6 Mon Sep 17 00:00:00 2001 From: Fabian Keil Date: Thu, 28 Apr 2011 18:12:21 +0200 Subject: [PATCH] Do not lock the es_list when flushing it from es_deinit(). es_deinit() is only called through atexit() at which point pth_kill() may already have been called. Fixes (or at least works around) https://bugs.g10code.com/gnupg/issue1320 --- common/estream.c | 17 ++++++++++++++++- 1 files changed, 16 insertions(+), 1 deletions(-) diff --git a/common/estream.c b/common/estream.c index 5215e63..45983f9 100644 --- a/common/estream.c +++ b/common/estream.c @@ -270,6 +270,7 @@ static unsigned char custom_std_fds_valid[3]; /* Local prototypes. */ static void fname_set_internal (estream_t stream, const char *fname, int quote); +static int do_fflush (estream_t stream); @@ -396,6 +397,20 @@ es_list_iterate (estream_iterator_t iterator) return ret; } +/* Iterate over list of registered streams, calling ITERATOR for each + of them, but do not lock. */ +static int +es_list_iterate_unlocked (estream_iterator_t iterator) +{ + estream_list_t list_obj; + int ret = 0; + + for (list_obj = estream_list; list_obj; list_obj = list_obj->cdr) + ret |= (*iterator) (list_obj->car); + + return ret; +} + /* @@ -441,7 +456,7 @@ static void es_deinit (void) { /* Flush all streams. */ - es_fflush (NULL); + es_list_iterate_unlocked (do_fflush); } -- 1.7.4.5