mirror of git://sourceware.org/git/glibc.git
* libio/genops.c (_IO_unbuffer_write): Give concurrently running
threads the chance to work correctly by trying to lock the stream. If this does not work, proceed without locking.
This commit is contained in:
parent
7876272372
commit
af047cff71
|
@ -1,3 +1,9 @@
|
||||||
|
2006-01-11 Ulrich Drepper <drepper@redhat.com>
|
||||||
|
|
||||||
|
* libio/genops.c (_IO_unbuffer_write): Give concurrently running
|
||||||
|
threads the chance to work correctly by trying to lock the stream.
|
||||||
|
If this does not work, proceed without locking.
|
||||||
|
|
||||||
2006-01-10 Ulrich Drepper <drepper@redhat.com>
|
2006-01-10 Ulrich Drepper <drepper@redhat.com>
|
||||||
|
|
||||||
* libio/genops.c (_IO_unbuffer_write): Don't always free the
|
* libio/genops.c (_IO_unbuffer_write): Don't always free the
|
||||||
|
|
|
@ -947,6 +947,16 @@ _IO_unbuffer_write (void)
|
||||||
/* Iff stream is un-orientated, it wasn't used. */
|
/* Iff stream is un-orientated, it wasn't used. */
|
||||||
&& fp->_mode != 0)
|
&& fp->_mode != 0)
|
||||||
{
|
{
|
||||||
|
int cnt;
|
||||||
|
#define MAXTRIES 2
|
||||||
|
for (cnt = 0; cnt < MAXTRIES; ++cnt)
|
||||||
|
if (_IO_lock_trylock (*fp->_lock) == 0)
|
||||||
|
break;
|
||||||
|
else
|
||||||
|
/* Give the other thread time to finish up its use of the
|
||||||
|
stream. */
|
||||||
|
__sched_yield ();
|
||||||
|
|
||||||
if (! dealloc_buffers && !(fp->_flags & _IO_USER_BUF))
|
if (! dealloc_buffers && !(fp->_flags & _IO_USER_BUF))
|
||||||
{
|
{
|
||||||
fp->_flags |= _IO_USER_BUF;
|
fp->_flags |= _IO_USER_BUF;
|
||||||
|
@ -958,6 +968,9 @@ _IO_unbuffer_write (void)
|
||||||
}
|
}
|
||||||
|
|
||||||
_IO_SETBUF (fp, NULL, 0);
|
_IO_SETBUF (fp, NULL, 0);
|
||||||
|
|
||||||
|
if (cnt < MAXTRIES)
|
||||||
|
_IO_lock_unlock (*fp->_lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Make sure that never again the wide char functions can be
|
/* Make sure that never again the wide char functions can be
|
||||||
|
|
Loading…
Reference in New Issue