From: Ulrich Drepper Date: Fri, 9 Jul 1999 22:26:18 +0000 (+0000) Subject: (buffered_vfprintf): Add locking. X-Git-Tag: cvs/glibc_2-1-2~290 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=fa24269a634f5b9b3c76c336d1c647691c9d262b;p=thirdparty%2Fglibc.git (buffered_vfprintf): Add locking. --- 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; }