Add missing checks for __SNLK flag
* libc/stdio/fclose.c (_fclose_r): Make _flockfile/_funlockfile calls dependent on __SNLK flag. * libc/stdio/findfp.c (__fp_lock): Ditto. (__fp_unlock): Ditto. * libc/stdio/freopen.c (_freopen_r): Ditto. * libc/stdio64/freopen64.c (_freopen64_r): Ditto. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
This commit is contained in:
parent
414e794811
commit
91a8eacec6
|
@ -1,3 +1,12 @@
|
|||
2015-12-08 Corinna Vinschen <corinna@vinschen.de>
|
||||
|
||||
* libc/stdio/fclose.c (_fclose_r): Make _flockfile/_funlockfile calls
|
||||
dependent on __SNLK flag.
|
||||
* libc/stdio/findfp.c (__fp_lock): Ditto.
|
||||
(__fp_unlock): Ditto.
|
||||
* libc/stdio/freopen.c (_freopen_r): Ditto.
|
||||
* libc/stdio64/freopen64.c (_freopen64_r): Ditto.
|
||||
|
||||
2015-12-08 Corinna Vinschen <corinna@vinschen.de>
|
||||
|
||||
* libc/stdio/freopen.c (_freopen_r): Only reset __SWID bit per SUSv4.
|
||||
|
|
|
@ -82,10 +82,12 @@ _DEFUN(_fclose_r, (rptr, fp),
|
|||
int __oldcancel;
|
||||
pthread_setcancelstate (PTHREAD_CANCEL_DISABLE, &__oldcancel);
|
||||
#endif
|
||||
if (!(fp->_flags2 & __SNLK))
|
||||
_flockfile (fp);
|
||||
|
||||
if (fp->_flags == 0) /* not open! */
|
||||
{
|
||||
if (!(fp->_flags2 & __SNLK))
|
||||
_funlockfile (fp);
|
||||
#ifdef _STDIO_WITH_THREAD_CANCELLATION_SUPPORT
|
||||
pthread_setcancelstate (__oldcancel, &__oldcancel);
|
||||
|
@ -111,6 +113,7 @@ _DEFUN(_fclose_r, (rptr, fp),
|
|||
FREELB (rptr, fp);
|
||||
__sfp_lock_acquire ();
|
||||
fp->_flags = 0; /* release this FILE for reuse */
|
||||
if (!(fp->_flags2 & __SNLK))
|
||||
_funlockfile (fp);
|
||||
#ifndef __SINGLE_THREAD__
|
||||
__lock_close_recursive (fp->_lock);
|
||||
|
|
|
@ -293,6 +293,7 @@ static int
|
|||
_DEFUN(__fp_lock, (ptr),
|
||||
FILE * ptr)
|
||||
{
|
||||
if (!(ptr->_flags2 & __SNLK))
|
||||
_flockfile (ptr);
|
||||
|
||||
return 0;
|
||||
|
@ -303,6 +304,7 @@ static int
|
|||
_DEFUN(__fp_unlock, (ptr),
|
||||
FILE * ptr)
|
||||
{
|
||||
if (!(ptr->_flags2 & __SNLK))
|
||||
_funlockfile (ptr);
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -95,7 +95,7 @@ _DEFUN(_freopen_r, (ptr, file, mode, fp),
|
|||
register FILE *__restrict fp)
|
||||
{
|
||||
register int f;
|
||||
int flags, oflags;
|
||||
int flags, oflags, oflags2;
|
||||
int e = 0;
|
||||
|
||||
CHECK_INIT (ptr, fp);
|
||||
|
@ -106,10 +106,13 @@ _DEFUN(_freopen_r, (ptr, file, mode, fp),
|
|||
int __oldcancel;
|
||||
pthread_setcancelstate (PTHREAD_CANCEL_DISABLE, &__oldcancel);
|
||||
#endif
|
||||
oflags2 = fp->_flags2;
|
||||
if (!(oflags2 & __SNLK))
|
||||
_flockfile (fp);
|
||||
|
||||
if ((flags = __sflags (ptr, mode, &oflags)) == 0)
|
||||
{
|
||||
if (!(oflags2 & __SNLK))
|
||||
_funlockfile (fp);
|
||||
#ifdef _STDIO_WITH_THREAD_CANCELLATION_SUPPORT
|
||||
pthread_setcancelstate (__oldcancel, &__oldcancel);
|
||||
|
@ -217,6 +220,7 @@ _DEFUN(_freopen_r, (ptr, file, mode, fp),
|
|||
__sfp_lock_acquire ();
|
||||
fp->_flags = 0; /* set it free */
|
||||
ptr->_errno = e; /* restore in case _close clobbered */
|
||||
if (!(oflags2 & __SNLK))
|
||||
_funlockfile (fp);
|
||||
#ifndef __SINGLE_THREAD__
|
||||
__lock_close_recursive (fp->_lock);
|
||||
|
@ -241,6 +245,7 @@ _DEFUN(_freopen_r, (ptr, file, mode, fp),
|
|||
fp->_flags |= __SCLE;
|
||||
#endif
|
||||
|
||||
if (!(oflags2 & __SNLK))
|
||||
_funlockfile (fp);
|
||||
#ifdef _STDIO_WITH_THREAD_CANCELLATION_SUPPORT
|
||||
pthread_setcancelstate (__oldcancel, &__oldcancel);
|
||||
|
|
|
@ -94,7 +94,7 @@ _DEFUN (_freopen64_r, (ptr, file, mode, fp),
|
|||
register FILE *fp)
|
||||
{
|
||||
register int f;
|
||||
int flags, oflags;
|
||||
int flags, oflags, oflags2;
|
||||
int e = 0;
|
||||
|
||||
|
||||
|
@ -106,10 +106,13 @@ _DEFUN (_freopen64_r, (ptr, file, mode, fp),
|
|||
int __oldcancel;
|
||||
pthread_setcancelstate (PTHREAD_CANCEL_DISABLE, &__oldcancel);
|
||||
#endif
|
||||
oflags2 = fp->_flags2;
|
||||
if (!(oflags2 & __SNLK))
|
||||
_flockfile (fp);
|
||||
|
||||
if ((flags = __sflags (ptr, mode, &oflags)) == 0)
|
||||
{
|
||||
if (!(oflags2 & __SNLK))
|
||||
_funlockfile (fp);
|
||||
#ifdef _STDIO_WITH_THREAD_CANCELLATION_SUPPORT
|
||||
pthread_setcancelstate (__oldcancel, &__oldcancel);
|
||||
|
@ -217,6 +220,7 @@ _DEFUN (_freopen64_r, (ptr, file, mode, fp),
|
|||
__sfp_lock_acquire ();
|
||||
fp->_flags = 0; /* set it free */
|
||||
ptr->_errno = e; /* restore in case _close clobbered */
|
||||
if (!(oflags2 & __SNLK))
|
||||
_funlockfile (fp);
|
||||
#ifndef __SINGLE_THREAD__
|
||||
__lock_close_recursive (fp->_lock);
|
||||
|
@ -244,6 +248,7 @@ _DEFUN (_freopen64_r, (ptr, file, mode, fp),
|
|||
|
||||
fp->_flags |= __SL64;
|
||||
|
||||
if (!(oflags2 & __SNLK))
|
||||
_funlockfile (fp);
|
||||
#if !defined (__SINGLE_THREAD__) && defined (_POSIX_THREADS)
|
||||
pthread_setcancelstate (__oldcancel, &__oldcancel);
|
||||
|
|
Loading…
Reference in New Issue