From 99d6c367c4820a072dc4ada51561df17e2093778 Mon Sep 17 00:00:00 2001 From: Eric Andersen Date: Wed, 6 Dec 2006 22:41:21 +0000 Subject: stdio update from mjn3 --- libc/stdio/_stdio.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'libc/stdio/_stdio.c') diff --git a/libc/stdio/_stdio.c b/libc/stdio/_stdio.c index 6c96d8660..c406792d7 100644 --- a/libc/stdio/_stdio.c +++ b/libc/stdio/_stdio.c @@ -154,8 +154,12 @@ FILE *__stdout = _stdio_streams + 1; /* For putchar() macro. */ FILE *_stdio_openlist = _stdio_streams; # ifdef __UCLIBC_HAS_THREADS__ -pthread_mutex_t _stdio_openlist_lock = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP; -int _stdio_openlist_delflag = 0; +pthread_mutex_t _stdio_openlist_add_lock = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP; +#ifdef __STDIO_BUFFERS +pthread_mutex_t _stdio_openlist_del_lock = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP; +volatile int _stdio_openlist_use_count = 0; +int _stdio_openlist_del_count = 0; +#endif # endif #endif @@ -187,7 +191,11 @@ void attribute_hidden _stdio_term(void) * locked, then I suppose there is a chance that a pointer in the * chain might be corrupt due to a partial store. */ - __stdio_init_mutex(&_stdio_openlist_lock); + __stdio_init_mutex(&_stdio_openlist_add_lock); +#warning check +#ifdef __STDIO_BUFFERS + __stdio_init_mutex(&_stdio_openlist_del_lock); +#endif /* Next we need to worry about the streams themselves. If a stream * is currently locked, then it may be in an invalid state. So we @@ -195,7 +203,7 @@ void attribute_hidden _stdio_term(void) * Then we reinitialize the locks. */ for (ptr = _stdio_openlist ; ptr ; ptr = ptr->__nextopen ) { - if (__STDIO_ALWAYS_THREADTRYLOCK(ptr)) { + if (__STDIO_ALWAYS_THREADTRYLOCK_CANCEL_UNSAFE(ptr)) { /* The stream is already locked, so we don't want to touch it. * However, if we have custom streams, we can't just close it * or leave it locked since a custom stream may be stacked -- cgit v1.2.3