summaryrefslogtreecommitdiffstats
path: root/newlib/libc/stdio/fclose.c
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2015-12-08 21:23:22 +0100
committerCorinna Vinschen <corinna@vinschen.de>2015-12-08 21:23:22 +0100
commit91a8eacec6575a3a2c6aa4c4cf26961870f6074a (patch)
treef5eddf39c5d7e22f148092859eeef55f141ae332 /newlib/libc/stdio/fclose.c
parent414e7948118bb3b7071e7c8cbddcf371e0d48e38 (diff)
downloadcygnal-91a8eacec6575a3a2c6aa4c4cf26961870f6074a.tar.gz
cygnal-91a8eacec6575a3a2c6aa4c4cf26961870f6074a.tar.bz2
cygnal-91a8eacec6575a3a2c6aa4c4cf26961870f6074a.zip
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>
Diffstat (limited to 'newlib/libc/stdio/fclose.c')
-rw-r--r--newlib/libc/stdio/fclose.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/newlib/libc/stdio/fclose.c b/newlib/libc/stdio/fclose.c
index cd271c490..0ce112306 100644
--- a/newlib/libc/stdio/fclose.c
+++ b/newlib/libc/stdio/fclose.c
@@ -82,11 +82,13 @@ _DEFUN(_fclose_r, (rptr, fp),
int __oldcancel;
pthread_setcancelstate (PTHREAD_CANCEL_DISABLE, &__oldcancel);
#endif
- _flockfile (fp);
+ if (!(fp->_flags2 & __SNLK))
+ _flockfile (fp);
if (fp->_flags == 0) /* not open! */
{
- _funlockfile (fp);
+ if (!(fp->_flags2 & __SNLK))
+ _funlockfile (fp);
#ifdef _STDIO_WITH_THREAD_CANCELLATION_SUPPORT
pthread_setcancelstate (__oldcancel, &__oldcancel);
#endif
@@ -111,7 +113,8 @@ _DEFUN(_fclose_r, (rptr, fp),
FREELB (rptr, fp);
__sfp_lock_acquire ();
fp->_flags = 0; /* release this FILE for reuse */
- _funlockfile (fp);
+ if (!(fp->_flags2 & __SNLK))
+ _funlockfile (fp);
#ifndef __SINGLE_THREAD__
__lock_close_recursive (fp->_lock);
#endif