summaryrefslogtreecommitdiff
path: root/libio
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@gmail.com>2011-09-09 16:15:25 -0400
committerUlrich Drepper <drepper@gmail.com>2011-09-09 16:15:25 -0400
commitf22e10748fbabbf07161eb7a5540b8c0e18553c4 (patch)
tree3d9d7754fbf7ca9b80bc0d6a87c4be2c1c730e3d /libio
parentf3cdd4674892740f766ea0b5ab5e734e4a028cb0 (diff)
downloadglibc-f22e10748fbabbf07161eb7a5540b8c0e18553c4.tar.gz
Don't lock string streams in stream cleanup code
Diffstat (limited to 'libio')
-rw-r--r--libio/genops.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/libio/genops.c b/libio/genops.c
index 481fbc52b0..5d21c42404 100644
--- a/libio/genops.c
+++ b/libio/genops.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1993,1995,1997-2002, 2003, 2004, 2006, 2007
+/* Copyright (C) 1993,1995,1997-2002, 2003, 2004, 2006, 2007, 2011
Free Software Foundation, Inc.
This file is part of the GNU C Library.
@@ -471,7 +471,7 @@ _IO_default_xsputn (f, data, n)
f->_IO_write_ptr += count;
#endif
s += count;
- }
+ }
else if (count)
{
char *p = f->_IO_write_ptr;
@@ -479,9 +479,9 @@ _IO_default_xsputn (f, data, n)
for (i = count; --i >= 0; )
*p++ = *s++;
f->_IO_write_ptr = p;
- }
+ }
more -= count;
- }
+ }
if (more == 0 || _IO_OVERFLOW (f, (unsigned char) *s++) == EOF)
break;
more--;
@@ -534,9 +534,9 @@ _IO_default_xsgetn (fp, data, n)
while (--i >= 0)
*s++ = *p++;
fp->_IO_read_ptr = p;
- }
- more -= count;
- }
+ }
+ more -= count;
+ }
if (more == 0 || __underflow (fp) == EOF)
break;
}
@@ -959,7 +959,7 @@ _IO_unbuffer_write (void)
int cnt;
#define MAXTRIES 2
for (cnt = 0; cnt < MAXTRIES; ++cnt)
- if (_IO_lock_trylock (*fp->_lock) == 0)
+ if (fp->_lock == NULL || _IO_lock_trylock (*fp->_lock) == 0)
break;
else
/* Give the other thread time to finish up its use of the
@@ -978,7 +978,7 @@ _IO_unbuffer_write (void)
_IO_SETBUF (fp, NULL, 0);
- if (cnt < MAXTRIES)
+ if (cnt < MAXTRIES && fp->_lock != NULL)
_IO_lock_unlock (*fp->_lock);
}