aboutsummaryrefslogtreecommitdiff
path: root/stdio-common/vfprintf.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>1999-07-09 22:22:21 +0000
committerUlrich Drepper <drepper@redhat.com>1999-07-09 22:22:21 +0000
commit5ef2d37b330420c89cd476afa83ca5a839094796 (patch)
tree14979d91d54cbc2a116baba918dd6d8f05c77c76 /stdio-common/vfprintf.c
parentfbb802fc7dcc06b8f76bf75de7529edabdd19d4f (diff)
downloadglibc-5ef2d37b330420c89cd476afa83ca5a839094796.zip
glibc-5ef2d37b330420c89cd476afa83ca5a839094796.tar.gz
glibc-5ef2d37b330420c89cd476afa83ca5a839094796.tar.bz2
Update.
1999-07-09 Ulrich Drepper <drepper@cygnus.com> * stdio-common/vfprintf.c (buffered_vfprintf): Add locking.
Diffstat (limited to 'stdio-common/vfprintf.c')
-rw-r--r--stdio-common/vfprintf.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/stdio-common/vfprintf.c b/stdio-common/vfprintf.c
index f167058..902a70d 100644
--- a/stdio-common/vfprintf.c
+++ b/stdio-common/vfprintf.c
@@ -1886,6 +1886,10 @@ buffered_vfprintf (register _IO_FILE *s, const CHAR_T *format,
/* Now print to helper instead. */
result = 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. */
#ifdef COMPILE_WPRINTF
if ((to_flush = (hp->_wide_data->_IO_write_ptr
@@ -1893,16 +1897,20 @@ buffered_vfprintf (register _IO_FILE *s, const CHAR_T *format,
{
if ((int) _IO_sputn (s, hp->_wide_data->_IO_write_base, to_flush)
!= to_flush)
- return -1;
+ result = -1;
}
#else
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;
+ result = -1;
}
#endif
+ /* Unlock the stream. */
+ _IO_funlockfile (s);
+ __libc_cleanup_region_end (0);
+
return result;
}