From fa24269a634f5b9b3c76c336d1c647691c9d262b Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Fri, 9 Jul 1999 22:26:18 +0000 Subject: [PATCH] (buffered_vfprintf): Add locking. --- stdio-common/vfprintf.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/stdio-common/vfprintf.c b/stdio-common/vfprintf.c index 263b0238c7b..db83a6a7b02 100644 --- a/stdio-common/vfprintf.c +++ b/stdio-common/vfprintf.c @@ -1746,13 +1746,21 @@ buffered_vfprintf (register _IO_FILE *s, const CHAR_T *format, /* Now print to helper instead. */ result = _IO_vfprintf (hp, format, args); + /* Lock stream. */ + __libc_cleanup_region_start ((void (*) (void *)) &_IO_funlockfile, s); + _IO_flockfile (s); + /* Now flush anything from the helper to the S. */ if ((to_flush = hp->_IO_write_ptr - hp->_IO_write_base) > 0) { if ((int) _IO_sputn (s, hp->_IO_write_base, to_flush) != to_flush) - return -1; + reesult = -1; } + /* Unlock the stream. */ + _IO_funlockfile (s); + __libc_cleanup_region_end (0); + return result; } -- 2.47.3